Skip to content

Commit 6b76f10

Browse files
committed
Cleanup.
1 parent f15cd89 commit 6b76f10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+267
-254
lines changed

entries/each.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ $( "li" ).each(function( index ) {
3131
</p>
3232
<p>You can stop the loop from within the callback function by returning <code>false</code>.</p>
3333
<p>Note: most jQuery methods that return a jQuery object also loop through the set of elements in the jQuery collection — a process known as <i>implicit iteration</i>. When this occurs, it is often unnecessary to <i>explicitly</i> iterate with the <code>.each()</code> method:</p>
34-
<pre><code>
34+
<pre><code>
3535
// The .each() method is unnecessary here:
3636
$( "li" ).each(function() {
3737
$( this ).addClass( "foo" );
3838
});
3939

4040
// Instead, you should rely on implicit iteration:
4141
$( "li" ).addClass( "bar" );
42-
</code></pre>
42+
</code></pre>
4343
</longdesc>
4444
<example>
4545
<desc>Iterate over three divs and sets their color property.</desc>
4646
<code><![CDATA[
4747
$( document.body ).click(function() {
4848
$( "div" ).each(function( i ) {
49-
if ( this.style.color != "blue" ) {
49+
if ( this.style.color !== "blue" ) {
5050
this.style.color = "blue";
5151
} else {
5252
this.style.color = "";
@@ -102,12 +102,12 @@ To do list: <span>(click here to change)</span>
102102
]]></html>
103103
</example>
104104
<example>
105-
<desc>Use "return" to break out of each() loops early.</desc>
105+
<desc>Use <code>return false</code> to break out of each() loops early.</desc>
106106
<code><![CDATA[
107107
$( "button" ).click(function() {
108-
$( "div" ).each(function( index, domEle ) {
109-
// domEle == this
110-
$( domEle ).css( "backgroundColor", "yellow" );
108+
$( "div" ).each(function( index, element ) {
109+
// element == this
110+
$( element ).css( "backgroundColor", "yellow" );
111111
if ( $( this ).is( "#stop" ) ) {
112112
$( "span" ).text( "Stopped at div index #" + index );
113113
return false;

entries/empty.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $( ".hello" ).empty();
2424
&lt;div class="goodbye"&gt;Goodbye&lt;/div&gt;
2525
&lt;/div&gt;
2626
</code></pre>
27-
<p>If we had any number of nested elements inside <code>&lt;div class="hello"&gt;</code>, they would be removed, too. </p>
27+
<p>If we had any number of nested elements inside <code>&lt;div class="hello"&gt;</code>, they would be removed, too.</p>
2828
<p>To avoid memory leaks, jQuery removes other constructs such as data and event handlers from the child elements before removing the elements themselves.</p>
2929
<p>If you want to remove elements without destroying their data or event handlers (so they can be re-added later), use <a href="/detach/"><code>.detach()</code></a> instead.</p>
3030
</longdesc>
@@ -42,7 +42,7 @@ $( "button" ).click(function() {
4242
]]></css>
4343
<html><![CDATA[
4444
<p>
45-
Hello, <span>Person</span> <a href="javascript:;">and person</a>
45+
Hello, <span>Person</span> <em>and person</em>.
4646
</p>
4747
4848
<button>Call empty() on above paragraph</button>

entries/end.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
&lt;li&gt;list item 2&lt;/li&gt;
2020
&lt;li class="bar"&gt;list item 3&lt;/li&gt;
2121
&lt;/ul&gt;
22-
</code></pre>
22+
</code></pre>
2323
<p>The <code>end()</code> method is useful primarily when exploiting jQuery's chaining properties. When not using chaining, we can usually just call up a previous object by variable name, so we don't need to manipulate the stack. With <code>end()</code>, though, we can string all the method calls together:</p>
2424
<pre><code>
2525
$( "ul.first" )
2626
.find( ".foo" )
2727
.css( "background-color", "red" )
2828
.end()
29-
.find( ".bar" )
30-
.css( "background-color", "green" );
29+
.find( ".bar" )
30+
.css( "background-color", "green" );
3131
</code></pre>
3232
<p>This chain searches for items with the class <code>foo</code> within the first list only and turns their backgrounds red. Then <code>end()</code> returns the object to its state before the call to <code>find()</code>, so the second <code>find()</code> looks for '.bar' inside <code>&lt;ul class="first"&gt;</code>, not just inside that list's <code>&lt;li class="foo"&gt;</code>, and turns the matching elements' backgrounds green. The net result is that items 1 and 3 of the first list have a colored background, and none of the items from the second list do.</p>
3333
<p>A long jQuery chain can be visualized as a structured code block, with filtering methods providing the openings of nested blocks and <code>end()</code> methods closing them:</p>
@@ -50,7 +50,7 @@ jQuery.fn.showTags = function( n ) {
5050
return this.tagName;
5151
})
5252
.get()
53-
.join(", ");
53+
.join( ", " );
5454
$( "b:eq( " + n + " )" ).text( tags );
5555
return this;
5656
};

entries/eq-selector.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ $( "td:eq( 2 )" ).css( "color", "red" );
4040
<desc>Apply three different styles to list items to demonstrate that <code>:eq()</code> is designed to select a single element while <code>:nth-child()</code> or <code>:eq()</code> within a looping construct such as <code>.each()</code> can select multiple elements.</desc>
4141
<code><![CDATA[
4242
// Applies yellow background color to a single <li>
43-
$( "ul.nav li:eq( 1 )" ).css( "backgroundColor", "#ff0" );
43+
$( "ul.nav li:eq(1)" ).css( "backgroundColor", "#ff0" );
4444
4545
// Applies italics to text of the second <li> within each <ul class="nav">
4646
$( "ul.nav" ).each(function( index ) {
47-
$( this ).find( "li:eq( 1 )" ).css( "fontStyle", "italic" );
47+
$( this ).find( "li:eq(1)" ).css( "fontStyle", "italic" );
4848
});
4949
5050
// Applies red text color to descendants of <ul class="nav">
5151
// for each <li> that is the second child of its parent
52-
$( "ul.nav li:nth-child( 2 )" ).css( "color", "red" );
52+
$( "ul.nav li:nth-child(2)" ).css( "color", "red" );
5353
]]></code>
5454
<html><![CDATA[
5555
<ul class="nav">
@@ -73,7 +73,7 @@ $( "ul.nav li:nth-child( 2 )" ).css( "color", "red" );
7373
}
7474
]]></css>
7575
<code><![CDATA[
76-
$( "li:eq( -2 )" ).addClass( "foo" )
76+
$( "li:eq(-2)" ).addClass( "foo" )
7777
]]></code>
7878
<html><![CDATA[
7979
<ul class="nav">

entries/event.data.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
<code><![CDATA[
2121
var logDiv = $( "#log" );
2222
23-
// Note: This code is for demonstration purposes only.
24-
for (var i = 0; i < 5; i++) {
25-
$( "button" ).eq( i ).on( "click", {value: i}, function( event ) {
23+
for ( var i = 0; i < 5; i++ ) {
24+
$( "button" ).eq( i ).on( "click", { value: i }, function( event ) {
2625
var msgs = [
2726
"button = " + $( this ).index(),
2827
"event.data.value = " + event.data.value,
2928
"i = " + i
3029
];
31-
logDiv.append( msgs.join(", ") + "<br>" );
30+
logDiv.append( msgs.join( ", " ) + "<br>" );
3231
});
3332
}
3433
]]></code>

entries/event.delegateTarget.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ $( ".box" ).on( "click", "button", function( event ) {
2020
<category slug="events/event-object"/>
2121
<category slug="events"/>
2222
<category slug="version/1.7"/>
23-
</entry>
23+
</entry>

entries/event.isImmediatePropagationStopped.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<example>
1212
<desc>Checks whether event.stopImmediatePropagation() was called.</desc>
1313
<code><![CDATA[
14-
function immediatePropStopped( e ) {
14+
function immediatePropStopped( event ) {
1515
var msg = "";
16-
if ( e.isImmediatePropagationStopped() ) {
17-
msg = "called"
16+
if ( event.isImmediatePropagationStopped() ) {
17+
msg = "called";
1818
} else {
1919
msg = "not called";
2020
}
@@ -34,4 +34,4 @@ $( "button" ).click(function( event ) {
3434
</example>
3535
<category slug="events/event-object"/>
3636
<category slug="version/1.3"/>
37-
</entry>
37+
</entry>

entries/event.isPropagationStopped.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<example>
1212
<desc>Checks whether event.stopPropagation() was called</desc>
1313
<code><![CDATA[
14-
function propStopped( e ) {
14+
function propStopped( event ) {
1515
var msg = "";
16-
if ( e.isPropagationStopped() ) {
17-
msg = "called"
16+
if ( event.isPropagationStopped() ) {
17+
msg = "called";
1818
} else {
1919
msg = "not called";
2020
}

entries/event.metaKey.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
<example>
1313
<desc>Determine whether the META key was pressed when the event fired.</desc>
1414
<css><![CDATA[
15-
body {
16-
background-color: #eef;
17-
}
18-
div {
19-
padding: 20px;
20-
}
15+
body {
16+
background-color: #eef;
17+
}
18+
div {
19+
padding: 20px;
20+
}
2121
]]></css>
2222
<html><![CDATA[
2323
<button value="Test" name="Test" id="checkMetaKey">Click me!</button>
2424
<div id="display"></div>
2525
]]></html>
2626
<code><![CDATA[
27-
$( "#checkMetaKey" ).click(function( e ) {
28-
$( "#display" ).text( e.metaKey );
27+
$( "#checkMetaKey" ).click(function( event ) {
28+
$( "#display" ).text( event.metaKey );
2929
});
3030
]]></code>
3131
</example>

entries/event.pageX.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
<signature>
55
<added>1.0.4</added>
66
</signature>
7-
<desc>The mouse position relative to the left edge of the document. </desc>
7+
<desc>The mouse position relative to the left edge of the document.</desc>
88
<longdesc> </longdesc>
99
<example>
1010
<desc>Show the mouse position relative to the left and top edges of the document (within this iframe).</desc>
1111
<css><![CDATA[
12-
body {
13-
background-color: #eef;
14-
}
15-
div {
16-
padding: 20px;
17-
}
12+
body {
13+
background-color: #eef;
14+
}
15+
div {
16+
padding: 20px;
17+
}
1818
]]></css>
1919
<html><![CDATA[
2020
<div id="log"></div>
2121
]]></html>
2222
<code><![CDATA[
23-
$( document ).on( "mousemove", function( e ) {
24-
$( "#log" ).text( "e.pageX: " + e.pageX + ", e.pageY: " + e.pageY );
23+
$( document ).on( "mousemove", function( event ) {
24+
$( "#log" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );
2525
});
2626
]]></code>
2727
</example>

entries/event.pageY.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
<signature>
55
<added>1.0.4</added>
66
</signature>
7-
<desc>The mouse position relative to the top edge of the document. </desc>
7+
<desc>The mouse position relative to the top edge of the document.</desc>
88
<longdesc> </longdesc>
99
<example>
1010
<desc>Show the mouse position relative to the left and top edges of the document (within this iframe).</desc>
1111
<css><![CDATA[
12-
body {
13-
background-color: #eef;
14-
}
15-
div {
16-
padding: 20px;
17-
}
12+
body {
13+
background-color: #eef;
14+
}
15+
div {
16+
padding: 20px;
17+
}
1818
]]></css>
1919
<html><![CDATA[
2020
<div id="log"></div>
2121
]]></html>
2222
<code><![CDATA[
23-
$( document ).on( "mousemove", function( e ) {
24-
$( "#log" ).text( "e.pageX: " + e.pageX + ", e.pageY: " + e.pageY );
23+
$( document ).on( "mousemove", function( event ) {
24+
$( "#log" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );
2525
});
2626
]]></code>
2727
</example>

entries/event.preventDefault.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<signature>
55
<added>1.0</added>
66
</signature>
7-
<desc> If this method is called, the default action of the event will not be triggered. </desc>
7+
<desc>If this method is called, the default action of the event will not be triggered.</desc>
88
<longdesc>
99
<p>For example, clicked anchors will not take the browser to a new URL. We can use <a href="/event.isDefaultPrevented/"><code>event.isDefaultPrevented()</code></a> to determine if this method has been called by an event handler that was triggered by this event.</p>
1010
</longdesc>
@@ -13,7 +13,7 @@
1313
<code><![CDATA[
1414
$( "a" ).click(function( event ) {
1515
event.preventDefault();
16-
$( "<div/>" )
16+
$( "<div>" )
1717
.append( "default " + event.type + " prevented" )
1818
.appendTo( "#log" );
1919
});

entries/event.relatedTarget.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<signature>
55
<added>1.1.4</added>
66
</signature>
7-
<desc>The other DOM element involved in the event, if any. </desc>
7+
<desc>The other DOM element involved in the event, if any.</desc>
88
<longdesc>
99
<p>For <code>mouseout</code>, indicates the element being entered; for <code>mouseover</code>, indicates the element being exited. </p>
1010
</longdesc>

entries/event.stopImmediatePropagation.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<signature>
55
<added>1.3</added>
66
</signature>
7-
<desc> Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.</desc>
7+
<desc>Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.</desc>
88
<longdesc>
99
<p>In addition to keeping any additional handlers on an element from being executed, this method also stops the bubbling by implicitly calling <code>event.stopPropagation()</code>. To simply prevent the event from bubbling to ancestor elements but allow other event handlers to execute on the same element, we can use <code><a href="/event.stopPropagation/">event.stopPropagation()</a></code> instead.</p>
1010
<p>Use <code><a href="/event.isImmediatePropagationStopped/">event.isImmediatePropagationStopped()</a></code> to know whether this method was ever called (on that event object).</p>
@@ -34,7 +34,7 @@ $( "p" ).click(function( event ) {
3434
});
3535
$( "div" ).click(function( event ) {
3636
// This function will be executed
37-
$( this ).css( "background-color", "#f00" );
37+
$( this ).css( "background-color", "#f00" );
3838
});
3939
]]></code>
4040
<html><![CDATA[

entries/event.stopPropagation.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<signature>
55
<added>1.0</added>
66
</signature>
7-
<desc>Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. </desc>
7+
<desc>Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.</desc>
88
<longdesc>
99
<p>We can use <code><a href="/event.isPropagationStopped/">event.isPropagationStopped()</a></code> to determine if this method was ever called (on that event object). </p>
1010
<p>This method works for custom events triggered with <a href="/trigger/">trigger()</a>, as well.</p>
@@ -16,7 +16,7 @@
1616
<code><![CDATA[
1717
$( "p" ).click(function( event ) {
1818
event.stopPropagation();
19-
// do something
19+
// Do something
2020
});
2121
]]></code>
2222
</example>

entries/event.target.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ $( "body" ).click(function( event ) {
3535
<desc>Implements a simple event delegation: The click handler is added to an unordered list, and the children of its li children are hidden. Clicking one of the li children toggles (see toggle()) their children.</desc>
3636
<code><![CDATA[
3737
function handler( event ) {
38-
var $target = $( event.target );
39-
if( $target.is( "li" ) ) {
40-
$target.children().toggle();
38+
var target = $( event.target );
39+
if ( target.is( "li" ) ) {
40+
target.children().toggle();
4141
}
4242
}
4343
$( "ul" ).click( handler ).find( "ul" ).hide();

entries/event.type.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<signature>
55
<added>1.0</added>
66
</signature>
7-
<desc> Describes the nature of the event. </desc>
7+
<desc>Describes the nature of the event.</desc>
88
<longdesc> </longdesc>
99
<example>
1010
<desc>On all anchor clicks, alert the event type.</desc>

entries/event.which.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<signature>
55
<added>1.1.3</added>
66
</signature>
7-
<desc> For key or mouse events, this property indicates the specific key or button that was pressed. </desc>
7+
<desc>For key or mouse events, this property indicates the specific key or button that was pressed.</desc>
88
<longdesc>
99
<p>The <code>event.which</code> property normalizes <code>event.keyCode</code> and <code>event.charCode</code>. It is recommended to watch <code>event.which</code> for keyboard key input. For more detail, read about <a href="https://developer.mozilla.org/en/DOM/event.charCode#Notes">event.charCode on the MDC</a>. </p>
1010
<p><code>event.which</code> also normalizes button presses (<code>mousedown</code> and <code>mouseup</code>events), reporting <code>1</code> for left button, <code>2</code> for middle, and <code>3</code> for right. Use <code>event.which</code> instead of <code>event.button</code>. </p>
1111
</longdesc>
1212
<example>
1313
<desc>Log which key was depressed.</desc>
1414
<code><![CDATA[
15-
$( "#whichkey" ).on( "keydown", function( e ) {
16-
$( "#log" ).html( e.type + ": " + e.which );
15+
$( "#whichkey" ).on( "keydown", function( event ) {
16+
$( "#log" ).html( event.type + ": " + event.which );
1717
});
1818
]]></code>
1919
<html><![CDATA[
@@ -24,8 +24,8 @@ $( "#whichkey" ).on( "keydown", function( e ) {
2424
<example>
2525
<desc>Log which mouse button was depressed.</desc>
2626
<code><![CDATA[
27-
$( "#whichkey" ).on( "mousedown", function( e ) {
28-
$( "#log" ).html( e.type + ": " + e.which );
27+
$( "#whichkey" ).on( "mousedown", function( event ) {
28+
$( "#log" ).html( event.type + ": " + event.which );
2929
});
3030
]]></code>
3131
<html><![CDATA[

0 commit comments

Comments
 (0)