/* Uploadify v2.1.4 Release Date: November 8, 2010 Copyright (c) 2010 Ronnie Garcia, Travis Nickels Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ if(jQuery)( function(jQuery){ jQuery.extend(jQuery.fn,{ uploadify:function(options) { jQuery(this).each(function(){ var settings = jQuery.extend({ id : jQuery(this).attr('id'), // The ID of the object being Uploadified uploader : 'uploadify.swf', // The path to the uploadify swf file script : 'uploadify.php', // The path to the uploadify backend upload script expressInstall : null, // The path to the express install swf file folder : '', // The path to the upload folder height : 30, // The height of the flash button width : 120, // The width of the flash button cancelImg : 'cancel.png', // The path to the cancel image for the default file queue item container wmode : 'opaque', // The wmode of the flash file scriptAccess : 'sameDomain', // Set to "always" to allow script access across domains fileDataName : 'Filedata', // The name of the file collection object in the backend upload script method : 'POST', // The method for sending variables to the backend upload script queueSizeLimit : 999, // The maximum size of the file queue simUploadLimit : 1, // The number of simultaneous uploads allowed queueID : false, // The optional ID of the queue container displayData : 'percentage', // Set to "speed" to show the upload speed in the default queue item removeCompleted : true, // Set to true if you want the queue items to be removed when a file is done uploading onInit : function() {}, // Function to run when uploadify is initialized onSelect : function() {}, // Function to run when a file is selected onSelectOnce : function() {}, // Function to run once when files are added to the queue onQueueFull : function() {}, // Function to run when the queue reaches capacity onCheck : function() {}, // Function to run when script checks for duplicate files on the server onCancel : function() {}, // Function to run when an item is cleared from the queue onClearQueue : function() {}, // Function to run when the queue is manually cleared onError : function() {}, // Function to run when an upload item returns an error onProgress : function() {}, // Function to run each time the upload progress is updated onComplete : function() {}, // Function to run when an upload is completed onAllComplete : function() {} // Function to run when all uploads are completed }, options); jQuery(this).data('settings',settings); var pagePath = location.pathname; pagePath = pagePath.split('/'); pagePath.pop(); pagePath = pagePath.join('/') + '/'; var data = {}; data.uploadifyID = settings.id; data.pagepath = pagePath; if (settings.buttonImg) data.buttonImg = escape(settings.buttonImg); if (settings.buttonText) data.buttonText = escape(settings.buttonText); if (settings.rollover) data.rollover = true; data.script = settings.script; data.folder = escape(settings.folder); if (settings.scriptData) { var scriptDataString = ''; for (var name in settings.scriptData) { scriptDataString += '&' + name + '=' + settings.scriptData[name]; } data.scriptData = escape(scriptDataString.substr(1)); } data.width = settings.width; data.height = settings.height; data.wmode = settings.wmode; data.method = settings.method; data.queueSizeLimit = settings.queueSizeLimit; data.simUploadLimit = settings.simUploadLimit; if (settings.hideButton) data.hideButton = true; if (settings.fileDesc) data.fileDesc = settings.fileDesc; if (settings.fileExt) data.fileExt = settings.fileExt; if (settings.multi) data.multi = true; if (settings.auto) data.auto = true; if (settings.sizeLimit) data.sizeLimit = settings.sizeLimit; if (settings.checkScript) data.checkScript = settings.checkScript; if (settings.fileDataName) data.fileDataName = settings.fileDataName; if (settings.queueID) data.queueID = settings.queueID; if (settings.onInit() !== false) { jQuery(this).css('display','none'); jQuery(this).after('
'); swfobject.embedSWF(settings.uploader, settings.id + 'Uploader', settings.width, settings.height, '9.0.24', settings.expressInstall, data, {'quality':'high','wmode':settings.wmode,'allowScriptAccess':settings.scriptAccess},{},function(event) { if (typeof(settings.onSWFReady) == 'function' && event.success) settings.onSWFReady(); }); if (settings.queueID == false) { jQuery("#" + jQuery(this).attr('id') + "Uploader").after('
'); } else { jQuery("#" + settings.queueID).addClass('uploadifyQueue'); } } if (typeof(settings.onOpen) == 'function') { jQuery(this).bind("uploadifyOpen", settings.onOpen); } jQuery(this).bind("uploadifySelect", {'action': settings.onSelect, 'queueID': settings.queueID}, function(event, ID, fileObj) { if (event.data.action(event, ID, fileObj) !== false) { var byteSize = Math.round(fileObj.size / 1024 * 100) * .01; var suffix = 'KB'; if (byteSize > 1000) { byteSize = Math.round(byteSize *.001 * 100) * .01; suffix = 'MB'; } var sizeParts = byteSize.toString().split('.'); if (sizeParts.length > 1) { byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2); } else { byteSize = sizeParts[0]; } if (fileObj.name.length > 20) { fileName = fileObj.name.substr(0,20) + '...'; } else { fileName = fileObj.name; } queue = '#' + jQuery(this).attr('id') + 'Queue'; if (event.data.queueID) { queue = '#' + event.data.queueID; } jQuery(queue).append('
\
\ \
\ ' + fileName + ' (' + byteSize + suffix + ')\
\
\
\
'); } }); jQuery(this).bind("uploadifySelectOnce", {'action': settings.onSelectOnce}, function(event, data) { event.data.action(event, data); if (settings.auto) { if (settings.checkScript) { jQuery(this).uploadifyUpload(null, false); } else { jQuery(this).uploadifyUpload(null, true); } } }); jQuery(this).bind("uploadifyQueueFull", {'action': settings.onQueueFull}, function(event, queueSizeLimit) { if (event.data.action(event, queueSizeLimit) !== false) { alert('The queue is full. The max size is ' + queueSizeLimit + '.'); } }); jQuery(this).bind("uploadifyCheckExist", {'action': settings.onCheck}, function(event, checkScript, fileQueueObj, folder, single) { var postData = new Object(); postData = fileQueueObj; postData.folder = (folder.substr(0,1) == '/') ? folder : pagePath + folder; if (single) { for (var ID in fileQueueObj) { var singleFileID = ID; } } jQuery.post(checkScript, postData, function(data) { for(var key in data) { if (event.data.action(event, data, key) !== false) { var replaceFile = confirm("Do you want to replace the file " + data[key] + "?"); if (!replaceFile) { document.getElementById(jQuery(event.target).attr('id') + 'Uploader').cancelFileUpload(key,true,true); } } } if (single) { document.getElementById(jQuery(event.target).attr('id') + 'Uploader').startFileUpload(singleFileID, true); } else { document.getElementById(jQuery(event.target).attr('id') + 'Uploader').startFileUpload(null, true); } }, "json"); }); jQuery(this).bind("uploadifyCancel", {'action': settings.onCancel}, function(event, ID, fileObj, data, remove, clearFast) { if (event.data.action(event, ID, fileObj, data, clearFast) !== false) { if (remove) { var fadeSpeed = (clearFast == true) ? 0 : 250; jQuery("#" + jQuery(this).attr('id') + ID).fadeOut(fadeSpeed, function() { jQuery(this).remove() }); } } }); jQuery(this).bind("uploadifyClearQueue", {'action': settings.onClearQueue}, function(event, clearFast) { var queueID = (settings.queueID) ? settings.queueID : jQuery(this).attr('id') + 'Queue'; if (clearFast) { jQuery("#" + queueID).find('.uploadifyQueueItem').remove(); } if (event.data.action(event, clearFast) !== false) { jQuery("#" + queueID).find('.uploadifyQueueItem').each(function() { var index = jQuery('.uploadifyQueueItem').index(this); jQuery(this).delay(index * 100).fadeOut(250, function() { jQuery(this).remove() }); }); } }); var errorArray = []; jQuery(this).bind("uploadifyError", {'action': settings.onError}, function(event, ID, fileObj, errorObj) { if (event.data.action(event, ID, fileObj, errorObj) !== false) { var fileArray = new Array(ID, fileObj, errorObj); errorArray.push(fileArray); jQuery("#" + jQuery(this).attr('id') + ID).find('.percentage').text(" - " + errorObj.type + " Error"); jQuery("#" + jQuery(this).attr('id') + ID).find('.uploadifyProgress').hide(); jQuery("#" + jQuery(this).attr('id') + ID).addClass('uploadifyError'); } }); if (typeof(settings.onUpload) == 'function') { jQuery(this).bind("uploadifyUpload", settings.onUpload); } jQuery(this).bind("uploadifyProgress", {'action': settings.onProgress, 'toDisplay': settings.displayData}, function(event, ID, fileObj, data) { if (event.data.action(event, ID, fileObj, data) !== false) { jQuery("#" + jQuery(this).attr('id') + ID + "ProgressBar").animate({'width': data.percentage + '%'},250,function() { if (data.percentage == 100) { jQuery(this).closest('.uploadifyProgress').fadeOut(250,function() {jQuery(this).remove()}); } }); if (event.data.toDisplay == 'percentage') displayData = ' - ' + data.percentage + '%'; if (event.data.toDisplay == 'speed') displayData = ' - ' + data.speed + 'KB/s'; if (event.data.toDisplay == null) displayData = ' '; jQuery("#" + jQuery(this).attr('id') + ID).find('.percentage').text(displayData); } }); jQuery(this).bind("uploadifyComplete", {'action': settings.onComplete}, function(event, ID, fileObj, response, data) { if (event.data.action(event, ID, fileObj, unescape(response), data) !== false) { jQuery("#" + jQuery(this).attr('id') + ID).find('.percentage').text(' - Terminé'); if (settings.removeCompleted) { jQuery("#" + jQuery(event.target).attr('id') + ID).fadeOut(250,function() {jQuery(this).remove()}); } jQuery("#" + jQuery(event.target).attr('id') + ID).addClass('completed'); } }); if (typeof(settings.onAllComplete) == 'function') { jQuery(this).bind("uploadifyAllComplete", {'action': settings.onAllComplete}, function(event, data) { if (event.data.action(event, data) !== false) { errorArray = []; } }); } }); }, uploadifySettings:function(settingName, settingValue, resetObject) { var returnValue = false; jQuery(this).each(function() { if (settingName == 'scriptData' && settingValue != null) { if (resetObject) { var scriptData = settingValue; } else { var scriptData = jQuery.extend(jQuery(this).data('settings').scriptData, settingValue); } var scriptDataString = ''; for (var name in scriptData) { scriptDataString += '&' + name + '=' + scriptData[name]; } settingValue = escape(scriptDataString.substr(1)); } returnValue = document.getElementById(jQuery(this).attr('id') + 'Uploader').updateSettings(settingName, settingValue); }); if (settingValue == null) { if (settingName == 'scriptData') { var returnSplit = unescape(returnValue).split('&'); var returnObj = new Object(); for (var i = 0; i < returnSplit.length; i++) { var iSplit = returnSplit[i].split('='); returnObj[iSplit[0]] = iSplit[1]; } returnValue = returnObj; } } return returnValue; }, uploadifyUpload:function(ID,checkComplete) { jQuery(this).each(function() { if (!checkComplete) checkComplete = false; document.getElementById(jQuery(this).attr('id') + 'Uploader').startFileUpload(ID, checkComplete); }); }, uploadifyCancel:function(ID) { jQuery(this).each(function() { document.getElementById(jQuery(this).attr('id') + 'Uploader').cancelFileUpload(ID, true, true, false); }); }, uploadifyClearQueue:function() { jQuery(this).each(function() { document.getElementById(jQuery(this).attr('id') + 'Uploader').clearFileUploadQueue(false); }); } }) })(jQuery); /* SWFObject v2.2 is released under the MIT License */ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab in BBQ, which was the main reason for the // previous release! // 1.2 - (2/16/2010) Integrated 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 method, and reworked the // 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 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 // 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 // plugin for more information. Also added the // method and added additional 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 and // 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 (function($,window){ '$:nomunge'; // Used by YUI compressor. // Some convenient shortcuts. var undefined, aps = Array.prototype.slice, decode = decodeURIComponent, // Method / object references. jq_param = $.param, jq_param_fragment, jq_deparam, jq_deparam_fragment, jq_bbq = $.bbq = $.bbq || {}, jq_bbq_pushState, jq_bbq_getState, jq_elemUrlAttr, jq_event_special = $.event.special, // Reused strings. str_hashchange = 'hashchange', 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_no_escape, // Used by jQuery.elemUrlAttr. elemUrlAttr_cache = {}; // A few commonly used bits, broken out to help reduce minified file size. function is_string( arg ) { return typeof arg === 'string'; }; // Why write the same function twice? Let's curry! Mmmm, curry.. function curry( func ) { var args = aps.call( arguments, 1 ); return function() { return func.apply( this, args.concat( aps.call( arguments ) ) ); }; }; // 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' ); }; // Get location.search (or what you'd expect location.search to be) sans any // leading #. Thanks for making this necessary, IE6! function get_querystring( url ) { return url.replace( /(?:^[^?#]*\?([^#]*).*$)?.*/, '$1' ); }; // Section: Param (to string) // // Method: jQuery.param.querystring // // Retrieve the query string from a URL or if no arguments are passed, the // current window.location. // // Usage: // // > jQuery.param.querystring( [ url ] ); // // Arguments: // // url - (String) A URL containing query string params to be parsed. If url // is not passed, the current window.location is used. // // Returns: // // (String) The parsed query string, with any leading "?" removed. // // Method: 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. // // Usage: // // > jQuery.param.querystring( url, params [, merge_mode ] ); // // Arguments: // // url - (String) A valid URL for params to be merged into. This URL may // contain a query string and/or fragment (hash). // params - (String) A params string or URL containing query string params to // be merged into url. // params - (Object) A params object to be merged into url. // 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 query string // params in url. // * 1: any query string params in url will override params in the params // argument. // * 2: params argument will completely replace any query string in url. // // Returns: // // (String) Either a params string with urlencoded data or a URL with a // urlencoded query string in the format 'a=b&c=d&e=f'. // Method: jQuery.param.fragment // // Retrieve the fragment (hash) from a URL or if no arguments are passed, the // current window.location. // // Usage: // // > jQuery.param.fragment( [ url ] ); // // Arguments: // // url - (String) A URL containing fragment (hash) params to be parsed. If // url is not passed, the current window.location is used. // // Returns: // // (String) The parsed fragment (hash) string, with any leading "#" removed. // Method: 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. // // Usage: // // > jQuery.param.fragment( url, params [, merge_mode ] ); // // Arguments: // // url - (String) A valid URL for params to be merged into. This URL may // contain a query string and/or fragment (hash). // params - (String) A params string or URL containing fragment (hash) params // to be merged into url. // params - (Object) A params object to be merged into url. // 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 fragment (hash) // params in url. // * 1: any fragment (hash) params in url will override params in the // params argument. // * 2: params argument will completely replace any query string in url. // // Returns: // // (String) Either a params string with urlencoded data or a URL with a // urlencoded fragment (hash) in the format 'a=b&c=d&e=f'. function jq_param_sub( is_fragment, get_func, url, params, merge_mode ) { var result, qs, matches, url_params, hash; if ( params !== undefined ) { // Build URL by merging params into url string. // 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 ? /^([^#]*)\#?(.*)$/ : /^([^#?]*)\??([^#]*)(#?.*)/ ); // 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, '' ); } else { // Convert relevant params in url to object. url_params = jq_deparam( matches[2] ); params = is_string( params ) // Convert passed params string into object. ? jq_deparam[ is_fragment ? str_fragment : str_querystring ]( params ) // Passed params object. : params; qs = merge_mode === 2 ? params // passed params replace url params : merge_mode === 1 ? $.extend( {}, params, url_params ) // url params override passed params : $.extend( {}, url_params, params ); // passed params override url params // Convert params object to a string. qs = jq_param( qs ); // Unescape characters specified via $.param.noEscape. Since only hash- // history users have requested this feature, it's only enabled for // fragment-related params strings. if ( is_fragment ) { qs = qs.replace( re_no_escape, decode ); } } // 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; } 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 ] ); } return result; }; jq_param[ str_querystring ] = curry( jq_param_sub, 0, get_querystring ); jq_param[ str_fragment ] = jq_param_fragment = curry( jq_param_sub, 1, get_fragment ); // Method: jQuery.param.fragment.noEscape // // Specify characters that will be left unescaped when fragments are created // or merged using , or when the fragment is modified // using . 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. jq_param_fragment.noEscape = function( chars ) { chars = chars || ''; var arr = $.map( chars.split(''), encodeURIComponent ); re_no_escape = new RegExp( arr.join('|'), 'g' ); }; // A sensible default. These are the characters people seem to complain about // "uglifying up the URL" the most. jq_param_fragment.noEscape( ',/' ); // Section: Deparam (from string) // // Method: jQuery.deparam // // 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. // // Usage: // // > jQuery.deparam( params [, coerce ] ); // // Arguments: // // params - (String) A params string to be parsed. // coerce - (Boolean) If true, coerces any numbers or true, false, null, and // undefined to their actual value. Defaults to false if omitted. // // Returns: // // (Object) An object representing the deserialized params string. $.deparam = jq_deparam = function( params, coerce ) { var obj = {}, coerce_types = { 'true': !0, 'false': !1, 'null': null }; // Iterate over all name=value pairs. $.each( params.replace( /\+/g, ' ' ).split( '&' ), function(j,v){ var param = v.split( '=' ), key = decode( param[0] ), val, cur = obj, i = 0, // If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it // into its component parts. keys = key.split( '][' ), keys_last = keys.length - 1; // If the first keys part contains [ and the last ends with ], then [] // are correctly balanced. if ( /\[/.test( keys[0] ) && /\]$/.test( keys[ keys_last ] ) ) { // Remove the trailing ] from the last keys part. keys[ keys_last ] = keys[ keys_last ].replace( /\]$/, '' ); // Split first keys part into two parts on the [ and add them back onto // the beginning of the keys array. keys = keys.shift().split('[').concat( keys ); keys_last = keys.length - 1; } else { // Basic 'foo' style key. keys_last = 0; } // Are we dealing with a name=value pair, or just a name? if ( param.length === 2 ) { val = decode( param[1] ); // Coerce values. if ( coerce ) { val = val && !isNaN(val) ? +val // number : val === 'undefined' ? undefined // undefined : coerce_types[val] !== undefined ? coerce_types[val] // true, false, null : val; // string } if ( keys_last ) { // Complex key, build deep object structure based on a few rules: // * The 'cur' pointer starts at the object top-level. // * [] = array push (n is set to array length), [n] = array if n is // numeric, otherwise object. // * If at the last keys part, set the value. // * For each keys part, if the current level is undefined create an // object or array based on the type of the next keys part. // * Move the 'cur' pointer to the next level. // * Rinse & repeat. for ( ; i <= keys_last; i++ ) { key = keys[i] === '' ? cur.length : keys[i]; cur = cur[key] = i < keys_last ? cur[key] || ( keys[i+1] && isNaN( keys[i+1] ) ? {} : [] ) : val; } } else { // Simple key, even simpler rules, since only scalars and shallow // arrays are allowed. if ( $.isArray( obj[key] ) ) { // val is already an array, so push on the next value. obj[key].push( val ); } else if ( obj[key] !== undefined ) { // val isn't an array, but since a second value has been specified, // convert val into an array. obj[key] = [ obj[key], val ]; } else { // val is a scalar. obj[key] = val; } } } else if ( key ) { // No value was defined, so set something meaningful. obj[key] = coerce ? undefined : ''; } }); return obj; }; // Method: jQuery.deparam.querystring // // 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. // // Usage: // // > jQuery.deparam.querystring( [ url ] [, coerce ] ); // // Arguments: // // url - (String) An optional params string or URL containing query string // params to be parsed. If url is omitted, the current window.location // is used. // coerce - (Boolean) If true, coerces any numbers or true, false, null, and // undefined to their actual value. Defaults to false if omitted. // // Returns: // // (Object) An object representing the deserialized params string. // Method: jQuery.deparam.fragment // // 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. // // Usage: // // > jQuery.deparam.fragment( [ url ] [, coerce ] ); // // Arguments: // // url - (String) An optional params string or URL containing fragment (hash) // params to be parsed. If url is omitted, the current window.location // is used. // coerce - (Boolean) If true, coerces any numbers or true, false, null, and // undefined to their actual value. Defaults to false if omitted. // // Returns: // // (Object) An object representing the deserialized params string. function jq_deparam_sub( is_fragment, url_or_params, coerce ) { if ( url_or_params === undefined || typeof url_or_params === 'boolean' ) { // url_or_params not specified. coerce = url_or_params; 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; } return jq_deparam( url_or_params, coerce ); }; jq_deparam[ str_querystring ] = curry( jq_deparam_sub, 0 ); jq_deparam[ str_fragment ] = jq_deparam_fragment = curry( jq_deparam_sub, 1 ); // Section: Element manipulation // // Method: 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 and 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: // // a - href // base - href // iframe - src // img - src // input - src // form - action // link - href // script - src // // 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. // Only define function and set defaults if function doesn't already exist, as // the urlInternal plugin will provide this method as well. $[ str_elemUrlAttr ] || ($[ str_elemUrlAttr ] = function( obj ) { return $.extend( elemUrlAttr_cache, obj ); })({ a: str_href, base: str_href, iframe: str_src, img: str_src, input: str_src, form: 'action', link: str_href, script: str_src }); jq_elemUrlAttr = $[ str_elemUrlAttr ]; // Method: 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 // , 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 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. // Method: 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 // , 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 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. function jq_fn_sub( mode, force_attr, params, merge_mode ) { if ( !is_string( params ) && typeof params !== 'object' ) { // force_attr not specified. merge_mode = params; params = force_attr; force_attr = undefined; } return this.each(function(){ var that = $(this), // Get attribute specified, or default specified via $.elemUrlAttr. attr = force_attr || jq_elemUrlAttr()[ ( this.nodeName || '' ).toLowerCase() ] || '', // Get URL value. url = attr && that.attr( attr ) || ''; // Update attribute with new URL. that.attr( attr, jq_param[ mode ]( url, params, merge_mode ) ); }); }; $.fn[ str_querystring ] = curry( jq_fn_sub, str_querystring ); $.fn[ str_fragment ] = curry( jq_fn_sub, str_fragment ); // Section: History, hashchange event // // Method: jQuery.bbq.pushState // // Adds a 'state' into the browser history at the current position, setting // location.hash and triggering any bound 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. jq_bbq.pushState = jq_bbq_pushState = function( params, merge_mode ) { if ( is_string( params ) && /^#/.test( params ) && merge_mode === undefined ) { // Params string begins with # and merge_mode not specified, so completely // overwrite window.location.hash. merge_mode = 2; } var has_args = params !== undefined, // Merge params into window.location using $.param.fragment. url = jq_param_fragment( window[ str_location ][ str_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 ) ? '' : '#' ); }; // Method: 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. jq_bbq.getState = jq_bbq_getState = function( key, coerce ) { return key === undefined || typeof key === 'boolean' ? jq_deparam_fragment( key ) // 'key' really means 'coerce' here : jq_deparam_fragment( coerce )[ key ]; }; // Method: 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 // 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. jq_bbq.removeState = function( arr ) { var state = {}; // If one or more arguments is passed.. if ( arr !== undefined ) { // Get the current state. state = jq_bbq_getState(); // For each passed key, delete the corresponding property from the current // state. $.each( $.isArray( arr ) ? arr : arguments, function(i,v){ delete state[ v ]; }); } // Set the state, completely overriding any existing state. jq_bbq_pushState( state, 2 ); }; // 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 // and the event.getState method is equivalent to the // 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 and 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 for more detailed information. jq_event_special[ str_hashchange ] = $.extend( jq_event_special[ str_hashchange ], { // Augmenting the event object with the .fragment property and .getState // method requires jQuery 1.4 or newer. Note: with 1.3.2, everything will // work, but the event won't be augmented) add: function( handleObj ) { var old_handler; function new_handler(e) { // e.fragment is set to the value of location.hash (with any leading # // removed) at the time the event is triggered. var hash = e[ str_fragment ] = jq_param_fragment(); // e.getState() works just like $.bbq.getState(), but uses the // e.fragment property stored on the event object. e.getState = function( key, coerce ) { return key === undefined || typeof key === 'boolean' ? jq_deparam( hash, key ) // 'key' really means 'coerce' here : jq_deparam( hash, coerce )[ key ]; }; old_handler.apply( this, arguments ); }; // This may seem a little complicated, but it normalizes the special event // .add method between jQuery 1.4/1.4.1 and 1.4.2+ if ( $.isFunction( handleObj ) ) { // 1.4, 1.4.1 old_handler = handleObj; return new_handler; } else { // 1.4.2+ old_handler = handleObj.handler; handleObj.handler = new_handler; } } }); })(jQuery,this); /*! * jQuery hashchange event - v1.2 - 2/11/2010 * http://benalman.com/projects/jquery-hashchange-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ // Script: jQuery hashchange event // // *Version: 1.2, Last updated: 2/11/2010* // // Project Home - http://benalman.com/projects/jquery-hashchange-plugin/ // GitHub - http://github.com/cowboy/jquery-hashchange/ // Source - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js // (Minified) - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (1.1kb) // // About: License // // Copyright (c) 2010 "Cowboy" Ben Alman, // Dual licensed under the MIT and GPL licenses. // http://benalman.com/about/license/ // // About: Examples // // This working example, complete with fully commented code, illustrate one way // in which this plugin can be used. // // hashchange event - http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/ // // About: 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 Versions - 1.3.2, 1.4.1, 1.4.2 // Browsers Tested - Internet Explorer 6-8, Firefox 2-3.7, Safari 3-4, Chrome, Opera 9.6-10.1. // Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/ // // About: 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 Button - http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/ // Firefox: Remote XMLHttpRequest - http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/ // WebKit: Back Button in an Iframe - http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/ // Safari: Back Button from a different domain - http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/ // // About: Release History // // 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. (function($,window,undefined){ '$:nomunge'; // Used by YUI compressor. // Method / object references. var fake_onhashchange, jq_event_special = $.event.special, // Reused strings. str_location = 'location', str_hashchange = 'hashchange', str_href = 'href', // IE6/7 specifically need some special love when it comes to back-button // support, so let's do a little browser sniffing.. browser = $.browser, mode = document.documentMode, is_old_ie = browser.msie && ( mode === undefined || mode < 8 ), // Does the browser support window.onhashchange? Test for IE version, since // IE8 incorrectly reports this when in "IE7" or "IE8 Compatibility View"! supports_onhashchange = 'on' + str_hashchange in window && !is_old_ie; // 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 ) { url = url || window[ str_location ][ str_href ]; return url.replace( /^[^#]*#?(.*)$/, '$1' ); }; // Property: jQuery.hashchangeDelay // // The numeric interval (in milliseconds) at which the // polling loop executes. Defaults to 100. $[ str_hashchange + 'Delay' ] = 100; // Event: hashchange event // // Fired when location.hash changes. In browsers that support it, the native // window.onhashchange event is used (IE8, FF3.6), otherwise a polling loop is // initialized, running every milliseconds to see if // the hash has changed. In IE 6 and 7, a hidden Iframe is created to allow // the back button and hash-based history to work. // // Usage: // // > $(window).bind( 'hashchange', function(e) { // > var hash = location.hash; // > ... // > }); // // Additional Notes: // // * The polling loop and Iframe are not created until at least one callback // is actually bound to 'hashchange'. // * If you need the bound callback(s) to execute immediately, in cases where // the page 'state' exists on page load (via bookmark or page refresh, for // example) use $(window).trigger( 'hashchange' ); // * The event can be bound before DOM ready, but since it won't be usable // before then in IE6/7 (due to the necessary Iframe), recommended usage is // to bind it inside a $(document).ready() callback. jq_event_special[ str_hashchange ] = $.extend( jq_event_special[ str_hashchange ], { // Called only when the first 'hashchange' event is bound to window. setup: function() { // If window.onhashchange is supported natively, there's nothing to do.. if ( supports_onhashchange ) { return false; } // Otherwise, we need to create our own. And we don't want to call this // until the user binds to the event, just in case they never do, since it // will create a polling loop and possibly even a hidden Iframe. $( fake_onhashchange.start ); }, // Called only when the last 'hashchange' event is unbound from window. teardown: function() { // If window.onhashchange is supported natively, there's nothing to do.. if ( supports_onhashchange ) { return false; } // Otherwise, we need to stop ours (if possible). $( fake_onhashchange.stop ); } }); // fake_onhashchange does all the work of triggering the window.onhashchange // event for browsers that don't natively support it, including creating a // polling loop to watch for hash changes and in IE 6/7 creating a hidden // Iframe to enable back and forward. fake_onhashchange = (function(){ var self = {}, timeout_id, iframe, set_history, get_history; // Initialize. In IE 6/7, creates a hidden Iframe for history handling. function init(){ // Most browsers don't need special methods here.. set_history = get_history = function(val){ return val; }; // But IE6/7 do! if ( is_old_ie ) { // Create hidden Iframe after the end of the body to prevent initial // page load from scrolling unnecessarily. iframe = $('