Skip to content

Commit 1d1dfdc

Browse files
agcolomscottgonzalez
authored andcommitted
Code indentation and formatting (t entries)
1 parent 27d5a47 commit 1d1dfdc

8 files changed

+343
-237
lines changed

entries/text-selector.xml

+40-33
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,55 @@
77
</signature>
88
<desc>Selects all elements of type text.</desc>
99
<longdesc>
10-
<p><code>$(':text')</code> allows us to select all <code>&lt;input type="text"&gt;</code> elements. 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>$(':text')</code> is equivalent to <code>$('*:text')</code>, so <code>$('input:text')</code> should be used instead. </p>
10+
<p><code>$( ":text" )</code> allows us to select all <code>&lt;input type="text"&gt;</code> elements. 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>$( ":text" )</code> is equivalent to <code>$( "*:text" )</code>, so <code>$( "input:text" )</code> should be used instead. </p>
1111
<p><strong>Note:</strong> As of jQuery 1.5.2, <code>:text</code> selects <code>input</code> elements that have no specified <code>type</code> attribute (in which case <code>type="text"</code> is implied). </p>
12-
<p>This difference in behavior between <code>$(':text')</code> and <code>$('[type=text]')</code>, can be seen below:</p>
13-
<pre><code>$('&lt;input&gt;').is('[type=text]'); // false
14-
$('&lt;input&gt;').is(':text'); // true
15-
</code></pre>
12+
<p>This difference in behavior between <code>$( ":text" )</code> and <code>$( "[type=text]" )</code>, can be seen below:</p>
13+
<pre><code>
14+
$( "&lt;input&gt;" ).is( "[type=text]"); // false
15+
$( "&lt;input&gt;" ).is( ":text" ); // true
16+
</code></pre>
1617
</longdesc>
1718
<note id="jquery-selector-extension-alt" type="additional" data-selector=":text" data-alt="[type=&quot;text&quot;]"/>
1819
<example>
1920
<desc>Finds all text inputs.</desc>
2021
<code><![CDATA[
21-
var input = $("form input:text").css({background:"yellow", border:"3px red solid"});
22-
$("div").text("For this type jQuery found " + input.length + ".")
23-
.css("color", "red");
24-
$("form").submit(function () { return false; }); // so it won't submit
22+
var input = $( "form input:text" ).css({
23+
background: "yellow",
24+
border: "3px red solid"
25+
});
26+
$( "div" ).text( "For this type jQuery found " + input.length + "." )
27+
.css( "color", "red" );
28+
$( "form" ).submit(function() {
29+
return false;
30+
}); // So it won't submit
2531
]]></code>
2632
<css><![CDATA[
27-
textarea { height:25px; }
28-
]]></css>
29-
<html><![CDATA[<form>
30-
<input type="button" value="Input Button"/>
31-
<input type="checkbox" />
32-
33-
<input type="file" />
34-
<input type="hidden" />
35-
<input type="image" />
36-
37-
<input type="password" />
38-
<input type="radio" />
39-
<input type="reset" />
40-
41-
<input type="submit" />
42-
<input type="text" />
43-
<select><option>Option</option></select>
44-
45-
<textarea></textarea>
46-
<button>Button</button>
47-
</form>
48-
<div>
49-
</div>]]></html>
33+
textarea {
34+
height: 25px;
35+
}
36+
]]></css>
37+
<html><![CDATA[
38+
<form>
39+
<input type="button" value="Input Button">
40+
<input type="checkbox">
41+
<input type="file">
42+
<input type="hidden">
43+
<input type="image">
44+
<input type="password">
45+
<input type="radio">
46+
<input type="reset">
47+
<input type="submit">
48+
<input type="text">
49+
<select>
50+
<option>Option</option>
51+
</select>
52+
<textarea></textarea>
53+
<button>Button</button>
54+
</form>
55+
<div></div>
56+
]]></html>
5057
</example>
5158
<category slug="selectors/form-selectors"/>
5259
<category slug="selectors/jquery-selector-extensions"/>
5360
<category slug="version/1.0"/>
54-
</entry>
61+
</entry>

