Skip to content

Commit 0683cb2

Browse files
agcolomscottgonzalez
authored andcommitted
Code indentation and formatting (c entries).
1 parent 8b21f88 commit 0683cb2

19 files changed

+702
-441
lines changed

entries/ajaxStart.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</code></pre>
1919
<p>Attach the event handler to any element:</p>
2020
<pre><code>
21-
$(document).ajaxStart(function() {
21+
$( document ).ajaxStart(function() {
2222
$( ".log" ).text( "Triggered ajaxStart handler." );
2323
});
2424
</code></pre>
@@ -34,7 +34,8 @@ $( ".trigger" ).click(function() {
3434
<note id="ajax-global-false" type="additional" data-title=".ajaxStart()"/>
3535
<example>
3636
<desc>Show a loading message whenever an Ajax request starts (and none is already active).</desc>
37-
<code><![CDATA[$(document).ajaxStart(function() {
37+
<code><![CDATA[
38+
$( document ).ajaxStart(function() {
3839
$( "#loading" ).show();
3940
});]]></code>
4041
</example>

entries/animate.xml

+154-113
Large diffs are not rendered by default.

entries/attr.xml

+10-7
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ $( "#greatphoto" ).attr( "title", "Photo by Kelly Clark" );</code></pre>
186186
$( "#greatphoto" ).attr({
187187
alt: "Beijing Brush Seller",
188188
title: "photo by Kelly Clark"
189-
});</code></pre>
189+
});
190+
</code></pre>
190191
<p>When setting multiple attributes, the quotes around attribute names are optional.</p>
191192
<p><strong>WARNING</strong>: When setting the 'class' attribute, you must always use quotes!</p>
192193
<p><strong>Note</strong>: jQuery prohibits changing the <code>type</code> attribute on an <code>&lt;input&gt;</code> or <code>&lt;button&gt;</code> element and will throw an error in all browsers. This is because the <code>type</code> attribute cannot be changed in Internet Explorer.</p>
@@ -195,7 +196,8 @@ $( "#greatphoto" ).attr({
195196
<pre><code>
196197
$( "#greatphoto" ).attr( "title", function(i, val) {
197198
return val + " - photo by Kelly Clark"
198-
});</code></pre>
199+
});
200+
</code></pre>
199201
<p>This use of a function to compute attribute values can be particularly useful when modifying the attributes of multiple elements at once.</p>
200202
<p><strong>Note: </strong>If nothing is returned in the setter function (ie. <code>function(index, attr){})</code>, or if <code>undefined</code> is returned, the current value is not changed. This is useful for selectively setting values only when certain criteria are met.</p>
201203
</longdesc>
@@ -229,11 +231,12 @@ $( "div" ).text( $( "img" ).attr( "alt" ) );
229231
<example>
230232
<desc>Set the id for divs based on the position in the page.</desc>
231233
<code><![CDATA[
232-
$( "div" ).attr( "id", function ( arr ) {
233-
return "div-id" + arr;
234-
})
235-
.each(function () {
236-
$( "span", this ).html( "(id = '<b>" + this.id + "</b>')" );
234+
$( "div" )
235+
.attr( "id", function( arr ) {
236+
return "div-id" + arr;
237+
})
238+
.each(function() {
239+
$( "span", this ).html( "(id = '<b>" + this.id + "</b>')" );
237240
});
238241
]]></code>
239242
<css><![CDATA[

entries/callbacks.fireWith.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ callbacks.add( log );
2828
// fire the callbacks on the list using the context "window"
2929
// and an arguments array
3030
31-
callbacks.fireWith( window, ["foo","bar"]);
31+
callbacks.fireWith( window, [ "foo","bar" ] );
3232
3333
// outputs: "Received: foo, bar"
3434
]]></code></pre>

entries/callbacks.lock.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
</longdesc>
1212
<example>
1313
<desc>Use <code>callbacks.lock()</code> to lock a callback list to avoid further changes being made to the list state:</desc>
14-
<code><![CDATA[// a sample logging function to be added to a callbacks list
14+
<code><![CDATA[
15+
// a sample logging function to be added to a callbacks list
1516
var foo = function( value ) {
1617
console.log( "foo:" + value );
1718
};
@@ -32,13 +33,16 @@ callbacks.lock();
3233
callbacks.fire( "world" );
3334
3435
// as the list was locked, no items
35-
// were called, so "world" isn"t logged
36+
// were called, so "world" isn't logged
3637
]]></code>
3738
</example>
3839
<example>
3940
<desc>Use <code>callbacks.lock()</code> to lock a callback list with "memory," and then resume using the list:</desc>
40-
<html><![CDATA[<div id="log"></div>]]></html>
41-
<code><![CDATA[// simple function for logging results
41+
<html><![CDATA[
42+
<div id="log"></div>
43+
]]></html>
44+
<code><![CDATA[
45+
// simple function for logging results
4246
var log = function( value) {
4347
$( "#log" ).append( "<p>" + value + "</p>" );
4448
};

entries/change.xml

+44-33
Original file line numberDiff line numberDiff line change
@@ -21,62 +21,73 @@
2121
<added>1.0</added>
2222
</signature>
2323
<longdesc>
24-
<p>This method is a shortcut for <code>.on('change', handler)</code> in the first two variations, and <code>.trigger('change')</code> in the third.</p>
24+
<p>This method is a shortcut for <code>.on( "change", handler )</code> in the first two variations, and <code>.trigger( "change" )</code> in the third.</p>
2525
<p>The <code>change</code> event is sent to an element when its value changes. This event is limited to <code>&lt;input&gt;</code> elements, <code>&lt;textarea&gt;</code> boxes and <code>&lt;select&gt;</code> elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.</p>
2626
<p>For example, consider the HTML:</p>
27-
<pre><code>&lt;form&gt;
28-
&lt;input class="target" type="text" value="Field 1" /&gt;
27+
<pre><code>
28+
&lt;form&gt;
29+
&lt;input class="target" type="text" value="Field 1"&gt;
2930
&lt;select class="target"&gt;
3031
&lt;option value="option1" selected="selected"&gt;Option 1&lt;/option&gt;
3132
&lt;option value="option2"&gt;Option 2&lt;/option&gt;
3233
&lt;/select&gt;
3334
&lt;/form&gt;
3435
&lt;div id="other"&gt;
3536
Trigger the handler
36-
&lt;/div&gt;</code></pre>
37+
&lt;/div&gt;
38+
</code></pre>
3739
<p>The event handler can be bound to the text input and the select box:</p>
38-
<pre><code>$('.target').change(function() {
39-
alert('Handler for .change() called.');
40-
});</code></pre>
40+
<pre><code>
41+
$( ".target" ).change(function() {
42+
alert( "Handler for .change() called." );
43+
});
44+
</code></pre>
4145
<p>Now when the second option is selected from the dropdown, the alert is displayed. It is also displayed if you change the text in the field and then click away. If the field loses focus without the contents having changed, though, the event is not triggered. To trigger the event manually, apply <code>.change()</code> without arguments:</p>
42-
<pre><code>$('#other').click(function() {
43-
$('.target').change();
44-
});</code></pre>
46+
<pre><code>
47+
$( "#other" ).click(function() {
48+
$( ".target" ).change();
49+
});
50+
</code></pre>
4551
<p>After this code executes, clicks on <samp>Trigger the handler</samp> will also alert the message. The message will display twice, because the handler has been bound to the <code>change</code> event on both of the form elements.</p>
4652
<p>As of jQuery 1.4, the <code>change</code> event bubbles in Internet Explorer, behaving consistently with the event in other modern browsers.</p>
4753
</longdesc>
4854
<example>
4955
<desc>Attaches a change event to the select that gets the text for each selected option and writes them in the div. It then triggers the event for the initial text draw.</desc>
5056
<code><![CDATA[
51-
$("select").change(function () {
52-
var str = "";
53-
$("select option:selected").each(function () {
54-
str += $(this).text() + " ";
55-
});
56-
$("div").text(str);
57-
})
58-
.change();
57+
$( "select" )
58+
.change(function () {
59+
var str = "";
60+
$( "select option:selected" ).each(function () {
61+
str += $( this ).text() + " ";
62+
});
63+
$( "div" ).text( str );
64+
})
65+
.change();
5966
]]></code>
6067
<css><![CDATA[
61-
div { color:red; }
68+
div {
69+
color: red;
70+
}
6271
]]></css>
63-
<html><![CDATA[<select name="sweets" multiple="multiple">
64-
<option>Chocolate</option>
65-
<option selected="selected">Candy</option>
66-
67-
<option>Taffy</option>
68-
<option selected="selected">Caramel</option>
69-
<option>Fudge</option>
70-
<option>Cookie</option>
71-
72-
</select>
73-
<div></div>]]></html>
72+
<html><![CDATA[
73+
<select name="sweets" multiple="multiple">
74+
<option>Chocolate</option>
75+
<option selected="selected">Candy</option>
76+
<option>Taffy</option>
77+
<option selected="selected">Caramel</option>
78+
<option>Fudge</option>
79+
<option>Cookie</option>
80+
</select>
81+
<div></div>
82+
]]></html>
7483
</example>
7584
<example>
7685
<desc>To add a validity test to all text input elements:</desc>
77-
<code><![CDATA[$("input[type='text']").change( function() {
78-
// check input ($(this).val()) for validity here
79-
});]]></code>
86+
<code><![CDATA[
87+
$( "input[type='text']" ).change(function() {
88+
// check input( $( this ).val() ) for validity here
89+
});
90+
]]></code>
8091
</example>
8192
<category slug="events/form-events"/>
8293
<category slug="forms"/>

entries/checkbox-selector.xml

+42-28
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,61 @@
77
</signature>
88
<desc>Selects all elements of type checkbox.</desc>
99
<longdesc>
10-
<p><code>$(':checkbox')</code> is equivalent to <code>$('[type=checkbox]')</code>. As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':checkbox')</code> is equivalent to <code>$('*:checkbox')</code>, so <code>$('input:checkbox')</code> should be used instead. </p>
10+
<p><code>$( ":checkbox" )</code> is equivalent to <code>$( "[type=checkbox]" )</code>. As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':checkbox')</code> is equivalent to <code>$( "*:checkbox" )</code>, so <code>$( "input:checkbox" )</code> should be used instead. </p>
1111
</longdesc>
1212
<note id="jquery-selector-extension-alt" type="additional" data-selector=":checkbox" data-alt="[type=&quot;checkbox&quot;]"/>
1313
<example>
1414
<desc>Finds all checkbox inputs.</desc>
1515
<code><![CDATA[
16-
17-
var input = $("form input:checkbox").wrap('<span></span>').parent().css({background:"yellow", border:"3px red solid"});
18-
$("div").text("For this type jQuery found " + input.length + ".")
19-
.css("color", "red");
20-
$("form").submit(function () { return false; }); // so it won't submit
21-
16+
var input = $( "form input:checkbox" )
17+
.wrap( "<span></span>" )
18+
.parent()
19+
.css({
20+
background: "yellow",
21+
border: "3px red solid"
22+
});
23+
$( "div" )
24+
.text( "For this type jQuery found " + input.length + "." )
25+
.css( "color", "red" );
26+
$( "form" )
27+
.submit(function () {
28+
return false;
29+
}); // so it won't submit
2230
]]></code>
2331
<css><![CDATA[
24-
textarea { height:25px; }
32+
textarea {
33+
height: 25px;
34+
}
2535
]]></css>
26-
<html><![CDATA[<form>
27-
<input type="button" value="Input Button"/>
28-
<input type="checkbox" />
29-
30-
<input type="checkbox" />
31-
<input type="file" />
32-
<input type="hidden" />
36+
<html><![CDATA[
37+
<form>
38+
<input type="button" value="Input Button">
39+
<input type="checkbox">
40+
41+
<input type="checkbox">
42+
<input type="file">
43+
<input type="hidden">
3344
34-
<input type="image" />
35-
<input type="password" />
36-
<input type="radio" />
45+
<input type="image">
46+
<input type="password">
47+
<input type="radio">
3748
38-
<input type="reset" />
39-
<input type="submit" />
40-
<input type="text" />
49+
<input type="reset">
50+
<input type="submit">
51+
<input type="text">
4152
42-
<select><option>Option<option/></select>
43-
<textarea></textarea>
44-
<button>Button</button>
45-
</form>
53+
<select>
54+
<option>Option</option>
55+
</select>
56+
57+
<textarea></textarea>
58+
<button>Button</button>
59+
</form>
4660
47-
<div>
48-
</div>]]></html>
61+
<div></div>
62+
]]></html>
4963
</example>
5064
<category slug="selectors/form-selectors"/>
5165
<category slug="selectors/jquery-selector-extensions"/>
5266
<category slug="version/1.0"/>
53-
</entry>
67+
</entry>

entries/checked-selector.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ countChecked();
2121
$( "input[type=checkbox]" ).on( "click", countChecked );
2222
]]></code>
2323
<css><![CDATA[
24-
div { color:red; }
24+
div {
25+
color: red;
26+
}
2527
]]></css>
2628
<html><![CDATA[
2729
<form>
@@ -46,8 +48,10 @@ $( "input" ).on( "click", function() {
4648
});
4749
]]></code>
4850
<css><![CDATA[
49-
input, label { line-height: 1.5em; }
50-
]]></css>
51+
input, label {
52+
line-height: 1.5em;
53+
}
54+
]]></css>
5155
<html><![CDATA[
5256
<form>
5357
<div>

entries/child-selector.xml

+13-5
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,28 @@
1818
</longdesc>
1919
<example>
2020
<desc>Places a border around all list items that are children of &lt;ul class="topnav"&gt; .</desc>
21-
<code><![CDATA[$("ul.topnav > li").css("border", "3px double red");]]></code>
21+
<code><![CDATA[
22+
$( "ul.topnav > li" ).css( "border", "3px double red" );
23+
]]></code>
2224
<css><![CDATA[
23-
body { font-size:14px; }
24-
]]></css>
25+
body {
26+
font-size: 14px;
27+
}
28+
]]></css>
2529
<html><![CDATA[
2630
<ul class="topnav">
2731
<li>Item 1</li>
2832
<li>Item 2
29-
<ul><li>Nested item 1</li><li>Nested item 2</li><li>Nested item 3</li></ul>
33+
<ul>
34+
<li>Nested item 1</li>
35+
<li>Nested item 2</li>
36+
<li>Nested item 3</li>
37+
</ul>
3038
</li>
3139
<li>Item 3</li>
3240
</ul>
3341
]]></html>
3442
</example>
3543
<category slug="selectors/hierarchy-selectors"/>
3644
<category slug="version/1.0"/>
37-
</entry>
45+
</entry>

0 commit comments

Comments
 (0)