Skip to content

Commit f94f8b4

Browse files
committed
api docs: code indentation and formatting (i entries)
1 parent 79a8dbf commit f94f8b4

File tree

9 files changed

+395
-224
lines changed

9 files changed

+395
-224
lines changed

entries/id-selector.xml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,42 @@
1818
<example>
1919
<desc>Select the element with the id "myDiv" and give it a red border.</desc>
2020
<code><![CDATA[
21-
$( "#myDiv" ).css( "border","3px solid red" );
21+
$( "#myDiv" ).css( "border", "3px solid red" );
2222
]]></code>
23-
<html><![CDATA[<div id="notMe"><p>id="notMe"</p></div>
24-
25-
<div id="myDiv">id="myDiv"</div>]]></html>
23+
<html><![CDATA[
24+
<div id="notMe"><p>id="notMe"</p></div>
25+
<div id="myDiv">id="myDiv"</div>
26+
]]></html>
2627
<css><![CDATA[
2728
div {
2829
width: 90px;
2930
height: 90px;
30-
float:left;
31+
float: left;
3132
padding: 5px;
3233
margin: 5px;
33-
background-color: #EEEEEE;
34+
background-color: #eee;
3435
}
35-
]]></css>
36+
]]></css>
3637
</example>
3738
<example>
3839
<desc>Select the element with the id "myID.entry[1]" and give it a red border. Note how certain characters must be escaped with backslashes.</desc>
3940
<code><![CDATA[
4041
$( "#myID\\.entry\\[1\\]" ).css( "border", "3px solid red" );
4142
]]></code>
42-
<html><![CDATA[<div id="myID.entry[0]">id="myID.entry[0]"</div>
43-
44-
<div id="myID.entry[1]">id="myID.entry[1]"</div>
45-
<div id="myID.entry[2]">id="myID.entry[2]"</div>]]></html>
43+
<html><![CDATA[
44+
<div id="myID.entry[0]">id="myID.entry[0]"</div>
45+
<div id="myID.entry[1]">id="myID.entry[1]"</div>
46+
<div id="myID.entry[2]">id="myID.entry[2]"</div>
47+
]]></html>
4648
<css><![CDATA[
4749
div {
4850
width: 300px;
49-
float:left;
51+
float: left;
5052
padding: 2px;
5153
margin: 3px;
52-
background-color: #EEEEEE;
54+
background-color: #eee;
5355
}
54-
]]></css>
56+
]]></css>
5557
</example>
5658
<category slug="selectors/basic-css-selectors"/>
5759
<category slug="version/1.0"/>

entries/image-selector.xml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,44 @@
1313
<example>
1414
<desc>Finds all image inputs.</desc>
1515
<code><![CDATA[
16-
var input = $("input:image").css({background:"yellow", border:"3px red solid"});
17-
$("div").text("For this type jQuery found " + input.length + ".")
18-
.css("color", "red");
19-
$("form").submit(function () { return false; }); // so it won't submit
16+
var input = $( "input:image" ).css({
17+
background:"yellow",
18+
border:"3px red solid"
19+
});
20+
$(" div ")
21+
.text( "For this type jQuery found " + input.length + "." )
22+
.css( "color", "red" );
23+
$( "form" ).submit(function() {
24+
return false;
25+
}); // so it won't submit
2026
]]></code>
2127
<css><![CDATA[
22-
textarea { height:45px; }
23-
]]></css>
24-
<html><![CDATA[<form>
25-
<input type="button" value="Input Button"/>
26-
<input type="checkbox" />
27-
28-
<input type="file" />
29-
<input type="hidden" />
30-
<input type="image" />
31-
32-
<input type="password" />
33-
<input type="radio" />
34-
<input type="reset" />
35-
36-
<input type="submit" />
37-
<input type="text" />
38-
<select><option>Option<option/></select>
39-
28+
textarea {
29+
height: 45px;
30+
}
31+
]]></css>
32+
<html><![CDATA[
33+
<form>
34+
<input type="button" value="Input Button">
35+
<input type="checkbox">
36+
<input type="file">
37+
<input type="hidden">
38+
<input type="image">
39+
<input type="password">
40+
<input type="radio">
41+
<input type="reset">
42+
<input type="submit">
43+
<input type="text">
44+
<select>
45+
<option>Option<option/>
46+
</select>
4047
<textarea></textarea>
4148
<button>Button</button>
4249
</form>
43-
<div>
44-
</div>]]></html>
50+
<div></div>
51+
]]></html>
4552
</example>
4653
<category slug="selectors/form-selectors"/>
4754
<category slug="selectors/jquery-selector-extensions"/>
4855
<category slug="version/1.0"/>
49-
</entry>
56+
</entry>