entries/text.xml

+54-32
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,41 @@
99
<desc>Get the combined text contents of each element in the set of matched elements, including their descendants.</desc>
1010
<longdesc>
1111
<p>Unlike the <code>.html()</code> method, <code>.text()</code> can be used in both XML and HTML documents. The result of the <code>.text()</code> method is a string containing the combined text of all matched elements. (Due to variations in the HTML parsers in different browsers, the text returned may vary in newlines and other white space.) Consider the following HTML:</p>
12-
<pre><code>&lt;div class="demo-container"&gt;
13-
&lt;div class="demo-box"&gt;Demonstration Box&lt;/div&gt;
12+
<pre><code>
13+
&lt;div class="demo-container"&gt;
14+
&lt;div class="demo-box"&gt;Demonstration Box&lt;/div&gt;
1415
&lt;ul&gt;
15-
&lt;li&gt;list item 1&lt;/li&gt;
16-
&lt;li&gt;list &lt;strong&gt;item&lt;/strong&gt; 2&lt;/li&gt;
16+
&lt;li&gt;list item 1&lt;/li&gt;
17+
&lt;li&gt;list &lt;strong&gt;item&lt;/strong&gt; 2&lt;/li&gt;
1718
&lt;/ul&gt;
18-
&lt;/div&gt;
19-
</code></pre>
20-
<p>The code <code>$('div.demo-container').text()</code> would produce the following result:</p>
19+
&lt;/div&gt;
20+
</code></pre>
21+
<p>The code <code>$( "div.demo-container" ).text()</code> would produce the following result:</p>
2122
<p>
2223
<code>Demonstration Box list item 1 list item 2</code>
2324
</p>
24-
<p>The <code>.text()</code> method cannot be used on form inputs or scripts. To set or get the text value of <code>input</code> or <code>textarea</code> elements, use the <a href="/val"><code>.val()</code></a> method. To get the value of a script element, use the <a href="/html"><code>.html()</code></a> method.</p>
25+
<p>The <code>.text()</code> method cannot be used on form inputs or scripts. To set or get the text value of <code>input</code> or <code>textarea</code> elements, use the <a href="/val/"><code>.val()</code></a> method. To get the value of a script element, use the <a href="/html/"><code>.html()</code></a> method.</p>
2526
<p>As of jQuery 1.4, the <code>.text()</code> method returns the value of text and CDATA nodes as well as element nodes.</p>
2627
</longdesc>
2728
<example>
2829
<desc>Find the text in the first paragraph (stripping out the html), then set the html of the last paragraph to show it is just text (the red bold is gone).</desc>
2930
<code><![CDATA[
30-
var str = $("p:first").text();
31-
$("p:last").html(str);
31+
var str = $( "p:first" ).text();
32+
$( "p:last" ).html( str );
3233
]]></code>
3334
<css><![CDATA[
34-
p { color:blue; margin:8px; }
35-
b { color:red; }
36-
]]></css>
37-
<html><![CDATA[<p><b>Test</b> Paragraph.</p>
38-
<p></p>]]></html>
35+
p {
36+
color: blue;
37+
margin: 8px;
38+
}
39+
b {
40+
color: red;
41+
}
42+
]]></css>
43+
<html><![CDATA[
44+
<p><b>Test</b> Paragraph.</p>
45+
<p></p>
46+
]]></html>
3947
</example>
4048
<category slug="manipulation/dom-insertion-inside"/>
4149
<category slug="version/1.0"/>
@@ -58,41 +66,55 @@ $("p:last").html(str);
5866
<longdesc>
5967
<p>Unlike the <code>.html()</code> method, <code>.text()</code> can be used in both XML and HTML documents. </p>
6068
<p>We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method <code>.createTextNode()</code>, does not interpret the string as HTML. Consider the following HTML:</p>
61-
<pre><code>&lt;div class="demo-container"&gt;
69+
<pre><code>
70+
&lt;div class="demo-container"&gt;
6271
&lt;div class="demo-box"&gt;Demonstration Box&lt;/div&gt;
6372
&lt;ul&gt;
6473
&lt;li&gt;list item 1&lt;/li&gt;
6574
&lt;li&gt;list &lt;strong&gt;item&lt;/strong&gt; 2&lt;/li&gt;
6675
&lt;/ul&gt;
6776
&lt;/div&gt;
68-
</code></pre>
69-
<p>The code <code>$('div.demo-container').text('&lt;p&gt;This is a test.&lt;/p&gt;');</code> will produce the following DOM output:</p>
70-
<pre><code>&lt;div class="demo-container"&gt;
77+
</code></pre>
78+
<p>The code <code>$( "div.demo-container" ).text( "&lt;p&gt;This is a test.&lt;/p&gt;" );</code> will produce the following DOM output:</p>
79+
<pre><code>
80+
&lt;div class="demo-container"&gt;
7181
&amp;lt;p&amp;gt;This is a test.&amp;lt;/p&amp;gt;
72-
&lt;/div&gt;</code></pre>
82+
&lt;/div&gt;
83+
</code></pre>
7384
<p>It will appear on a rendered page as though the tags were exposed, like this:</p>
74-
<pre><code>&lt;p&gt;This is a test&lt;/p&gt;</code></pre>
75-
<p>The <code>.text()</code> method cannot be used on input elements. For input field text, use the <a href="/val">.val()</a> method.</p>
85+
<pre><code>
86+
&lt;p&gt;This is a test&lt;/p&gt;
87+
</code></pre>
88+
<p>The <code>.text()</code> method cannot be used on input elements. For input field text, use the <a href="/val/">.val()</a> method.</p>
7689
<p>As of jQuery 1.4, the <code>.text()</code> method allows us to set the text content by passing in a function.</p>
77-
<pre><code>$('ul li').text(function(index) {
78-
return 'item number ' + (index + 1);
79-
});</code></pre>
90+
<pre><code>
91+
$( "ul li" ).text(function( index ) {
92+
return "item number " + ( index + 1 );
93+
});
94+
</code></pre>
8095
<p>Given an unordered list with three <code>&lt;li&gt;</code> elements, this example will produce the following DOM output:</p>
81-
<pre><code>&lt;ul&gt;
96+
<pre><code>
97+
&lt;ul&gt;
8298
&lt;li&gt;item number 1&lt;/li&gt;
8399
&lt;li&gt;item number 2&lt;/li&gt;
84100
&lt;li&gt;item number 3&lt;/li&gt;
85101
&lt;/ul&gt;
86-
</code></pre>
102+
</code></pre>
87103
</longdesc>
88104
<example>
89105
<desc>Add text to the paragraph (notice the bold tag is escaped).</desc>
90-
<code><![CDATA[$("p").text("<b>Some</b> new text.");]]></code>
106+
<code><![CDATA[
107+
$( "p" ).text( "<b>Some</b> new text." );
108+
]]></code>
91109
<css><![CDATA[
92-
93-
p { color:blue; margin:8px; }
94-
]]></css>
95-
<html><![CDATA[<p>Test Paragraph.</p>]]></html>
110+
p {
111+
color: blue;
112+
margin: 8px;
113+
}
114+
]]></css>
115+
<html><![CDATA[
116+
<p>Test Paragraph.</p>
117+
]]></html>
96118
</example>
97119
<category slug="manipulation/dom-insertion-inside"/>
98120
<category slug="version/1.0"/>

