From dd019fed64d41909772eed3ee2ae4869944c9256 Mon Sep 17 00:00:00 2001
From: Markus Amalthea Magnuson
Date: Sun, 3 Mar 2013 15:10:15 +0100
Subject: [PATCH 1/3] Code style adherence, mostly whitespace changes.
* Spaces to tabs.
* Some removal of empty lines where code is a bit to sparse, and
insertion where a bit too dense.
* Reflow a couple of code comments.
* Remove any trailing whitespace.
---
.../beware-anonymous-functions.md | 45 +--
page/code-organization/concepts.md | 302 ++++++++----------
page/code-organization/deferreds.md | 36 +--
page/code-organization/deferreds/examples.md | 275 ++++++++--------
.../deferreds/jquery-deferreds.md | 48 +--
.../code-organization/dont-repeat-yourself.md | 28 +-
.../feature-browser-detection.md | 26 +-
7 files changed, 355 insertions(+), 405 deletions(-)
diff --git a/page/code-organization/beware-anonymous-functions.md b/page/code-organization/beware-anonymous-functions.md
index 8ce056b9..2532a69f 100644
--- a/page/code-organization/beware-anonymous-functions.md
+++ b/page/code-organization/beware-anonymous-functions.md
@@ -13,44 +13,33 @@ your handlers and callbacks.
// BAD
$( document ).ready(function() {
- $("#magic").click(function( event ) {
+ $( "#magic" ).click(function( event ) {
+ $( "#yayeffects" ).slideUp(function() {
+ // ...
+ });
+ });
- $("#yayeffects").slideUp(function() {
-
- // ...
-
- });
-
- });
-
- $("#happiness").load( url + " #unicorns", function() {
-
- // ...
-
- });
+ $( "#happiness" ).load( url + " #unicorns", function() {
+ // ...
+ });
});
// BETTER
var PI = {
- onReady : function() {
-
- $("#magic").click( PI.candyMtn );
-
- $("#happiness").load( PI.url + " #unicorns", PI.unicornCb );
-
- },
-
- candyMtn : function( event ) {
-
- $("#yayeffects").slideUp( PI.slideCb );
+ onReady: function() {
+ $( "#magic" ).click( PI.candyMtn );
+ $( "#happiness" ).load( PI.url + " #unicorns", PI.unicornCb );
+ },
- },
+ candyMtn: function( event ) {
+ $( "#yayeffects" ).slideUp( PI.slideCb );
+ },
- slideCb : function() { ... },
+ slideCb: function() { ... },
- unicornCb : function() { ... }
+ unicornCb: function() { ... }
};
diff --git a/page/code-organization/concepts.md b/page/code-organization/concepts.md
index 612a479b..fb61e41a 100644
--- a/page/code-organization/concepts.md
+++ b/page/code-organization/concepts.md
@@ -51,16 +51,21 @@ options, and easing the path to reuse and refactoring.
```
// An object literal
var myFeature = {
- myProperty: "hello",
- myMethod: function() {
- console.log( myFeature.myProperty );
- },
- init: function( settings ) {
- myFeature.settings = settings;
- },
- readSettings : function() {
- console.log( myFeature.settings );
- }
+
+ myProperty: "hello",
+
+ myMethod: function() {
+ console.log( myFeature.myProperty );
+ },
+
+ init: function( settings ) {
+ myFeature.settings = settings;
+ },
+
+ readSettings: function() {
+ console.log( myFeature.settings );
+ }
+
};
myFeature.myProperty === "hello"; // true
@@ -68,7 +73,7 @@ myFeature.myProperty === "hello"; // true
myFeature.myMethod(); // "hello"
myFeature.init({
- foo: "bar"
+ foo: "bar"
});
myFeature.readSettings(); // { foo: "bar" }
@@ -84,28 +89,18 @@ How would we apply this pattern to jQuery code? Let's say that we had this code
written in the traditional jQuery style:
```
-// clicking on a list item loads some content
-// using the list item's ID and hides content
-// in sibling list items
+// clicking on a list item loads some content using the
+// list item's ID, and hides content in sibling list items
$( document ).ready(function() {
- $("#myFeature li").append("").click(function() {
-
- var $this = $( this );
-
- var $div = $this.find("div");
-
- $div.load( "foo.php?item=" + $this.attr("id"), function() {
-
- $div.show();
-
- $this.siblings().find("div").hide();
-
- }
-
- );
-
- });
+ $( "#myFeature li" ).append( "" ).click(function() {
+ var $this = $( this );
+ var $div = $this.find( "div" );
+ $div.load( "foo.php?item=" + $this.attr( "id" ), function() {
+ $div.show();
+ $this.siblings().find( "div" ).hide();
+ });
+ });
});
```
@@ -121,76 +116,53 @@ functionality later.
// Using an object literal for a jQuery feature
var myFeature = {
- init : function( settings ) {
-
- myFeature.config = {
- $items : $("#myFeature li"),
- $container : $(""),
- urlBase : "/foo.php?item="
- };
-
- // allow overriding the default config
- $.extend( myFeature.config, settings );
-
- myFeature.setup();
-
- },
-
- setup : function() {
-
- myFeature.config.$items.each( myFeature.createContainer ).click( myFeature.showItem );
-
- },
-
- createContainer : function() {
-
- var $i = $( this );
-
- var $c = myFeature.config.$container.clone().appendTo( $i );
-
- $i.data( "container", $c );
-
- },
-
- buildUrl : function() {
-
- return myFeature.config.urlBase + myFeature.$currentItem.attr("id");
-
- },
-
- showItem : function() {
-
- var myFeature.$currentItem = $( this );
-
- myFeature.getContent( myFeature.showContent );
-
- },
-
- getContent : function( callback ) {
-
- var url = myFeature.buildUrl();
-
- myFeature.$currentItem.data("container").load( url, callback );
-
- },
-
- showContent : function() {
-
- myFeature.$currentItem.data("container").show();
-
- myFeature.hideContent();
-
- },
-
- hideContent : function() {
-
- myFeature.$currentItem.siblings().each(function() {
-
- $( this ).data("container").hide();
-
- });
-
- }
+ init: function( settings ) {
+ myFeature.config = {
+ $items: $( "#myFeature li" ),
+ $container: $( "" ),
+ urlBase: "/foo.php?item="
+ };
+
+ // allow overriding the default config
+ $.extend( myFeature.config, settings );
+
+ myFeature.setup();
+ },
+
+ setup: function() {
+ myFeature.config.$items.each( myFeature.createContainer ).click( myFeature.showItem );
+ },
+
+ createContainer: function() {
+ var $i = $( this );
+ var $c = myFeature.config.$container.clone().appendTo( $i );
+ $i.data( "container", $c );
+ },
+
+ buildUrl: function() {
+ return myFeature.config.urlBase + myFeature.$currentItem.attr( "id" );
+ },
+
+ showItem: function() {
+ var myFeature.$currentItem = $( this );
+ myFeature.getContent( myFeature.showContent );
+ },
+
+ getContent: function( callback ) {
+ var url = myFeature.buildUrl();
+ myFeature.$currentItem.data( "container" ).load( url, callback );
+ },
+
+ showContent: function() {
+ myFeature.$currentItem.data( "container" ).show();
+ myFeature.hideContent();
+ },
+
+ hideContent: function() {
+ myFeature.$currentItem.siblings().each(function() {
+ $( this ).data( "container" ).hide();
+ });
+ }
};
@@ -227,31 +199,30 @@ desired.
// The module pattern
var feature = (function() {
- // private variables and functions
- var privateThing = "secret";
- var publicThing = "not secret";
- var changePrivateThing = function() {
- privateThing = "super secret";
- };
+ // private variables and functions
+ var privateThing = "secret";
+ var publicThing = "not secret";
- var sayPrivateThing = function() {
- console.log( privateThing );
- changePrivateThing();
- };
+ var changePrivateThing = function() {
+ privateThing = "super secret";
+ };
- // public API
- return {
- publicThing: publicThing,
- sayPrivateThing: sayPrivateThing
- };
+ var sayPrivateThing = function() {
+ console.log( privateThing );
+ changePrivateThing();
+ };
+
+ // public API
+ return {
+ publicThing: publicThing,
+ sayPrivateThing: sayPrivateThing
+ };
})();
feature.publicThing; // "not secret"
-
-// logs "secret" and changes the value
-// of privateThing
+// logs "secret" and changes the value of privateThing
feature.sayPrivateThing();
```
@@ -276,47 +247,56 @@ of the module, `showItemByIndex()`.
// Using the module pattern for a jQuery feature
$( document ).ready(function() {
- var feature = (function() {
-
- var $items = $("#myFeature li");
- var $container = $("");
- var $currentItem = null;
- var urlBase = "/foo.php?item=";
- var createContainer = function() {
- var $i = $( this );
- var $c = $container.clone().appendTo( $i );
- $i.data( "container", $c );
- },
- buildUrl = function() {
- return urlBase + $currentItem.attr("id");
- },
- showItem = function() {
- $currentItem = $( this );
- getContent( showContent );
- },
- showItemByIndex = function( idx ) {
- $.proxy( showItem, $items.get( idx ) );
- },
- getContent = function( callback ) {
- $currentItem.data("container").load( buildUrl(), callback );
- },
- showContent = function() {
- $currentItem.data("container").show();
- hideContent();
- },
- hideContent = function() {
- $currentItem.siblings().each(function() {
- $( this ).data("container").hide();
- });
- };
- $items.each( createContainer ).click( showItem );
-
- return {
- showItemByIndex: showItemByIndex
- };
-
- })();
-
- feature.showItemByIndex( 0 );
+ var feature = (function() {
+
+ var $items = $( "#myFeature li" );
+ var $container = $( "" );
+ var $currentItem = null;
+ var urlBase = "/foo.php?item=";
+
+ var createContainer = function() {
+ var $i = $( this );
+ var $c = $container.clone().appendTo( $i );
+ $i.data( "container", $c );
+ },
+
+ buildUrl = function() {
+ return urlBase + $currentItem.attr( "id" );
+ },
+
+ showItem = function() {
+ $currentItem = $( this );
+ getContent( showContent );
+ },
+
+ showItemByIndex = function( idx ) {
+ $.proxy( showItem, $items.get( idx ) );
+ },
+
+ getContent = function( callback ) {
+ $currentItem.data( "container" ).load( buildUrl(), callback );
+ },
+
+ showContent = function() {
+ $currentItem.data( "container" ).show();
+ hideContent();
+ },
+
+ hideContent = function() {
+ $currentItem.siblings().each(function() {
+ $( this ).data( "container" ).hide();
+ });
+ };
+
+ $items.each( createContainer ).click( showItem );
+
+ return {
+ showItemByIndex: showItemByIndex
+ };
+
+ })();
+
+ feature.showItemByIndex( 0 );
+
});
```
diff --git a/page/code-organization/deferreds.md b/page/code-organization/deferreds.md
index 5e10b597..bed7d934 100644
--- a/page/code-organization/deferreds.md
+++ b/page/code-organization/deferreds.md
@@ -42,11 +42,11 @@ may look like:
promise = callToAPI( arg1, arg2, ...);
promise.then(function( futureValue ) {
- /* handle futureValue */
+ /* handle futureValue */
});
promise.then(function( futureValue ) {
- /* do something else */
+ /* do something else */
});
```
@@ -62,11 +62,11 @@ promise was resolved, another for when the promise was rejected. If we
get back to pseudo-code, we may do things like:
```
-promise.then( function( futureValue ) {
- /* we got a value */
-} , function() {
- /* something went wrong */
-} );
+promise.then(function( futureValue ) {
+ /* we got a value */
+}, function() {
+ /* something went wrong */
+});
```
In the case of certain applications, it is necessary to have several
@@ -78,11 +78,11 @@ action once all the promises have been fully fulfilled:
```
when(
- promise1,
- promise2,
- ...
+ promise1,
+ promise2,
+ ...
).then(function( futureValue1, futureValue2, ... ) {
- /* all promises have completed and are resolved */
+ /* all promises have completed and are resolved */
});
```
@@ -96,14 +96,14 @@ of this means it's a trivial process to execute a single callback once
the animations are done. For example:
```
-var promise1 = $("#id1").animate().promise();
-var promise2 = $("#id2").animate().promise();
+var promise1 = $( "#id1" ).animate().promise();
+var promise2 = $( "#id2" ).animate().promise();
when(
- promise1,
- promise2
-).then(function(){
- /* once both animations have completed
- we can then run our additional logic */
+ promise1,
+ promise2
+).then(function() {
+ /* once both animations have completed
+ we can then run our additional logic */
});
```
diff --git a/page/code-organization/deferreds/examples.md b/page/code-organization/deferreds/examples.md
index 5ab68e62..e969992b 100644
--- a/page/code-organization/deferreds/examples.md
+++ b/page/code-organization/deferreds/examples.md
@@ -37,12 +37,12 @@ system to properly handle both complete and inbound requests.
var cachedScriptPromises = {};
$.cachedGetScript = function( url, callback ) {
- if ( !cachedScriptPromises[ url ] ) {
- cachedScriptPromises[ url ] = $.Deferred(function( defer ) {
- $.getScript( url ).then( defer.resolve, defer.reject );
- }).promise();
- }
- return cachedScriptPromises[ url ].done( callback );
+ if ( !cachedScriptPromises[ url ] ) {
+ cachedScriptPromises[ url ] = $.Deferred(function( defer ) {
+ $.getScript( url ).then( defer.resolve, defer.reject );
+ }).promise();
+ }
+ return cachedScriptPromises[ url ].done( callback );
};
```
@@ -66,15 +66,15 @@ when a key isn't in the cache yet:
```
$.createCache = function( requestFunction ) {
- var cache = {};
- return function( key, callback ) {
- if ( !cache[ key ] ) {
- cache[ key ] = $.Deferred(function( defer ) {
- requestFunction( defer, key );
- }).promise();
- }
- return cache[ key ].done( callback );
- };
+ var cache = {};
+ return function( key, callback ) {
+ if ( !cache[ key ] ) {
+ cache[ key ] = $.Deferred(function( defer ) {
+ requestFunction( defer, key );
+ }).promise();
+ }
+ return cache[ key ].done( callback );
+ };
}
```
@@ -83,7 +83,7 @@ as follows:
```
$.cachedGetScript = $.createCache(function( defer, url ) {
- $.getScript( url ).then( defer.resolve, defer.reject );
+ $.getScript( url ).then( defer.resolve, defer.reject );
});
```
@@ -96,16 +96,16 @@ A cache can be used to ensure that the same image is not loaded multiple times.
```
$.loadImage = $.createCache(function( defer, url ) {
- var image = new Image();
- function cleanUp() {
- image.onload = image.onerror = null;
- }
- defer.then( cleanUp, cleanUp );
- image.onload = function() {
- defer.resolve( url );
- };
- image.onerror = defer.reject;
- image.src = url;
+ var image = new Image();
+ function cleanUp() {
+ image.onload = image.onerror = null;
+ }
+ defer.then( cleanUp, cleanUp );
+ image.onload = function() {
+ defer.resolve( url );
+ };
+ image.onerror = defer.reject;
+ image.src = url;
});
```
@@ -126,15 +126,15 @@ page are also perfect candidates. For instance, the following:
```
$.searchTwitter = $.createCache(function( defer, query ) {
- $.ajax({
- url: "http://search.twitter.com/search.json",
- data: {
- q: query
- },
- dataType: "jsonp",
- success: defer.resolve,
- error: defer.reject
- });
+ $.ajax({
+ url: "http://search.twitter.com/search.json",
+ data: {
+ q: query
+ },
+ dataType: "jsonp",
+ success: defer.resolve,
+ error: defer.reject
+ });
});
```
@@ -161,21 +161,21 @@ following caching system:
```
var readyTime;
-
+
$(function() {
- readyTime = jQuery.now();
+ readyTime = jQuery.now();
});
-
+
$.afterDOMReady = $.createCache(function( defer, delay ) {
- delay = delay || 0;
- $(function() {
- var delta = $.now() - readyTime;
- if ( delta >= delay ) {
- defer.resolve();
- } else {
- setTimeout( defer.resolve, delay - delta );
- }
- });
+ delay = delay || 0;
+ $(function() {
+ var delta = $.now() - readyTime;
+ if ( delta >= delay ) {
+ defer.resolve();
+ } else {
+ setTimeout( defer.resolve, delay - delta );
+ }
+ });
});
```
@@ -196,13 +196,13 @@ dealing with such a situation, one usually end up with code like this:
```
var buttonClicked = false;
-
+
$( "#myButton" ).click(function() {
- if ( !buttonClicked ) {
- buttonClicked = true;
- initializeData();
- showPanel();
- }
+ if ( !buttonClicked ) {
+ buttonClicked = true;
+ initializeData();
+ showPanel();
+ }
});
```
@@ -211,7 +211,7 @@ opened:
```
if ( buttonClicked ) {
- /* perform specific action */
+ /* perform specific action */
}
```
@@ -228,18 +228,18 @@ multiple event types):
```
$.fn.bindOnce = function( event, callback ) {
- var element = $( this[ 0 ] ),
- defer = element.data( "bind_once_defer_" + event );
- if ( !defer ) {
- defer = $.Deferred();
- function deferCallback() {
- element.unbind( event, deferCallback );
- defer.resolveWith( this, arguments );
- }
- element.bind( event, deferCallback )
- element.data( "bind_once_defer_" + event , defer );
- }
- return defer.done( callback ).promise();
+ var element = $( this[ 0 ] ),
+ defer = element.data( "bind_once_defer_" + event );
+ if ( !defer ) {
+ defer = $.Deferred();
+ function deferCallback() {
+ element.unbind( event, deferCallback );
+ defer.resolveWith( this, arguments );
+ }
+ element.bind( event, deferCallback )
+ element.data( "bind_once_defer_" + event , defer );
+ }
+ return defer.done( callback ).promise();
};
```
@@ -258,7 +258,7 @@ But let's define a helper method first:
```
$.fn.firstClick = function( callback ) {
- return this.bindOnce( "click", callback );
+ return this.bindOnce( "click", callback );
};
```
@@ -266,7 +266,7 @@ Then the logic can be re-factored as follows:
```
var openPanel = $( "#myButton" ).firstClick();
-
+
openPanel.done( initializeData );
openPanel.done( showPanel );
```
@@ -275,7 +275,7 @@ If an action should be performed only when a panel is opened later on:
```
openPanel.done(function() {
- /* perform specific action */
+ /* perform specific action */
});
```
@@ -296,13 +296,13 @@ the helpers defined earlier, it could be defined as:
```
$( "#myButton" ).firstClick(function() {
- var panel = $( "#myPanel" );
- $.when(
- $.get( "panel.html" ),
- panel.slideDownPromise()
- ).done(function( ajaxResponse ) {
- panel.html( ajaxResponse[ 0 ] ).fadeIn();
- });
+ var panel = $( "#myPanel" );
+ $.when(
+ $.get( "panel.html" ),
+ panel.slideDownPromise()
+ ).done(function( ajaxResponse ) {
+ panel.html( ajaxResponse[ 0 ] ).fadeIn();
+ });
});
```
@@ -315,10 +315,10 @@ The html code for this would look something like:
```
```
@@ -327,31 +327,30 @@ The code to handle our use case using our promise helpers is as follows:
```
$( "#myButton" ).firstClick(function() {
-
- var panel = $( "#myPanel" ),
- promises = [];
-
- $( "img", panel ).each(function() {
- var image = $( this ),
- src = element.attr( "data-src" );
- if ( src ) {
- promises.push(
- $.loadImage( src ).then( function() {
- image.attr( "src", src );
- }, function() {
- image.attr( "src", "error.png" );
- } )
- );
- }
- });
-
- promises.push(
- panel.slideDownPromise()
- );
-
- $.when.apply( null, promises ).done(function() {
- panel.fadeIn();
- });
+ var panel = $( "#myPanel" ),
+ promises = [];
+
+ $( "img", panel ).each(function() {
+ var image = $( this ),
+ src = element.attr( "data-src" );
+ if ( src ) {
+ promises.push(
+ $.loadImage( src ).then(function() {
+ image.attr( "src", src );
+ }, function() {
+ image.attr( "src", "error.png" );
+ })
+ );
+ }
+ });
+
+ promises.push(
+ panel.slideDownPromise()
+ );
+
+ $.when.apply( null, promises ).done(function() {
+ panel.fadeIn();
+ });
});
```
@@ -367,10 +366,10 @@ In order to implement deferred image display on the entire page,
the following format in HTML can be used.
```
-
-
-
-
+
+
+
+
```
What it says is pretty straight-forward:
@@ -383,21 +382,21 @@ What it says is pretty straight-forward:
```
$( "img" ).each(function() {
- var element = $( this ),
- src = element.attr( "data-src" ),
- after = element.attr( "data-after" );
- if ( src ) {
- $.when(
- $.loadImage( src ),
- $.afterDOMReady( after )
- ).then(function() {
- element.attr( "src", src );
- }, function() {
- element.attr( "src", "error.png" );
- } ).done(function() {
- element.fadeIn();
- });
- }
+ var element = $( this ),
+ src = element.attr( "data-src" ),
+ after = element.attr( "data-after" );
+ if ( src ) {
+ $.when(
+ $.loadImage( src ),
+ $.afterDOMReady( after )
+ ).then(function() {
+ element.attr( "src", src );
+ }, function() {
+ element.attr( "src", "error.png" );
+ }).done(function() {
+ element.fadeIn();
+ });
+ }
});
```
@@ -405,20 +404,20 @@ In order to delay the loading of the images themselves:
```
$( "img" ).each(function() {
- var element = $( this ),
- src = element.attr( "data-src" ),
- after = element.attr( "data-after" );
- if ( src ) {
- $.afterDOMReady( after, function() {
- $.loadImage( src ).then(function() {
- element.attr( "src", src );
- }, function() {
- element.attr( "src", "error.png" );
- } ).done(function() {
- element.fadeIn();
- });
- } );
- }
+ var element = $( this ),
+ src = element.attr( "data-src" ),
+ after = element.attr( "data-after" );
+ if ( src ) {
+ $.afterDOMReady( after, function() {
+ $.loadImage( src ).then(function() {
+ element.attr( "src", src );
+ }, function() {
+ element.attr( "src", "error.png" );
+ }).done(function() {
+ element.fadeIn();
+ });
+ });
+ }
});
```
diff --git a/page/code-organization/deferreds/jquery-deferreds.md b/page/code-organization/deferreds/jquery-deferreds.md
index e37c5a19..1f9e3ba0 100644
--- a/page/code-organization/deferreds/jquery-deferreds.md
+++ b/page/code-organization/deferreds/jquery-deferreds.md
@@ -46,17 +46,17 @@ conjunction with .then():
```
function successFunc(){
- console.log( "success!" );
-}
+ console.log( "success!" );
+}
function failureFunc(){
- console.log( "failure!" );
+ console.log( "failure!" );
}
$.when(
- $.ajax( "/main.php" ),
- $.ajax( "/modules.php" ),
- $.ajax( "/lists.php" )
+ $.ajax( "/main.php" ),
+ $.ajax( "/modules.php" ),
+ $.ajax( "/lists.php" )
).then( successFunc, failureFunc );
```
@@ -79,34 +79,34 @@ reactions.
```
function getLatestNews() {
- return $.get( "latestNews.php", function(data){
- console.log( "news data received" );
- $( ".news" ).html(data);
- } );
+ return $.get( "latestNews.php", function( data ) {
+ console.log( "news data received" );
+ $( ".news" ).html( data );
+ });
}
function getLatestReactions() {
- return $.get( "latestReactions.php", function(data){
- console.log( "reactions data received" );
- $( ".reactions" ).html(data);
- } );
+ return $.get( "latestReactions.php", function( data ) {
+ console.log( "reactions data received" );
+ $( ".reactions" ).html( data );
+ });
}
function prepareInterface() {
- return $.Deferred(function( dfd ) {
- var latest = $( ".news, .reactions" );
- latest.slideDown( 500, dfd.resolve );
- latest.addClass( "active" );
- }).promise();
+ return $.Deferred(function( dfd ) {
+ var latest = $( ".news, .reactions" );
+ latest.slideDown( 500, dfd.resolve );
+ latest.addClass( "active" );
+ }).promise();
}
$.when(
- getLatestNews(),
- getLatestReactions(),
- prepareInterface()
+ getLatestNews(),
+ getLatestReactions(),
+ prepareInterface()
).then(function(){
- console.log( "fire after requests succeed" );
+ console.log( "fire after requests succeed" );
}).fail(function(){
- console.log( "something went wrong!" );
+ console.log( "something went wrong!" );
});
```
diff --git a/page/code-organization/dont-repeat-yourself.md b/page/code-organization/dont-repeat-yourself.md
index 320575dd..1fe45dea 100644
--- a/page/code-organization/dont-repeat-yourself.md
+++ b/page/code-organization/dont-repeat-yourself.md
@@ -9,34 +9,24 @@ Don't repeat yourself; if you're repeating yourself, you're doing it wrong.
```
// BAD
-if ( $eventfade.data("currently") !== "showing" ) {
-
- $eventfade.stop();
-
+if ( $eventfade.data( "currently" ) !== "showing" ) {
+ $eventfade.stop();
}
-if ( $eventhover.data("currently") !== "showing" ) {
-
- $eventhover.stop();
-
+if ( $eventhover.data( "currently" ) !== "showing" ) {
+ $eventhover.stop();
}
-if ( $spans.data("currently") !== "showing" ) {
-
- $spans.stop();
-
+if ( $spans.data( "currently" ) !== "showing" ) {
+ $spans.stop();
}
// GOOD!!
var $elems = [ $eventfade, $eventhover, $spans ];
$.each( $elems, function( i, elem ) {
-
- if ( elem.data("currently") !== "showing" ) {
-
- elem.stop();
-
- }
-
+ if ( elem.data( "currently" ) !== "showing" ) {
+ elem.stop();
+ }
});
```
diff --git a/page/code-organization/feature-browser-detection.md b/page/code-organization/feature-browser-detection.md
index 58f5d095..b31484ee 100644
--- a/page/code-organization/feature-browser-detection.md
+++ b/page/code-organization/feature-browser-detection.md
@@ -61,16 +61,12 @@ Let's take a look at how to check whether or not a `