entries/index.xml

Lines changed: 99 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,47 @@
3232
&lt;li id="bar"&gt;bar&lt;/li&gt;
3333
&lt;li id="baz"&gt;baz&lt;/li&gt;
3434
&lt;/ul&gt;
35-
</code></pre>
35+
</code></pre>
3636
<p>If we retrieve one of the three list items (for example, through a DOM function or as the context to an event handler), <code>.index()</code> can search for this list item within the set of matched elements:</p>
3737
<pre><code>
38-
var listItem = document.getElementById('bar');
39-
alert('Index: ' + $('li').index(listItem));
40-
We get back the zero-based position of the list item:
41-
</code></pre>
38+
var listItem = document.getElementById( "bar" );
39+
alert( "Index: " + $( "li" ).index( listItem ) );
40+
</code></pre>
41+
<p>We get back the zero-based position of the list item:</p>
4242
<p>
4343
<samp>Index: 1</samp>
4444
</p>
4545
<p>Similarly, if we retrieve a jQuery object consisting of one of the three list items, <code>.index()</code> will search for that list item:</p>
4646
<pre><code>
47-
var listItem = $('#bar');
48-
alert('Index: ' + $('li').index(listItem));
49-
</code></pre>
47+
var listItem = $( "#bar" );
48+
alert( "Index: " + $( "li" ).index( listItem ) );
49+
</code></pre>
5050
<p>We get back the zero-based position of the list item:</p>
5151
<p>
5252
<samp>Index: 1</samp>
5353
</p>
5454
<p>Note that if the jQuery collection used as the <code>.index()</code> method's argument contains more than one element, the first element within the matched set of elements will be used.</p>
5555
<pre><code>
56-
var listItems = $('li:gt(0)');
57-
alert('Index: ' + $('li').index(listItems));
58-
</code></pre>
56+
var listItems = $( "li:gt(0)" );
57+
alert( "Index: " + $( "li" ).index( listItems ) );
58+
</code></pre>
5959
<p>We get back the zero-based position of the first list item within the matched set:</p>
6060
<p>
6161
<samp>Index: 1</samp>
6262
</p>
6363
<p>If we use a string as the <code>.index()</code> method's argument, it is interpreted as a jQuery selector string. The first element among the object's matched elements which also matches this selector is located.</p>
6464
<pre><code>
65-
var listItem = $('#bar');
66-
alert('Index: ' + listItem.index('li'));
67-
</code></pre>
65+
var listItem = $( "#bar" );
66+
alert( "Index: " + listItem.index( "li" ) );
67+
</code></pre>
6868
<p>We get back the zero-based position of the list item:</p>
6969
<p>
7070
<samp>Index: 1</samp>
7171
</p>
7272
<p>If we omit the argument, <code>.index()</code> will return the position of the first element within the set of matched elements in relation to its siblings:</p>
73-
<pre><code>alert('Index: ' + $('#bar').index());</code></pre>
73+
<pre><code>
74+
alert( "Index: " + $( "#bar" ).index() );
75+
</code></pre>
7476
<p>Again, we get back the zero-based position of the list item:</p>
7577
<p>
7678
<samp>Index: 1</samp>
@@ -79,80 +81,131 @@ alert('Index: ' + listItem.index('li'));
7981
<example>
8082
<desc>On click, returns the index (based zero) of that div in the page.</desc>
8183
<code><![CDATA[
82-
$("div").click(function () {
84+
$( "div" ).click(function () {
8385
// this is the dom element clicked
84-
var index = $("div").index(this);
85-
$("span").text("That was div index #" + index);
86+
var index = $( "div" ).index( this );
87+
$( "span" ).text( "That was div index #" + index );
8688
});
8789
]]></code>
8890
<css><![CDATA[
89-
div { background:yellow; margin:5px; }
90-
span { color:red; }
91+
div {
92+
background: yellow;
93+
margin: 5px;
94+
}
95+
span {
96+
color: red;
97+
}
9198
]]></css>
92-
<html><![CDATA[<span>Click a div!</span>
99+
<html><![CDATA[
100+
<span>Click a div!</span>
93101
<div>First div</div>
94102
<div>Second div</div>
95-
<div>Third div</div>]]></html>
103+
<div>Third div</div>
104+
]]></html>
96105
</example>
97106
<example>
98107
<desc>Returns the index for the element with ID bar.</desc>
99-
<css>div { font-weight: bold; color: #090; }</css>
100-
<code><![CDATA[var listItem = $('#bar');
101-
$('div').html( 'Index: ' + $('li').index(listItem) );]]></code>
102-
<html><![CDATA[<ul>
108+
<css><![CDATA[
109+
div {
110+
font-weight: bold;
111+
color: #090;
112+
}
113+
]]></css>
114+
<code><![CDATA[
115+
var listItem = $( "#bar" );
116+
$( "div" ).html( "Index: " + $( "li" ).index( listItem ) );
117+
]]></code>
118+
<html><![CDATA[
119+
<ul>
103120
<li id="foo">foo</li>
104121
<li id="bar">bar</li>
105122
<li id="baz">baz</li>
106123
</ul>
107-
<div></div>]]></html>
124+
<div></div>
125+
]]></html>
108126
</example>
109127
<example>
110128
<desc>Returns the index for the first item in the jQuery collection.</desc>
111-
<css>div { font-weight: bold; color: #090; }</css>
112-
<code><![CDATA[var listItems = $('li:gt(0)');
113-
$('div').html( 'Index: ' + $('li').index(listItems) );
129+
<css><![CDATA[
130+
div {
131+
font-weight: bold;
132+
color: #090;
133+
}
134+
]]></css>
135+
<code><![CDATA[
136+
var listItems = $( "li:gt(0)" ");
137+
$( "div" ).html( "Index: " + $( "li" ).index( listItems ) );
114138
]]></code>
115-
<html><![CDATA[<ul>
139+
<html><![CDATA[
140+
<ul>
116141
<li id="foo">foo</li>
117142
<li id="bar">bar</li>
118143
<li id="baz">baz</li>
119144
</ul>
120-
<div></div>]]></html>
145+
<div></div>
146+
]]></html>
121147
</example>
122148
<example>
123149
<desc>Returns the index for the element with ID bar in relation to all &lt;li&gt; elements.</desc>
124-
<css>div { font-weight: bold; color: #090; }</css>
125-
<code><![CDATA[$('div').html('Index: ' + $('#bar').index('li') );]]></code>
126-
<html><![CDATA[<ul>
150+
<css><![CDATA[
151+
div {
152+
font-weight: bold;
153+
color: #090;
154+
}
155+
]]></css>
156+
<code><![CDATA[
157+
$( "div" ).html( "Index: " + $( "#bar" ).index( "li" ) );
158+
]]></code>
159+
<html><![CDATA[
160+
<ul>
127161
<li id="foo">foo</li>
128162
<li id="bar">bar</li>
129163
<li id="baz">baz</li>
130164
</ul>
131-
<div></div>]]></html>
165+
<div></div>
166+
]]></html>
132167
</example>
133168
<example>
134169
<desc>Returns the index for the element with ID bar in relation to its siblings.</desc>
135-
<css>div { font-weight: bold; color: #090; }</css>
136-
<code><![CDATA[var barIndex = $('#bar').index();
137-
$('div').html( 'Index: ' + barIndex );]]></code>
138-
<html><![CDATA[<ul>
170+
<css><![CDATA[
171+
div {
172+
font-weight: bold;
173+
color: #090;
174+
}
175+
]]></css>
176+
<code><![CDATA[
177+
var barIndex = $( "#bar" ).index();
178+
$( "div" ).html( "Index: " + barIndex );
179+
]]></code>
180+
<html><![CDATA[
181+
<ul>
139182
<li id="foo">foo</li>
140183
<li id="bar">bar</li>
141184
<li id="baz">baz</li>
142185
</ul>
143-
<div></div>]]></html>
186+
<div></div>
187+
]]></html>
144188
</example>
145189
<example>
146190
<desc>Returns -1, as there is no element with ID foobar.</desc>
147-
<css>div { font-weight: bold; color: #090; }</css>
148-
<code><![CDATA[var foobar = $("li").index( $('#foobar') );
149-
$('div').html('Index: ' + foobar);]]></code>
150-
<html><![CDATA[<ul>
191+
<css><![CDATA[
192+
div {
193+
font-weight: bold;
194+
color: #090;
195+
}
196+
]]></css>
197+
<code><![CDATA[
198+
var foobar = $( "li" ).index( $( "#foobar" ) );
199+
$( "div" ).html( "Index: " + foobar );
200+
]]></code>
201+
<html><![CDATA[
202+
<ul>
151203
<li id="foo">foo</li>
152204
<li id="bar">bar</li>
153205
<li id="baz">baz</li>
154206
</ul>
155-
<div></div>]]></html>
207+
<div></div>
208+
]]></html>
156209
</example>
157210
<category slug="miscellaneous/dom-element-methods"/>
158211
<category slug="version/1.0"/>

entries/innerHeight.xml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,31 @@
77
<desc>Get the current computed height for the first element in the set of matched elements, including padding but not border.</desc>
88
<longdesc>
99
<p>This method returns the height of the element, including top and bottom padding, in pixels.</p>
10-
<p>This method is not applicable to <code>window</code> and <code>document</code> objects; for these, use <code><a href="/height">.height()</a></code> instead.</p>
10+
<p>This method is not applicable to <code>window</code> and <code>document</code> objects; for these, use <code><a href="/height/">.height()</a></code> instead.</p>
1111
<p class="image">
1212
<img src="/resources/0042_04_02.png"/>
1313
</p>
1414
</longdesc>
1515
<example>
1616
<desc>Get the innerHeight of a paragraph.</desc>
17-
<code><![CDATA[var p = $("p:first");
18-
$("p:last").text( "innerHeight:" + p.innerHeight() );]]></code>
19-
<css><![CDATA[p { margin:10px;padding:5px;border:2px solid #666; }]]></css>
20-
<html><![CDATA[<p>Hello</p><p></p>]]></html>
17+
<code><![CDATA[
18+
var p = $( "p:first" );
19+
$( "p:last" ).text( "innerHeight:" + p.innerHeight() );
20+
]]></code>
21+
<css><![CDATA[
22+
p {
23+
margin: 10px;
24+
padding: 5px;
25+
border: 2px solid #666;
26+
}
27+
]]></css>
28+
<html><![CDATA[
29+
<p>Hello</p>
30+
<p></p>
31+
]]></html>
2132
</example>
2233
<category slug="css"/>
2334
<category slug="dimensions"/>
2435
<category slug="manipulation/style-properties"/>
2536
<category slug="version/1.2.6"/>
26-
</entry>
37+
</entry>

0 commit comments

Comments
 (0)