entries/toArray.xml

+19-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
<desc>Retrieve all the DOM elements contained in the jQuery set, as an array.</desc>
88
<longdesc>
99
<p><code>.toArray()</code> returns all of the elements in the jQuery set:</p>
10-
<pre><code>alert($('li').toArray());</code></pre>
10+
<pre><code>
11+
alert( $( "li" ).toArray() );
12+
</code></pre>
1113
<p>All of the matched DOM nodes are returned by this call, contained in a standard array:</p>
1214
<p>
1315
<span class="result">[&lt;li id="foo"&gt;, &lt;li id="bar"&gt;]</span>
@@ -16,25 +18,29 @@
1618
<example>
1719
<desc>Selects all divs in the document and returns the DOM Elements as an Array, then uses the built-in reverse-method to reverse that array.</desc>
1820
<code><![CDATA[
19-
function disp(divs) {
21+
function disp( divs ) {
2022
var a = [];
21-
for (var i = 0; i < divs.length; i++) {
22-
a.push(divs[i].innerHTML);
23+
for ( var i = 0; i < divs.length; i++ ) {
24+
a.push( divs[ i ].innerHTML );
2325
}
24-
$("span").text(a.join(" "));
26+
$( "span" ).text( a.join( " " ) );
2527
}
2628
27-
disp( $("div").toArray().reverse() );
29+
disp( $( "div" ).toArray().reverse() );
2830
]]></code>
2931
<css><![CDATA[
30-
span { color:red; }
31-
]]></css>
32-
<html><![CDATA[Reversed - <span></span>
32+
span {
33+
color: red;
34+
}
35+
]]></css>
36+
<html><![CDATA[
37+
Reversed - <span></span>
3338
34-
<div>One</div>
35-
<div>Two</div>
36-
<div>Three</div>]]></html>
39+
<div>One</div>
40+
<div>Two</div>
41+
<div>Three</div>]]>
42+
</html>
3743
</example>
3844
<category slug="miscellaneous/dom-element-methods"/>
3945
<category slug="version/1.4"/>
40-
</entry>
46+
</entry>

