From 3776cbe314ac6f5081e998c3d5ac84d3fbc51872 Mon Sep 17 00:00:00 2001 From: jeresig Date: Mon, 21 Dec 2009 20:13:16 -0500 Subject: [PATCH] Standardize on using double-quotes for string literals. --- src/ajax.js | 2 +- src/attributes.js | 4 ++-- src/core.js | 2 +- src/css.js | 6 +++--- src/event.js | 5 +++-- src/manipulation.js | 2 +- src/offset.js | 38 +++++++++++++++++++------------------- src/support.js | 2 +- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index 0d1dd84..bd87252 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -604,7 +604,7 @@ jQuery.extend({ function add( key, value ) { // If value is a function, invoke it and return its 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. diff --git a/src/attributes.js b/src/attributes.js index 4f5692f..787c6bb 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -137,7 +137,7 @@ jQuery.fn.extend({ // Typecast once if the value is a number if ( typeof value === "number" ) { - value += ''; + value += ""; } var val = value; @@ -149,7 +149,7 @@ jQuery.fn.extend({ // Typecast each time if the value is a Function and the appended // value is therefore different each time. if ( typeof val === "number" ) { - val += ''; + val += ""; } } diff --git a/src/core.js b/src/core.js index faba32a..944e8a9 100644 --- a/src/core.js +++ b/src/core.js @@ -617,7 +617,7 @@ jQuery.extend({ // Use of jQuery.browser is frowned upon. // More details: http://docs.jquery.com/Utilities/jQuery.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 ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), diff --git a/src/css.js b/src/css.js index e52e453..5d31757 100644 --- a/src/css.js +++ b/src/css.js @@ -56,13 +56,13 @@ jQuery.extend({ style.zoom = 1; // Set the alpha filter to set the opacity - var opacity = parseInt( value, 10 ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"; - var filter = style.filter || jQuery.curCSS( elem, 'filter' ) || ""; + var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"; + var filter = style.filter || jQuery.curCSS( elem, "filter" ) || ""; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity; } return style.filter && style.filter.indexOf("opacity=") >= 0 ? - (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '': + (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "": ""; } diff --git a/src/event.js b/src/event.js index 3697e4e..6f8989a 100644 --- a/src/event.js +++ b/src/event.js @@ -230,6 +230,7 @@ jQuery.event = { if ( !elem ) { // Don't bubble custom events when global (to avoid too much overhead) event.stopPropagation(); + // Only trigger if we've ever bound an event for it if ( this.global[ type ] ) { jQuery.each( jQuery.cache, function() { @@ -824,8 +825,8 @@ jQuery.fn.extend({ return this.click( jQuery.event.proxy( fn, function( event ) { // Figure out which function to execute - var lastToggle = ( jQuery.data( this, 'lastToggle' + fn.guid ) || 0 ) % i; - jQuery.data( this, 'lastToggle' + fn.guid, lastToggle + 1 ); + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); // Make sure that clicks stop event.preventDefault(); diff --git a/src/manipulation.js b/src/manipulation.js index 7500730..5109cf0 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -380,7 +380,7 @@ jQuery.extend({ jQuery.each(elems, function( i, elem ) { if ( typeof elem === "number" ) { - elem += ''; + elem += ""; } if ( !elem ) { diff --git a/src/offset.js b/src/offset.js index 6925839..7ae9cb9 100644 --- a/src/offset.js +++ b/src/offset.js @@ -95,10 +95,10 @@ if ( "getBoundingClientRect" in document.documentElement ) { jQuery.offset = { initialize: function() { - var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, - html = '
'; + var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0, + html = "
"; - 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; body.insertBefore( container, body.firstChild ); @@ -109,12 +109,12 @@ jQuery.offset = { this.doesNotAddBorder = (checkDiv.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 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.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); @@ -130,8 +130,8 @@ jQuery.offset = { jQuery.offset.initialize(); if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { - top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; - left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; + top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0; + left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0; } return { top: top, left: left }; @@ -139,19 +139,19 @@ jQuery.offset = { setOffset: function( elem, options ) { // set position first, in-case top/left are set even on static elem - if ( /static/.test( jQuery.curCSS( elem, 'position' ) ) ) { - elem.style.position = 'relative'; + if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) { + elem.style.position = "relative"; } var curElem = jQuery( elem ), curOffset = curElem.offset(), - curTop = parseInt( jQuery.curCSS( elem, 'top', true ), 10 ) || 0, - curLeft = parseInt( jQuery.curCSS( elem, 'left', true ), 10) || 0, + curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0, + curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10) || 0, props = { top: (options.top - curOffset.top) + curTop, left: (options.left - curOffset.left) + curLeft }; - if ( 'using' in options ) { + if ( "using" in options ) { options.using.call( elem, props ); } else { curElem.css( props ); @@ -178,12 +178,12 @@ jQuery.fn.extend({ // Subtract element margins // note: when an element has margin: auto the offsetLeft and marginLeft // are the same in Safari causing offset.left to incorrectly be 0 - offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; - offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; + offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0; + offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0; // Add offsetParent borders - parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; - parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; + parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0; + parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0; // Subtract the two offsets return { @@ -195,7 +195,7 @@ jQuery.fn.extend({ offsetParent: function() { return this.map(function() { 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; } return offsetParent; @@ -234,7 +234,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) { win = getWindow( elem ); // 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 ] || win.document.body[ method ] : elem[ method ]; diff --git a/src/support.js b/src/support.js index 097866c..71cf9db 100644 --- a/src/support.js +++ b/src/support.js @@ -8,7 +8,7 @@ id = "script" + now(); div.style.display = "none"; - div.innerHTML = '
a'; + div.innerHTML = "
a"; var all = div.getElementsByTagName("*"), a = div.getElementsByTagName("a")[0]; -- 1.7.10.4