Skip to content

Commit

Permalink
initial import from wp db
Browse files Browse the repository at this point in the history
  • Loading branch information
kswedberg committed Apr 13, 2012
0 parents commit 2070dff
Show file tree
Hide file tree
Showing 308 changed files with 21,484 additions and 0 deletions.
Empty file added README.md
Empty file.
113 changes: 113 additions & 0 deletions entries/add.xml
@@ -0,0 +1,113 @@
<entry type='method' name="add" return="jQuery">
<signature>
<added>1.0</added>
<argument name="selector" type="Selector">
<desc>A string representing a selector expression to find additional elements to add to the set of matched elements.</desc>
</argument>
</signature>
<signature>
<added>1.0</added>
<argument name="elements" type="Elements">
<desc>One or more elements to add to the set of matched elements.</desc>
</argument>
</signature>
<signature>
<added>1.0</added>
<argument name="html" type="HTML">
<desc>An HTML fragment to add to the set of matched elements.</desc>
</argument>
</signature>
<signature>
<added>1.3.2</added>
<argument name="jQuery object" type="jQuery object ">
<desc>An existing jQuery object to add to the set of matched elements.</desc>
</argument>
</signature>
<signature>
<added>1.4</added>
<argument name="selector" type="Selector">
<desc>A string representing a selector expression to find additional elements to add to the set of matched elements.</desc>
</argument>
<argument name="context" type="Element">
<desc>The point in the document at which the selector should begin matching; similar to the context argument of the <code>$(selector, context)</code> method.</desc>
</argument>
</signature>
<desc>Add elements to the set of matched elements.</desc>
<longdesc><p>Given a jQuery object that represents a set of DOM elements, the <code>.add()</code> method constructs a new jQuery object from the union of those elements and the ones passed into the method. The argument to <code>.add()</code> can be pretty much anything that <code>$()</code> accepts, including a jQuery selector expression, references to DOM elements, or an HTML snippet.</p>
<p>The updated set of elements can be used in a following (chained) method, or assigned to a variable for later use. For example:</p>
<pre>
$("p").add("div").addClass("widget");
var pdiv = $("p").add("div");
</pre>
<p>The following will <em>not</em> save the added elements, because the <code>.add()</code> method creates a new set and leaves the original set in pdiv unchanged:</p>
<pre>
var pdiv = $("p");
pdiv.add("div"); // WRONG, pdiv will not change
</pre>
<p>Consider a page with a simple list and a paragraph following it:</p>
<pre>&lt;ul&gt;
&lt;li&gt;list item 1&lt;/li&gt;
&lt;li&gt;list item 2&lt;/li&gt;
&lt;li&gt;list item 3&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;a paragraph&lt;/p&gt;</pre>
<p>We can select the list items and then the paragraph by using either a selector or a reference to the DOM element itself as the <code>.add()</code> method's argument:</p>
<pre>$('li').add('p').css('background-color', 'red');</pre>
<p>Or:</p>
<pre>$('li').add(document.getElementsByTagName('p')[0])
.css('background-color', 'red');</pre>
<p>The result of this call is a red background behind all four elements.
Using an HTML snippet as the <code>.add()</code> method's argument (as in the third version), we can create additional elements on the fly and add those elements to the matched set of elements. Let's say, for example, that we want to alter the background of the list items along with a newly created paragraph:</p>
<pre>$('li').add('&lt;p id="new"&gt;new paragraph&lt;/p&gt;')
.css('background-color', 'red');</pre>
<p>Although the new paragraph has been created and its background color changed, it still does not appear on the page. To place it on the page, we could add one of the insertion methods to the chain.</p>
<p>As of jQuery 1.4 the results from .add() will always be returned in document order (rather than a simple concatenation).</p>
<p><strong>Note:</strong> To reverse the <code>.add()</code> you can use <a href="http://api.jquery.com/not"><code>.not( elements | selector )</code></a> to remove elements from the jQuery results, or <a href="http://api.jquery.com/end"><code>.end()</code></a> to return to the selection before you added.</p>
</longdesc>
<example>
<desc>Finds all divs and makes a border. Then adds all paragraphs to the jQuery object to set their backgrounds yellow.</desc>
<code><![CDATA[
$("div").css("border", "2px solid red")
.add("p")
.css("background", "yellow");
]]></code>
<css><![CDATA[
div { width:60px; height:60px; margin:10px; float:left; }
p { clear:left; font-weight:bold; font-size:16px;
color:blue; margin:0 10px; padding:2px; }
]]></css>
<html><![CDATA[<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p>Added this... (notice no border)</p>]]></html>
</example>
<example>
<desc>Adds more elements, matched by the given expression, to the set of matched elements.</desc>
<code><![CDATA[$("p").add("span").css("background", "yellow");]]></code>
<html><![CDATA[<p>Hello</p><span>Hello Again</span>]]></html>
</example>
<example>
<desc>Adds more elements, created on the fly, to the set of matched elements.</desc>
<code><![CDATA[$("p").clone().add("<span>Again</span>").appendTo(document.body);]]></code>
<html><![CDATA[<p>Hello</p>]]></html>
</example>
<example>
<desc>Adds one or more Elements to the set of matched elements.</desc>
<code><![CDATA[$("p").add(document.getElementById("a")).css("background", "yellow");]]></code>
<html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
</example>
<example>
<desc>Demonstrates how to add (or push) elements to an existing collection</desc>
<code><![CDATA[var collection = $("p");
// capture the new collection
collection = collection.add(document.getElementById("a"));
collection.css("background", "yellow");]]></code>
<html><![CDATA[<p>Hello</p><span id="a">Hello Again</span>]]></html>
</example>
</entry>
86 changes: 86 additions & 0 deletions entries/addClass.xml
@@ -0,0 +1,86 @@
<entry type='method' name="addClass" return="jQuery">
<signature>
<added>1.0</added>
<argument name="className" type="String">
<desc>One or more class names to be added to the class attribute of each matched element.</desc>
</argument>
</signature>
<signature>
<added>1.4</added>
<argument name="function(index, currentClass)" type="Function">
<desc>A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, <code>this</code> refers to the current element in the set.</desc>
</argument>
</signature>
<desc>Adds the specified class(es) to each of the set of matched elements.</desc>
<longdesc><p>It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.</p>
<p>More than one class may be added at a time, separated by a space, to the set of matched elements, like so:</p>
<pre>$("p").addClass("myClass yourClass");</pre>
<p>This method is often used with <code>.removeClass()</code> to switch elements' classes from one to another, like so:</p>
<pre>$("p").removeClass("myClass noClass").addClass("yourClass");</pre>
<p>Here, the <code>myClass</code> and <code>noClass</code> classes are removed from all paragraphs, while <code>yourClass</code> is added.</p>
<p>As of jQuery 1.4, the <code>.addClass()</code> method's argument can receive a function.</p>
<pre>$("ul li:last").addClass(function(index) {
return "item-" + index;
});</pre>
<p>Given an unordered list with five <code>&lt;li&gt;</code> elements, this example adds the class "item-4" to the last <code>&lt;li&gt;</code>.</p>

