Skip to content

Commit 0027946

Browse files
committed
api docs: code indentation and formatting (jQuery.h to jQuery.x entries)
1 parent 67e739f commit 0027946

29 files changed

+745
-528
lines changed

entries/jQuery.hasData.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</signature>
1010
<desc>Determine whether an element has any jQuery data associated with it.</desc>
1111
<longdesc>
12-
<p>The <code>jQuery.hasData()</code> method provides a way to determine if an element currently has any values that were set using <code><a href="/jQuery.data">jQuery.data()</a></code>. If no data is associated with an element (there is no data object at all or the data object is empty), the method returns <code>false</code>; otherwise it returns <code>true</code>.</p>
12+
<p>The <code>jQuery.hasData()</code> method provides a way to determine if an element currently has any values that were set using <code><a href="/jQuery.data/">jQuery.data()</a></code>. If no data is associated with an element (there is no data object at all or the data object is empty), the method returns <code>false</code>; otherwise it returns <code>true</code>.</p>
1313
<p>The primary advantage of <code>jQuery.hasData(element)</code> is that it does not create and associate a data object with the element if none currently exists. In contrast, <code>jQuery.data(element)</code> always returns a data object to the caller, creating one if no data object previously existed.
1414
</p>
1515
<p>Note that jQuery's event system uses the jQuery data API to store event handlers. Therefore, binding an event to an element using <code>.on()</code>, <code>.bind()</code>, <code>.live()</code>, <code>.delegate()</code>, or one of the shorthand event methods also associates a data object with that element.
@@ -18,24 +18,25 @@
1818
<example>
1919
<desc>Set data on an element and see the results of hasData.</desc>
2020
<code><![CDATA[
21-
var $p = jQuery("p"), p = $p[0];
22-
$p.append(jQuery.hasData(p)+" "); /* false */
21+
var $p = jQuery( "p" ), p = $p[ 0 ];
22+
$p.append( jQuery.hasData( p ) + " " ); // false
2323
24-
$.data(p, "testing", 123);
25-
$p.append(jQuery.hasData(p)+" "); /* true*/
24+
$.data( p, "testing", 123 );
25+
$p.append( jQuery.hasData( p ) + " " ); // true
2626
27-
$.removeData(p, "testing");
28-
$p.append(jQuery.hasData(p)+" "); /* false */
27+
$.removeData( p, "testing" );
28+
$p.append( jQuery.hasData( p ) + " " ); // false
2929
30-
$p.on('click', function() {});
31-
$p.append(jQuery.hasData(p)+" "); /* true */
32-
33-
$p.off('click');
34-
$p.append(jQuery.hasData(p)+" "); /* false */
30+
$p.on( "click", function() {} );
31+
$p.append( jQuery.hasData( p ) + " " ); // true
3532
33+
$p.off( "click" );
34+
$p.append( jQuery.hasData( p ) + " " ); // false
3635
]]></code>
37-
<html><![CDATA[<p>Results: </p>]]></html>
36+
<html><![CDATA[
37+
<p>Results: </p>
38+
]]></html>
3839
</example>
3940
<category slug="data"/>
4041
<category slug="version/1.5"/>
41-
</entry>
42+
</entry>

