Skip to content

Commit 0d7949d

Browse files
agcolomscottgonzalez
authored andcommitted
Code indentation and formatting (o entries)
1 parent 6b76f10 commit 0d7949d

10 files changed

+337
-187
lines changed

entries/odd-selector.xml

+11-8
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,30 @@
55
<signature>
66
<added>1.0</added>
77
</signature>
8-
<desc>Selects odd elements, zero-indexed. See also <a href="/Selectors/even">even</a>.</desc>
8+
<desc>Selects odd elements, zero-indexed. See also <a href="/Selectors/even/">even</a>.</desc>
99
<longdesc>
1010
<p>In particular, note that the <em>0-based indexing</em> means that, counter-intuitively, <code>:odd</code> selects the second element, fourth element, and so on within the matched set.</p>
1111
</longdesc>
1212
<note id="jquery-selector-extension" type="additional" data-selector=":odd"/>
1313
<note id="document-order" type="additional"/>
1414
<example>
1515
<desc>Finds odd table rows, matching the second, fourth and so on (index 1, 3, 5 etc.).</desc>
16-
<code><![CDATA[$("tr:odd").css("background-color", "#bbbbff");]]></code>
16+
<code><![CDATA[
17+
$( "tr:odd" ).css( "background-color", "#bbbbff" );
18+
]]></code>
1719
<css><![CDATA[
18-
table {
19-
background:#f3f7f5;
20-
}
20+
table {
21+
background: #f3f7f5;
22+
}
2123
]]></css>
22-
<html><![CDATA[<table border="1">
24+
<html><![CDATA[
25+
<table border="1">
2326
<tr><td>Row with Index #0</td></tr>
2427
<tr><td>Row with Index #1</td></tr>
25-
2628
<tr><td>Row with Index #2</td></tr>
2729
<tr><td>Row with Index #3</td></tr>
28-
</table>]]></html>
30+
</table>
31+
]]></html>
2932
</example>
3033
<category slug="selectors/basic-filter-selectors"/>
3134
<category slug="selectors/jquery-selector-extensions"/>

entries/off.xml