entries/toggle-event.xml

+19-14
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@
1616
</signature>
1717
<longdesc>
1818
<div class="warning">
19-
<p>Note: This method signature was deprecated in jQuery 1.8 and removed in jQuery 1.9. jQuery also provides an animation method named <a href="http://api.jquery.com/toggle/">.toggle()</a> that toggles the visibility of elements. Whether the animation or the event method is fired depends on the set of arguments passed.</p>
19+
<p>Note: This method signature was deprecated in jQuery 1.8 and removed in jQuery 1.9. jQuery also provides an animation method named <a href="/toggle/">.toggle()</a> that toggles the visibility of elements. Whether the animation or the event method is fired depends on the set of arguments passed.</p>
2020
</div>
2121
<p>The <code>.toggle()</code> method binds a handler for the <code>click</code> event, so the rules outlined for the triggering of <code>click</code> apply here as well.</p>
22-
<pre><code>For example, consider the HTML:
22+
<p>For example, consider the HTML:</p>
23+
<pre><code>
2324
&lt;div id="target"&gt;
2425
Click here
25-
&lt;/div&gt;</code></pre>
26+
&lt;/div&gt;
27+
</code></pre>
2628
<p>Event handlers can then be bound to the <code>&lt;div&gt;</code>:</p>
27-
<pre><code>$('#target').toggle(function() {
28-
alert('First handler for .toggle() called.');
29+
<pre><code>
30+
$( "#target" ).toggle(function() {
31+
alert( "First handler for .toggle() called." );
2932
}, function() {
30-
alert('Second handler for .toggle() called.');
31-
});</code></pre>
33+
alert( "Second handler for .toggle() called." );
34+
});
35+
</code></pre>
3236
<p>As the element is clicked repeatedly, the messages alternate:</p>
3337
<p>
3438
<samp>First handler for .toggle() called.</samp>
@@ -46,14 +50,15 @@
4650
</longdesc>
4751
<example>
4852
<desc>Toggle a style on table cells. (Not recommended. Use .toggleClass() instead.):</desc>
49-
<code><![CDATA[$("td").toggle(
50-
function () {
51-
$(this).addClass("selected");
52-
},
53-
function () {
54-
$(this).removeClass("selected");
53+
<code><![CDATA[
54+
$( "td" ).toggle(
55+
function() {
56+
$( this ).addClass( "selected" );
57+
}, function() {
58+
$( this ).removeClass( "selected" );
5559
}
56-
);]]></code>
60+
);
61+
]]></code>
5762
</example>
5863
<category slug="events/mouse-events"/>
5964
<category slug="version/1.0"/>

0 commit comments

Comments
 (0)