entries/jQuery.holdReady.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
</signature>
1111
<longdesc>
1212
<p>The <code>$.holdReady()</code> method allows the caller to delay jQuery's ready event. This <em>advanced feature</em> would typically be used by dynamic script loaders that want to load additional JavaScript such as jQuery plugins before allowing the ready event to occur, even though the DOM may be ready. This method must be called early in the document, such as in the <code>&lt;head&gt;</code> immediately after the jQuery script tag. Calling this method after the ready event has already fired will have no effect. </p>
13-
<p>To delay the ready event, first call <code>$.holdReady(true)</code>. When the ready event should be released to execute, call <code>$.holdReady(false)</code>. Note that multiple holds can be put on the ready event, one for each <code>$.holdReady(true)</code> call. The ready event will not actually fire until all holds have been released with a corresponding number of <code>$.holdReady(false)</code> calls <em>and</em> the normal document ready conditions are met. (See <a href="http://api.jquery.com/ready/"><code>ready</code></a> for more information.)</p>
13+
<p>To delay the ready event, first call <code>$.holdReady(true)</code>. When the ready event should be released to execute, call <code>$.holdReady( false )</code>. Note that multiple holds can be put on the ready event, one for each <code>$.holdReady( true )</code> call. The ready event will not actually fire until all holds have been released with a corresponding number of <code>$.holdReady(false)</code> calls <em>and</em> the normal document ready conditions are met. (See <a href="/ready/"><code>ready</code></a> for more information.)</p>
1414
</longdesc>
1515
<example>
1616
<desc>Delay the ready event until a custom plugin has loaded.</desc>
1717
<code><![CDATA[
18-
$.holdReady(true);
19-
$.getScript("myplugin.js", function() {
20-
$.holdReady(false);
18+
$.holdReady( true );
19+
$.getScript( "myplugin.js", function() {
20+
$.holdReady( false );
2121
});
2222
]]></code>
2323
</example>
2424
<category slug="core"/>
2525
<category slug="version/1.6"/>
26-
</entry>
26+
</entry>

entries/jQuery.inArray.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,28 @@
2020
</longdesc>
2121
<example>
2222
<desc>Report the index of some elements in the array.</desc>
23-
<code><![CDATA[var arr = [ 4, "Pete", 8, "John" ];
24-
var $spans = $("span");
25-
$spans.eq(0).text(jQuery.inArray("John", arr));
26-
$spans.eq(1).text(jQuery.inArray(4, arr));
27-
$spans.eq(2).text(jQuery.inArray("Karl", arr));
28-
$spans.eq(3).text(jQuery.inArray("Pete", arr, 2));
23+
<code><![CDATA[
24+
var arr = [ 4, "Pete", 8, "John" ];
25+
var $spans = $( "span" );
26+
$spans.eq( 0 ).text( jQuery.inArray( "John", arr ) );
27+
$spans.eq( 1 ).text( jQuery.inArray( 4, arr ) );
28+
$spans.eq( 2 ).text( jQuery.inArray( "Karl", arr ) );
29+
$spans.eq( 3 ).text( jQuery.inArray( "Pete", arr, 2 ) );
2930
]]></code>
3031
<css><![CDATA[
31-
div { color:blue; }
32-
span { color:red; }
32+
div {
33+
color: blue;
34+
}
35+
span {
36+
color: red;
37+
}
3338
]]></css>
3439
<html><![CDATA[
3540
<div>"John" found at <span></span></div>
3641
<div>4 found at <span></span></div>
3742
<div>"Karl" not found, so <span></span></div>
38-
<div>"Pete" is in the array, but not at or after index 2, so <span></span></div>]]></html>
43+
<div>"Pete" is in the array, but not at or after index 2, so <span></span></div>
44+
]]></html>
3945
</example>
4046
<category slug="utilities"/>
4147
<category slug="version/1.2"/>

entries/jQuery.isArray.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
</longdesc>
1414
<example>
1515
<desc>Finds out if the parameter is an array.</desc>
16-
<code><![CDATA[$("b").append( "" + $.isArray([]) );]]></code>
17-
<html><![CDATA[Is [] an Array? <b></b>]]></html>
16+
<code><![CDATA[
17+
$( "b" ).append( "" + $.isArray([]) );
18+
]]></code>
19+
<html><![CDATA[
20+
Is [] an Array? <b></b>
21+
]]></html>
1822
</example>
1923
<category slug="utilities"/>
2024
<category slug="version/1.3"/>
21-
</entry>
25+
</entry>

entries/jQuery.isEmptyObject.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
</signature>
1010
<desc>Check to see if an object is empty (contains no enumerable properties).</desc>
1111
<longdesc>
12-
<p>As of jQuery 1.4 this method checks both properties on the object itself and properties inherited from prototypes (in that it doesn't use hasOwnProperty). The argument should always be a plain JavaScript <code>Object</code> as other types of object (DOM elements, primitive strings/numbers, host objects) may not give consistent results across browsers. To determine if an object is a plain JavaScript object, use <a href="http://api.jquery.com/jQuery.isPlainObject"><code>$.isPlainObject()</code></a></p>
12+
<p>As of jQuery 1.4 this method checks both properties on the object itself and properties inherited from prototypes (in that it doesn't use hasOwnProperty). The argument should always be a plain JavaScript <code>Object</code> as other types of object (DOM elements, primitive strings/numbers, host objects) may not give consistent results across browsers. To determine if an object is a plain JavaScript object, use <a href="/jQuery.isPlainObject/"><code>$.isPlainObject()</code></a></p>
1313
</longdesc>
1414
<example>
1515
<desc>Check an object to see if it's empty.</desc>
16-
<code><![CDATA[jQuery.isEmptyObject({}) // true
17-
jQuery.isEmptyObject({ foo: "bar" }) // false
18-
]]></code>
16+
<code><![CDATA[
17+
jQuery.isEmptyObject({}); // true
18+
jQuery.isEmptyObject({ foo: "bar" }); // false
19+
]]></code>
1920
</example>
2021
<category slug="utilities"/>
2122
<category slug="version/1.4"/>

entries/jQuery.isFunction.xml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,45 @@
1717
function stub() {
1818
}
1919
var objs = [
20-
function () {},
21-
{ x:15, y:20 },
22-
null,
23-
stub,
24-
"function"
25-
];
20+
function () {},
21+
{ x:15, y:20 },
22+
null,
23+
stub,
24+
"function"
25+
];
2626
27-
jQuery.each(objs, function (i) {
28-
var isFunc = jQuery.isFunction(objs[i]);
29-
$("span").eq(i).text(isFunc);
27+
jQuery.each( objs, function ( i ) {
28+
var isFunc = jQuery.isFunction( objs[ i ]);
29+
$( "span" ).eq( i ).text( isFunc );
3030
});
3131
]]></code>
3232
<css><![CDATA[
33-
div { color:blue; margin:2px; font-size:14px; }
34-
span { color:red; }
35-
]]></css>
33+
div {
34+
color: blue;
35+
margin: 2px;
36+
font-size: 14px;
37+
}
38+
span {
39+
color: red;
40+
}
41+
]]></css>
3642
<html><![CDATA[
37-
<div>jQuery.isFunction(objs[0]) = <span></span></div>
38-
39-
<div>jQuery.isFunction(objs[1]) = <span></span></div>
40-
<div>jQuery.isFunction(objs[2]) = <span></span></div>
41-
<div>jQuery.isFunction(objs[3]) = <span></span></div>
42-
43-
<div>jQuery.isFunction(objs[4]) = <span></span></div>
44-
]]></html>
43+
<div>jQuery.isFunction( objs[ 0 ] ) = <span></span></div>
44+
<div>jQuery.isFunction( objs[ 1 ] ) = <span></span></div>
45+
<div>jQuery.isFunction( objs[ 2 ] ) = <span></span></div>
46+
<div>jQuery.isFunction( objs[ 3 ] ) = <span></span></div>
47+
<div>jQuery.isFunction( objs[ 4 ] ) = <span></span></div>
48+
]]></html>
4549
</example>
4650
<example>
4751
<desc>Finds out if the parameter is a function.</desc>
48-
<code><![CDATA[$.isFunction(function(){});]]></code>
49-
<results><![CDATA[true]]></results>
52+
<code><![CDATA[
53+
$.isFunction(function(){});
54+
]]></code>
55+
<results><![CDATA[
56+
true
57+
]]></results>
5058
</example>
5159
<category slug="utilities"/>
5260
<category slug="version/1.2"/>
53-
</entry>
61+
</entry>