+45-29
Original file line numberDiff line numberDiff line change
@@ -24,70 +24,86 @@
2424
</argument>
2525
</signature>
2626
<longdesc>
27-
<p>The <code>off()</code> method removes event handlers that were attached with <a href="http://api.jquery.com/on"><code>.on()</code></a>. See the discussion of delegated and directly bound events on that page for more information. Specific event handlers can be removed on elements by providing combinations of event names, namespaces, selectors, or handler function names. <strong>When multiple filtering arguments are given, all of the arguments provided must match for the event handler to be removed.</strong></p>
27+
<p>The <code>off()</code> method removes event handlers that were attached with <a href="/on/"><code>.on()</code></a>. See the discussion of delegated and directly bound events on that page for more information. Specific event handlers can be removed on elements by providing combinations of event names, namespaces, selectors, or handler function names. <strong>When multiple filtering arguments are given, all of the arguments provided must match for the event handler to be removed.</strong></p>
2828
<p>If a simple event name such as <code>"click"</code> is provided, <em>all</em> events of that type (both direct and delegated) are removed from the elements in the jQuery set. When writing code that will be used as a plugin, or simply when working with a large code base, best practice is to attach and remove events using namespaces so that the code will not inadvertently remove event handlers attached by other code. All events of all types in a specific namespace can be removed from an element by providing just a namespace, such as <code>".myPlugin"</code>. At minimum, either a namespace or event name must be provided.</p>
2929
<p>To remove specific delegated event handlers, provide a <code>selector</code> argument. The selector string must exactly match the one passed to <code>.on()</code> when the event handler was attached. To remove all delegated events from an element without removing non-delegated events, use the special value <code>"**"</code>.</p>
30-
<p>A handler can also be removed by specifying the function name in the <code>handler</code> argument. When jQuery attaches an event handler, it assigns a unique id to the handler function. Handlers proxied by <a href="http://api.jquery.com/jQuery.proxy"><code>jQuery.proxy()</code></a> or a similar mechanism will all have the same unique id (the proxy function), so passing proxied handlers to <code>.off</code> may remove more handlers than intended. In those situations it is better to attach and remove event handlers using namespaces.</p>
30+
<p>A handler can also be removed by specifying the function name in the <code>handler</code> argument. When jQuery attaches an event handler, it assigns a unique id to the handler function. Handlers proxied by <a href="/jQuery.proxy/"><code>jQuery.proxy()</code></a> or a similar mechanism will all have the same unique id (the proxy function), so passing proxied handlers to <code>.off</code> may remove more handlers than intended. In those situations it is better to attach and remove event handlers using namespaces.</p>
3131
<p>As with <code>.on()</code>, you can pass <code>events</code> as an object instead of specifying an <code>events</code> string and <code>handler</code> function as separate arguments. The keys for the <code>events</code> object are events and/or namespaces; the values are handler functions or the special value <code>false</code>.</p>
3232
</longdesc>
3333
<example>
3434
<desc>Add and remove event handlers on the colored button.</desc>
3535
<code><![CDATA[
3636
function aClick() {
37-
$("div").show().fadeOut("slow");
37+
$( "div" ).show().fadeOut( "slow" );
3838
}
39-
$("#bind").click(function () {
40-
$("body").on("click", "#theone", aClick)
41-
.find("#theone").text("Can Click!");
39+
$( "#bind" ).click(function() {
40+
$( "body" ).on( "click", "#theone", aClick )
41+
.find( "#theone" )
42+
.text( "Can Click!" );
4243
});
43-
$("#unbind").click(function () {
44-
$("body").off("click", "#theone", aClick)
45-
.find("#theone").text("Does nothing...");
44+
$( "#unbind" ).click(function() {
45+
$( "body" ).off( "click", "#theone", aClick )
46+
.find( "#theone" )
47+
.text( "Does nothing..." );
4648
});
4749
]]></code>
4850
<css><![CDATA[
49-
button { margin:5px; }
50-
button#theone { color:red; background:yellow; }
51+
button {
52+
margin: 5px;
53+
}
54+
button#theone {
55+
color: red;
56+
background: yellow;
57+
}
5158
]]></css>
52-
<html><![CDATA[<button id="theone">Does nothing...</button>
59+
<html><![CDATA[
60+
<button id="theone">Does nothing...</button>
5361
<button id="bind">Add Click</button>
5462
<button id="unbind">Remove Click</button>
55-
<div style="display:none;">Click!</div>]]></html>
63+
<div style="display:none;">Click!</div>
64+
]]></html>
5665
</example>
5766
<example>
5867
<desc>Remove all event handlers from all paragraphs:</desc>
59-
<code><![CDATA[$("p").off()]]></code>
68+
<code><![CDATA[
69+
$( "p" ).off();
70+
]]></code>
6071
</example>
6172
<example>
6273
<desc>Remove all delegated click handlers from all paragraphs:</desc>
63-
<code><![CDATA[$("p").off( "click", "**" )]]></code>
74+
<code><![CDATA[
75+
$( "p" ).off( "click", "**" );
76+
]]></code>
6477
</example>
6578
<example>
6679
<desc>Remove just one previously bound handler by passing it as the third argument:</desc>
67-
<code><![CDATA[var foo = function () {
68-
// code to handle some kind of event
80+
<code><![CDATA[
81+
var foo = function() {
82+
// Code to handle some kind of event
6983
};
7084
71-
// ... now foo will be called when paragraphs are clicked ...
72-
$("body").on("click", "p", foo);
85+
// ... Now foo will be called when paragraphs are clicked ...
86+
$( "body" ).on( "click", "p", foo );
7387
74-
// ... foo will no longer be called.
75-
$("body").off("click", "p", foo); ]]></code>
88+
// ... Foo will no longer be called.
89+
$( "body" ).off( "click", "p", foo );
90+
]]></code>
7691
</example>
7792
<example>
7893
<desc>Unbind all delegated event handlers by their namespace:</desc>
79-
<code><![CDATA[var validate = function () {
80-
// code to validate form entries
94+
<code><![CDATA[
95+
var validate = function() {
96+
// Code to validate form entries
8197
};
8298
83-
// delegate events under the ".validator" namespace
84-
$("form").on("click.validator", "button", validate);
99+
// Delegate events under the ".validator" namespace
100+
$( "form" ).on( "click.validator", "button", validate );
85101
86-
$("form").on("keypress.validator", "input[type='text']", validate);
102+
$( "form" ).on( "keypress.validator", "input[type='text']", validate );
87103
88-
// remove event handlers in the ".validator" namespace
89-
90-
$("form").off(".validator");]]></code>
104+
// Remove event handlers in the ".validator" namespace
105+
$( "form" ).off( ".validator" );
106+
]]></code>
91107
</example>
92108
<category slug="events/event-handler-attachment"/>
93109
<category slug="version/1.7"/>

entries/offset.xml

+49-23
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,59 @@
1717
</longdesc>
1818
<example>
1919
<desc>Access the offset of the second paragraph:</desc>
20-
<code><![CDATA[var p = $("p:last");
20+
<code><![CDATA[
21+
var p = $( "p:last" );
2122
var offset = p.offset();
22-
p.html( "left: " + offset.left + ", top: " + offset.top );]]></code>
23+
p.html( "left: " + offset.left + ", top: " + offset.top );
24+
]]></code>
2325
<css><![CDATA[
24-
p { margin-left:10px; }
25-
]]></css>
26-
<html><![CDATA[<p>Hello</p><p>2nd Paragraph</p>]]></html>
26+
p {
27+
margin-left: 10px;
28+
}
29+
]]></css>
30+
<html><![CDATA[
31+
<p>Hello</p><p>2nd Paragraph</p>
32+
]]></html>
2733
</example>
2834
<example>
2935
<desc>Click to see the offset.</desc>
3036
<code><![CDATA[
31-
$("*", document.body).click(function (e) {
32-
var offset = $(this).offset();
37+
$( "*", document.body ).click(function( e ) {
38+
var offset = $( this ).offset();
3339
e.stopPropagation();
34-
$("#result").text(this.tagName + " coords ( " + offset.left + ", " +
35-
offset.top + " )");
40+
$( "#result" ).text( this.tagName + " coords ( " + offset.left + ", " +
41+
offset.top + " )" );
3642
});
37-
3843
]]></code>
3944
<css><![CDATA[
40-
p { margin-left:10px; color:blue; width:200px;
41-
cursor:pointer; }
42-
span { color:red; cursor:pointer; }
43-
div.abs { width:50px; height:50px; position:absolute;
44-
left:220px; top:35px; background-color:green;
45-
cursor:pointer; }
46-
]]></css>
47-
<html><![CDATA[<div id="result">Click an element.</div>
45+
p {
46+
margin-left: 10px;
47+
color: blue;
48+
width: 200px;
49+
cursor: pointer;
50+
}
51+
span {
52+
color: red;
53+
cursor: pointer;
54+
}
55+
div.abs {
56+
width: 50px;
57+
height: 50px;
58+
position: absolute;
59+
left: 220px;
60+
top: 35px;
61+
background-color: green;
62+
cursor: pointer;
63+
}
64+
]]></css>
65+
<html><![CDATA[
66+
<div id="result">Click an element.</div>
4867
<p>
4968
This is the best way to <span>find</span> an offset.
5069
</p>
51-
5270
<div class="abs">
5371
</div>
54-
]]></html>
72+
]]></html>
5573
</example>
5674
<category slug="css"/>
5775
<category slug="offset"/>
@@ -78,9 +96,17 @@ div.abs { width:50px; height:50px; position:absolute;
7896
</longdesc>
7997
<example>
8098
<desc>Set the offset of the second paragraph:</desc>
81-
<code><![CDATA[$("p:last").offset({ top: 10, left: 30 });]]></code>
82-
<css><![CDATA[p { margin-left:10px; } ]]></css>
83-
<html><![CDATA[<p>Hello</p><p>2nd Paragraph</p>]]></html>
99+
<code><![CDATA[
100+
$( "p:last" ).offset({ top: 10, left: 30 });
101+
]]></code>
102+
<css><![CDATA[
103+
p {
104+
margin-left: 10px;
105+
}
106+
]]></css>
107+
<html><![CDATA[
108+
<p>Hello</p><p>2nd Paragraph</p>
109+
]]></html>
84110
</example>
85111
<category slug="css"/>
86112
<category slug="offset"/>

entries/offsetParent.xml

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
&lt;/ul&gt;
2929
</code></pre>
3030
<p>If we begin at item A, we can find its positioned ancestor:</p>
31-
<pre><code>$('li.item-a').offsetParent().css('background-color', 'red');</code></pre>
31+
<pre><code>
32+
$( "li.item-a" ).offsetParent().css( "background-color", "red" );
33+
</code></pre>
3234
<p>This will change the color of list item II, which is positioned.</p>
3335
</longdesc>
3436
<example>
3537
<desc>Find the offsetParent of item "A."</desc>
3638
<height>250</height>
37-
<code>$('li.item-a').offsetParent().css('background-color', 'red');</code>
39+
<code>$( "li.item-a" ).offsetParent().css( "background-color", "red" );</code>
3840
<html><![CDATA[
3941
<ul class="level-1">
4042
<li class="item-i">I</li>
@@ -52,8 +54,9 @@
5254
</ul>
5355
</li>
5456
<li class="item-iii">III</li>
55-
</ul>]]></html>
57+
</ul>
58+
]]></html>
5659
</example>
5760
<category slug="offset"/>
5861
<category slug="traversing/tree-traversal"/>
59-
</entry>
62+
</entry>

0 commit comments

Comments
 (0)