Standardize on using double-quotes for string literals.

This commit is contained in:
jeresig 2009-12-21 20:13:16 -05:00
parent 61e37d4149
commit 3776cbe314
8 changed files with 31 additions and 30 deletions

View File

@ -604,7 +604,7 @@ jQuery.extend({
function add( key, value ) { function add( key, value ) {
// If value is a function, invoke it and return its value // If value is a function, invoke it and return its value
value = jQuery.isFunction(value) ? value() : value; value = jQuery.isFunction(value) ? value() : value;
s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
} }
// If an array was passed in, assume that it is an array of form elements. // If an array was passed in, assume that it is an array of form elements.

View File

@ -137,7 +137,7 @@ jQuery.fn.extend({
// Typecast once if the value is a number // Typecast once if the value is a number
if ( typeof value === "number" ) { if ( typeof value === "number" ) {
value += ''; value += "";
} }
var val = value; var val = value;
@ -149,7 +149,7 @@ jQuery.fn.extend({
// Typecast each time if the value is a Function and the appended // Typecast each time if the value is a Function and the appended
// value is therefore different each time. // value is therefore different each time.
if ( typeof val === "number" ) { if ( typeof val === "number" ) {
val += ''; val += "";
} }
} }

View File

@ -617,7 +617,7 @@ jQuery.extend({
// Use of jQuery.browser is frowned upon. // Use of jQuery.browser is frowned upon.
// More details: http://docs.jquery.com/Utilities/jQuery.browser // More details: http://docs.jquery.com/Utilities/jQuery.browser
browser: { browser: {
version: (/.*?(?:firefox|safari|opera|msie)[\/ ]([\d.]+)/.exec(userAgent) || [0,'0'])[1], version: (/.*?(?:firefox|safari|opera|msie)[\/ ]([\d.]+)/.exec(userAgent) || [0,"0"])[1],
safari: /safari/.test( userAgent ), safari: /safari/.test( userAgent ),
opera: /opera/.test( userAgent ), opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),

View File

@ -56,13 +56,13 @@ jQuery.extend({
style.zoom = 1; style.zoom = 1;
// Set the alpha filter to set the opacity // Set the alpha filter to set the opacity
var opacity = parseInt( value, 10 ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"; var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
var filter = style.filter || jQuery.curCSS( elem, 'filter' ) || ""; var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
} }
return style.filter && style.filter.indexOf("opacity=") >= 0 ? return style.filter && style.filter.indexOf("opacity=") >= 0 ?
(parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '': (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
""; "";
} }

View File

@ -230,6 +230,7 @@ jQuery.event = {
if ( !elem ) { if ( !elem ) {
// Don't bubble custom events when global (to avoid too much overhead) // Don't bubble custom events when global (to avoid too much overhead)
event.stopPropagation(); event.stopPropagation();
// Only trigger if we've ever bound an event for it // Only trigger if we've ever bound an event for it
if ( this.global[ type ] ) { if ( this.global[ type ] ) {
jQuery.each( jQuery.cache, function() { jQuery.each( jQuery.cache, function() {
@ -824,8 +825,8 @@ jQuery.fn.extend({
return this.click( jQuery.event.proxy( fn, function( event ) { return this.click( jQuery.event.proxy( fn, function( event ) {
// Figure out which function to execute // Figure out which function to execute
var lastToggle = ( jQuery.data( this, 'lastToggle' + fn.guid ) || 0 ) % i; var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
jQuery.data( this, 'lastToggle' + fn.guid, lastToggle + 1 ); jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
// Make sure that clicks stop // Make sure that clicks stop
event.preventDefault(); event.preventDefault();

View File

@ -380,7 +380,7 @@ jQuery.extend({
jQuery.each(elems, function( i, elem ) { jQuery.each(elems, function( i, elem ) {
if ( typeof elem === "number" ) { if ( typeof elem === "number" ) {
elem += ''; elem += "";
} }
if ( !elem ) { if ( !elem ) {

View File

@ -95,10 +95,10 @@ if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.offset = { jQuery.offset = {
initialize: function() { initialize: function() {
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
container.innerHTML = html; container.innerHTML = html;
body.insertBefore( container, body.firstChild ); body.insertBefore( container, body.firstChild );
@ -109,12 +109,12 @@ jQuery.offset = {
this.doesNotAddBorder = (checkDiv.offsetTop !== 5); this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
this.doesAddBorderForTableAndCells = (td.offsetTop === 5); this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
// safari subtracts parent border width here which is 5px // safari subtracts parent border width here which is 5px
this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
checkDiv.style.position = checkDiv.style.top = ''; checkDiv.style.position = checkDiv.style.top = "";
innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
@ -130,8 +130,8 @@ jQuery.offset = {
jQuery.offset.initialize(); jQuery.offset.initialize();
if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
} }
return { top: top, left: left }; return { top: top, left: left };
@ -139,19 +139,19 @@ jQuery.offset = {
setOffset: function( elem, options ) { setOffset: function( elem, options ) {
// set position first, in-case top/left are set even on static elem // set position first, in-case top/left are set even on static elem
if ( /static/.test( jQuery.curCSS( elem, 'position' ) ) ) { if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
elem.style.position = 'relative'; elem.style.position = "relative";
} }
var curElem = jQuery( elem ), var curElem = jQuery( elem ),
curOffset = curElem.offset(), curOffset = curElem.offset(),
curTop = parseInt( jQuery.curCSS( elem, 'top', true ), 10 ) || 0, curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
curLeft = parseInt( jQuery.curCSS( elem, 'left', true ), 10) || 0, curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10) || 0,
props = { props = {
top: (options.top - curOffset.top) + curTop, top: (options.top - curOffset.top) + curTop,
left: (options.left - curOffset.left) + curLeft left: (options.left - curOffset.left) + curLeft
}; };
if ( 'using' in options ) { if ( "using" in options ) {
options.using.call( elem, props ); options.using.call( elem, props );
} else { } else {
curElem.css( props ); curElem.css( props );
@ -178,12 +178,12 @@ jQuery.fn.extend({
// Subtract element margins // Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft // note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0 // are the same in Safari causing offset.left to incorrectly be 0
offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
// Add offsetParent borders // Add offsetParent borders
parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
// Subtract the two offsets // Subtract the two offsets
return { return {
@ -195,7 +195,7 @@ jQuery.fn.extend({
offsetParent: function() { offsetParent: function() {
return this.map(function() { return this.map(function() {
var offsetParent = this.offsetParent || document.body; var offsetParent = this.offsetParent || document.body;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) { while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
offsetParent = offsetParent.offsetParent; offsetParent = offsetParent.offsetParent;
} }
return offsetParent; return offsetParent;
@ -234,7 +234,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
win = getWindow( elem ); win = getWindow( elem );
// Return the scroll offset // Return the scroll offset
return win ? ('pageXOffset' in win) ? win[ i ? 'pageYOffset' : 'pageXOffset' ] : return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
jQuery.support.boxModel && win.document.documentElement[ method ] || jQuery.support.boxModel && win.document.documentElement[ method ] ||
win.document.body[ method ] : win.document.body[ method ] :
elem[ method ]; elem[ method ];

View File

@ -8,7 +8,7 @@
id = "script" + now(); id = "script" + now();
div.style.display = "none"; div.style.display = "none";
div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.55;">a</a><select><option>text</option></select>'; div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><select><option>text</option></select>";
var all = div.getElementsByTagName("*"), var all = div.getElementsByTagName("*"),
a = div.getElementsByTagName("a")[0]; a = div.getElementsByTagName("a")[0];