</longdesc>
<example>
<desc>Adds the class "selected" to the matched elements.</desc>
<code><![CDATA[
$("p:last").addClass("selected");
]]></code>
<css><![CDATA[
p { margin: 8px; font-size:16px; }
.selected { color:blue; }
.highlight { background:yellow; }
]]></css>
<html><![CDATA[
<p>Hello</p>
<p>and</p>
<p>Goodbye</p>
]]></html>
</example>
<example>
<desc>Adds the classes "selected" and "highlight" to the matched elements.</desc>
<code><![CDATA[
$("p:last").addClass("selected highlight");
]]></code>
<css><![CDATA[
p { margin: 8px; font-size:16px; }
.selected { color:red; }
.highlight { background:yellow; }
]]></css>
<html><![CDATA[<p>Hello</p>
<p>and</p>
<p>Goodbye</p>]]></html>
</example>
<example>
<desc>Pass in a function to <code>.addClass()</code> to add the "green" class to a div that already has a "red" class.</desc>
<code><![CDATA[
$("div").addClass(function(index, currentClass) {
var addedClass;
if ( currentClass === "red" ) {
addedClass = "green";
$("p").text("There is one green div");
}
return addedClass;
});
]]></code>

<css><![CDATA[
div { background: white; }
.red { background: red; }
.red.green { background: green; }
]]></css>
<html><![CDATA[
<div>This div should be white</div>
<div class="red">This div will be green because it now has the "green" and "red" classes.
It would be red if the addClass function failed.</div>
<div>This div should be white</div>
<p>There are zero green divs</p>
]]></html>
</example>
</entry>
102 changes: 102 additions & 0 deletions entries/after.xml
@@ -0,0 +1,102 @@
<entry type='method' name="after" return="jQuery">
<signature>
<added>1.0</added>
<argument name="content" type="String, Element, jQuery">
<desc>HTML string, DOM element, or jQuery object to insert after each element in the set of matched elements.</desc>
</argument>
<argument name="content" type="String, Element, Array, jQuery" optional="true">
<desc>One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements.</desc>
</argument>
</signature>
<signature>
<added>1.4</added>
<argument name="function(index)" type="Function">
<desc>A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, <code>this</code> refers to the current element in the set.</desc>
</argument>
</signature>
<desc>Insert content, specified by the parameter, after each element in the set of matched elements.</desc>
<longdesc><p>The <code>.after()</code> and <code><a href='/insertAfter'>.insertAfter()</a></code> methods perform the same task. The major difference is in the syntax&#8212;specifically, in the placement of the content and target. With<code> .after()</code>, the selector expression preceding the method is the container after which the content is inserted. With <code>.insertAfter()</code>, on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted after the target container.</p>