entries/jQuery.isNumeric.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
<example>
1515
<desc>Sample return values of $.isNumeric with various inputs.</desc>
1616
<code><![CDATA[
17-
$.isNumeric("-10"); // true
18-
$.isNumeric(16); // true
19-
$.isNumeric(0xFF); // true
20-
$.isNumeric("0xFF"); // true
21-
$.isNumeric("8e5"); // true (exponential notation string)
22-
$.isNumeric(3.1415); // true
23-
$.isNumeric(+10); // true
24-
$.isNumeric(0144); // true (octal integer literal)
25-
$.isNumeric(""); // false
26-
$.isNumeric({}); // false (empty object)
27-
$.isNumeric(NaN); // false
28-
$.isNumeric(null); // false
29-
$.isNumeric(true); // false
30-
$.isNumeric(Infinity); // false
31-
$.isNumeric(undefined); // false
17+
$.isNumeric( "-10" ); // true
18+
$.isNumeric( 16 ); // true
19+
$.isNumeric( 0xFF ); // true
20+
$.isNumeric( "0xFF" ); // true
21+
$.isNumeric( "8e5" ); // true (exponential notation string)
22+
$.isNumeric( 3.1415 ); // true
23+
$.isNumeric( +10 ); // true
24+
$.isNumeric( 0144 ); // true (octal integer literal)
25+
$.isNumeric( "" ); // false
26+
$.isNumeric({}); // false (empty object)
27+
$.isNumeric( NaN ); // false
28+
$.isNumeric( null ); // false
29+
$.isNumeric( true ); // false
30+
$.isNumeric( Infinity ); // false
31+
$.isNumeric( undefined ); // false
3232
]]></code>
3333
</example>
3434
<category slug="utilities"/>