<p>Using the following HTML:</p>
<pre>&lt;div class="container"&gt;
&lt;h2&gt;Greetings&lt;/h2&gt;
&lt;div class="inner"&gt;Hello&lt;/div&gt;
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
&lt;/div&gt;</pre>

<p>Content can be created and then inserted after several elements at once:</p>

<pre>$('.inner').after('&lt;p&gt;Test&lt;/p&gt;');</pre>

<p>Each inner <code>&lt;div&gt;</code> element gets this new content:</p>

<pre>&lt;div class="container"&gt;
&lt;h2&gt;Greetings&lt;/h2&gt;
&lt;div class="inner"&gt;Hello&lt;/div&gt;
&lt;p&gt;Test&lt;/p&gt;
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
&lt;p&gt;Test&lt;/p&gt;
&lt;/div&gt;</pre>

<p>An element in the DOM can also be selected and inserted after another element:</p>

<pre>$('.container').after($('h2'));</pre>

<p>If an element selected this way is inserted elsewhere, it will be moved rather than cloned:</p>

<pre>&lt;div class="container"&gt;
&lt;div class="inner"&gt;Hello&lt;/div&gt;
&lt;div class="inner"&gt;Goodbye&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;Greetings&lt;/h2&gt;</pre>
<p>If there is more than one target element, however, cloned copies of the inserted element will be created for each target after the first.</p>
<h4 id="disconnected-dom-nodes">Inserting Disconnected DOM nodes</h4>
<p>As of jQuery 1.4, <code>.before()</code> and <code>.after()</code> will also work on disconnected DOM nodes. For example, given the following code:</p>
<pre>$('&lt;div/&gt;').after('&lt;p&gt;&lt;/p&gt;');</pre>
<p>The result is a jQuery set containing a div and a paragraph, in that order. That set can be further manipulated, even before it is inserted in the document.</p>
<pre>$('&lt;div/&gt;').after('&lt;p&gt;&lt;/p&gt;').addClass('foo')
.filter('p').attr('id', 'bar').html('hello')
.end()
.appendTo('body');</pre>
<p>This results in the following elements inserted just before the closing <code>&lt;/body&gt;</code> tag:</p>
<pre>
&lt;div class="foo"&gt;&lt;/div&gt;
&lt;p class="foo" id="bar"&gt;hello&lt;/p&gt;
</pre>
<h4 id="passing-a-function">Passing a Function</h4>
<p>As of jQuery 1.4, <code>.after()</code> supports passing a function that returns the elements to insert.</p>
<pre>$('p').after(function() {
return '&lt;div&gt;' + this.className + '&lt;/div&gt;';
});</pre>
<p>This example inserts a <code>&lt;div&gt;</code> after each paragraph, with each new <code>&lt;div&gt;</code> containing the class name(s) of its preceding paragraph.</p>
<h4 id="additional-arguments">Additional Arguments</h4>
<p>Similar to other content-adding methods such as <code><a href="http://api.jquery.com/prepend/">.prepend()</a></code> and <code><a href="http://api.jquery.com/before/">.before()</a></code>, <code>.after()</code> also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.</p>
<p>For example, the following will insert two new <code>&lt;div&gt;</code>s and an existing <code>&lt;div&gt;</code> after the first paragraph:</p>
<pre>var $newdiv1 = $('&lt;div id="object1"/&gt;'),
newdiv2 = document.createElement('div'),
existingdiv1 = document.getElementById('foo');

$('p').first().after($newdiv1, [newdiv2, existingdiv1]);
</pre>
<p>Since <code>.after()</code> can accept any number of additional arguments, the same result can be achieved by passing in the three <code>&lt;div&gt;</code>s as three separate arguments, like so: <code>$('p').first().after($newdiv1, newdiv2, existingdiv1)</code>. The type and number of arguments will largely depend on the elements that are collected in the code.</p>

</longdesc>
<example>
<desc>Inserts some HTML after all paragraphs.</desc>
<code><![CDATA[$("p").after("<b>Hello</b>");]]></code>
<css><![CDATA[p { background:yellow; }]]></css>
<html><![CDATA[<p>I would like to say: </p>]]></html>
</example>
<example>
<desc>Inserts a DOM element after all paragraphs.</desc>
<code><![CDATA[$("p").after( document.createTextNode("Hello") );]]></code>
<css><![CDATA[p { background:yellow; }]]></css>
<html><![CDATA[<p>I would like to say: </p>]]></html>
</example>
<example>
<desc>Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.</desc>
<code><![CDATA[$("p").after( $("b") );]]></code>
<css><![CDATA[p { background:yellow; }]]></css>
<html><![CDATA[<b>Hello</b><p>I would like to say: </p>]]></html>
</example>
</entry>
44 changes: 44 additions & 0 deletions entries/ajaxComplete.xml
@@ -0,0 +1,44 @@
<entry type='method' name="ajaxComplete" return="jQuery">
<signature>
<added>1.0</added>
<argument name="handler(event, XMLHttpRequest, ajaxOptions)" type="Function">
<desc>The function to be invoked.</desc>
</argument>
</signature>
<desc>Register a handler to be called when Ajax requests complete. This is an <a href='http://docs.jquery.com/Ajax_Events'>Ajax Event</a>.</desc>
<longdesc><p>Whenever an Ajax request completes, jQuery triggers the <code>ajaxComplete</code> event. Any and all handlers that have been registered with the <code>.ajaxComplete()</code> method are executed at this time.</p>
<p>To observe this method in action, we can set up a basic Ajax load request:</p>
<pre>&lt;div class="trigger"&gt;Trigger&lt;/div&gt;
&lt;div class="result"&gt;&lt;/div&gt;
&lt;div class="log"&gt;&lt;/div&gt;
</pre>
<p>We can attach our event handler to any element:</p>
<pre>$('.log').ajaxComplete(function() {
$(this).text('Triggered ajaxComplete handler.');
});
</pre>
<p>Now, we can make an Ajax request using any jQuery method:</p>
<pre>$('.trigger').click(function() {
$('.result').load('ajax/test.html');
});</pre>
<p>When the user clicks the element with class <code>trigger</code> and the Ajax request completes, the log message is displayed.</p>

<p><strong>Note:</strong> Because <code>.ajaxComplete()</code> is implemented as a method of jQuery object instances, we can use the <code>this</code> keyword as we do here to refer to the selected elements within the callback function.</p>

<p>All <code>ajaxComplete</code> handlers are invoked, regardless of what Ajax request was completed. If we must differentiate between the requests, we can use the parameters passed to the handler. Each time an <code>ajaxComplete</code> handler is executed, it is passed the event object, the <code>XMLHttpRequest</code> object, and the settings object that was used in the creation of the request. For example, we can restrict our callback to only handling events dealing with a particular URL:</p>

<p><strong>Note:</strong> You can get the returned ajax contents by looking at <code>xhr.responseXML</code> or <code>xhr.responseHTML</code> for xml and html respectively.</p>

<pre>$('.log').ajaxComplete(function(e, xhr, settings) {
if (settings.url == 'ajax/test.html') {
$(this).text('Triggered ajaxComplete handler. The result is ' +
xhr.responseHTML);
}
});</pre></longdesc>
<example>
<desc>Show a message when an Ajax request completes.</desc>
<code><![CDATA[$("#msg").ajaxComplete(function(event,request, settings){
$(this).append("<li>Request Complete.</li>");
});]]></code>
</example>
</entry>

0 comments on commit 2070dff

Please sign in to comment.