entries/jQuery.isPlainObject.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@
1212
<p><strong>Note:</strong> Host objects (or objects used by browser host environments to complete the execution environment of ECMAScript) have a number of inconsistencies which are difficult to robustly feature detect cross-platform. As a result of this, <code>$.isPlainObject()</code> may evaluate inconsistently across browsers in certain instances.</p>
1313
<p>An example of this is a test against <code>document.location</code> using <code>$.isPlainObject()</code> as follows:</p>
1414
<pre><code>
15-
console.log($.isPlainObject(document.location));
16-
</code></pre>
15+
console.log( $.isPlainObject( document.location ) );
16+
</code></pre>
1717
<p>which throws an invalid pointer exception in IE8. With this in mind, it's important to be aware of any of the gotchas involved in using <code>$.isPlainObject()</code> against older browsers. A couple basic examples that do function correctly cross-browser can be found below.</p>
1818
</longdesc>
1919
<example>
2020
<desc>Check an object to see if it's a plain object.</desc>
21-
<code><![CDATA[jQuery.isPlainObject({}) // true
22-
jQuery.isPlainObject("test") // false]]></code>
21+
<code><![CDATA[
22+
jQuery.isPlainObject({}) // true
23+
jQuery.isPlainObject( "test" ) // false
24+
]]></code>
2325
</example>
2426
<category slug="utilities"/>
2527
<category slug="version/1.4"/>

entries/jQuery.isWindow.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
</longdesc>
1414
<example>
1515
<desc>Finds out if the parameter is a window.</desc>
16-
<code><![CDATA[$("b").append( "" + $.isWindow(window) );]]></code>
17-
<html><![CDATA[Is 'window' a window? <b></b>]]></html>
16+
<code><![CDATA[
17+
$( "b" ).append( "" + $.isWindow( window ) );
18+
]]></code>
19+
<html><![CDATA[
20+
Is 'window' a window? <b></b>
21+
]]></html>
1822
</example>
1923
<category slug="utilities"/>
2024
<category slug="version/1.4.3"/>
21-
</entry>
25+
</entry>

entries/jQuery.isXMLDoc.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
<longdesc/>
1212
<example>
1313
<desc>Check an object to see if it's in an XML document.</desc>
14-
<code><![CDATA[jQuery.isXMLDoc(document) // false
15-
jQuery.isXMLDoc(document.body) // false]]></code>
14+
<code><![CDATA[
15+
jQuery.isXMLDoc( document ) // false
16+
jQuery.isXMLDoc( document.body ) // false
17+
]]></code>
1618
</example>
1719
<category slug="utilities"/>
1820
<category slug="version/1.1.4"/>
19-
</entry>
21+
</entry>

entries/jQuery.makeArray.xml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,34 @@
1515
<example>
1616
<desc>Turn a collection of HTMLElements into an Array of them.</desc>
1717
<code><![CDATA[
18-
var elems = document.getElementsByTagName("div"); // returns a nodeList
19-
var arr = jQuery.makeArray(elems);
20-
arr.reverse(); // use an Array method on list of dom elements
21-
$(arr).appendTo(document.body);
18+
var elems = document.getElementsByTagName( "div" ); // Returns a nodeList
19+
var arr = jQuery.makeArray( elems );
20+
arr.reverse(); // Use an Array method on list of dom elements
21+
$( arr ).appendTo( document.body );
2222
]]></code>
2323
<css><![CDATA[
24-
div { color:red; }
25-
]]></css>
26-
<html><![CDATA[<div>First</div>
27-
<div>Second</div>
28-
<div>Third</div>
29-
30-
<div>Fourth</div>]]></html>
24+
div {
25+
color: red;
26+
}
27+
]]></css>
28+
<html><![CDATA[
29+
<div>First</div>
30+
<div>Second</div>
31+
<div>Third</div>
32+
<div>Fourth</div>
33+
]]></html>
3134
</example>
3235
<example>
3336
<desc>Turn a jQuery object into an array</desc>
3437
<code><![CDATA[
35-
var obj = $('li');
36-
var arr = $.makeArray(obj);
38+
var obj = $( "li" );
39+
var arr = $.makeArray( obj );
3740
]]></code>
38-
<results><![CDATA[(typeof obj === 'object' && obj.jquery) === true;
39-
jQuery.isArray(arr) === true;]]></results>
41+
<results><![CDATA[
42+
( typeof obj === "object" && obj.jquery ) === true;
43+
jQuery.isArray( arr ) === true;
44+
]]></results>
4045
</example>
4146
<category slug="utilities"/>
4247
<category slug="version/1.2"/>
43-
</entry>
48+
</entry>

0 commit comments

Comments
 (0)