Permalink
Browse files

Edits for style and consistency. Mostly callbacks entries

  • Loading branch information...
1 parent c8e42e3 commit cd94e7833047eb3868c76086cd616b15511ef59c @kswedberg kswedberg committed Sep 9, 2012
View
@@ -3,45 +3,44 @@
<title>callbacks.add()</title>
<signature>
<added>1.7</added>
- <argument name="callbacks" type="Function">
+ <argument name="callbacks" type="Function, Array">
<desc>A function, or array of functions, that are to be added to the callback list.</desc>
</argument>
</signature>
<desc>Add a callback or a collection of callbacks to a callback list.</desc>
<longdesc>
<p>This method returns the Callbacks object onto which it is attached (<code>this</code>). </p>
<h2 id="example-1">Example</h2>
- <p>Using <code>callbacks.add()</code> to add new callbacks to a callback list:</p>
- <pre><code>
-// a sample logging function to be added to a callbacks list
-var foo = function( value ){
- console.log( 'foo:' + value );
-}
+ <p>Use <code>callbacks.add()</code> to add new callbacks to a callback list:</p>
+ <pre><code><![CDATA[// a sample logging function to be added to a callbacks list
+var foo = function( value ) {
+ console.log( "foo: " + value );
+};
// another function to also be added to the list
var bar = function( value ){
- console.log( 'bar:' + value );
-}
+ console.log( "bar: " + value );
+};
var callbacks = $.Callbacks();
-// add the function 'foo' to the list
+// add the function "foo" to the list
callbacks.add( foo );
// fire the items on the list
-callbacks.fire( 'hello' );
-// outputs: 'foo: hello'
+callbacks.fire( "hello" );
+// outputs: "foo: hello"
-// add the function 'bar' to the list
+// add the function "bar" to the list
callbacks.add( bar );
// fire the items on the list again
-callbacks.fire( 'world' );
+callbacks.fire( "world" );
// outputs:
-// 'foo: world'
-// 'bar: world'
-</code>
+// "foo: world"
+// "bar: world"
+]]></code>
</pre>
</longdesc>
<category slug="callbacks-object"/>
@@ -8,27 +8,28 @@
<longdesc>
<p>This method returns the Callbacks object onto which it is attached (<code>this</code>). </p>
<h2 id="example-1">Example</h2>
- <p>Using <code>callbacks.disable()</code> to disable further calls being made to a callback list:</p>
- <pre><code>
-// a sample logging function to be added to a callbacks list
-var foo = function( value ){
- console.log( value );
-}
+ <p>Use <code>callbacks.disable()</code> to disable further calls to a callback list:</p>
+ <pre><code><![CDATA[// a sample logging function to be added to a callbacks list
+var foo = function( value ) {
+ console.log( value );
+};
var callbacks = $.Callbacks();
// add the above function to the list
callbacks.add( foo );
// fire the items on the list
-callbacks.fire( 'foo' ); // outputs: foo
+callbacks.fire( "foo" );
+// outputs: foo
// disable further calls being possible
callbacks.disable();
-// attempt to fire with 'foobar' as an argument
-callbacks.fire( 'foobar' ); // foobar isn't output
-</code></pre>
+// attempt to fire with "foobar" as an argument
+callbacks.fire( "foobar" );
+// foobar isn't output
+]]></code></pre>
</longdesc>
<category slug="callbacks-object"/>
<category slug="version/1.7"/>
@@ -8,16 +8,15 @@
<longdesc>
<p>This method returns the Callbacks object onto which it is attached (<code>this</code>). </p>
<h2 id="example-1">Example</h2>
- <p>Using <code>callbacks.empty()</code> to empty a list of callbacks:</p>
- <pre><code>
-// a sample logging function to be added to a callbacks list
-var foo = function( value1, value2 ){
- console.log( 'foo:' + value1 + ',' + value2 );
+ <p>Use <code>callbacks.empty()</code> to empty a list of callbacks:</p>
+ <pre><code><![CDATA[// a sample logging function to be added to a callbacks list
+var foo = function( value1, value2 ) {
+ console.log( "foo: " + value1 + "," + value2 );
}
// another function to also be added to the list
var bar = function( value1, value2 ){
- console.log( 'bar:' + value1 + ',' + value2 );
+ console.log( "bar: " + value1 + "," + value2 );
}
var callbacks = $.Callbacks();
@@ -30,9 +29,11 @@ callbacks.add( bar );
callbacks.empty();
// check to ensure all callbacks have been removed
-console.log( callbacks.has( foo ) ); // false
-console.log( callbacks.has( bar ) ); // false
-</code></pre>
+console.log( callbacks.has( foo ) );
+// false
+console.log( callbacks.has( bar ) );
+// false
+]]></code></pre>
</longdesc>
<category slug="callbacks-object"/>
<category slug="version/1.7"/>
View
@@ -3,44 +3,44 @@
<title>callbacks.fire()</title>
<signature>
<added>1.7</added>
- <argument name="arguments" type="">
+ <argument name="arguments" type="Anything">
<desc>The argument or list of arguments to pass back to the callback list.</desc>
</argument>
</signature>
<desc>Call all of the callbacks with the given arguments</desc>
<longdesc>
<p>This method returns the Callbacks object onto which it is attached (<code>this</code>). </p>
<h2 id="example-1">Example</h2>
- <p>Using <code>callbacks.fire()</code> to invoke the callbacks in a list with any arguments that have been passed:</p>
- <pre><code>
+ <p>Use <code>callbacks.fire()</code> to invoke the callbacks in a list with any arguments that have been passed:</p>
+ <pre><code><![CDATA[
// a sample logging function to be added to a callbacks list
-var foo = function( value ){
- console.log( 'foo:' + value );
+var foo = function( value ) {
+ console.log( "foo:" + value );
}
var callbacks = $.Callbacks();
-// add the function 'foo' to the list
+// add the function "foo" to the list
callbacks.add( foo );
// fire the items on the list
-callbacks.fire( 'hello' ); // outputs: 'foo: hello'
-callbacks.fire( 'world '); // outputs: 'foo: world'
+callbacks.fire( "hello" ); // outputs: "foo: hello"
+callbacks.fire( "world" ); // outputs: "foo: world"
// add another function to the list
var bar = function( value ){
- console.log( 'bar:' + value );
+ console.log( "bar:" + value );
}
// add this function to the list
callbacks.add( bar );
// fire the items on the list again
-callbacks.fire( 'hello again' );
+callbacks.fire( "hello again" );
// outputs:
-// 'foo: hello again'
-// 'bar: hello again'
-</code></pre>
+// "foo: hello again"
+// "bar: hello again"
+]]></code></pre>
</longdesc>
<category slug="callbacks-object"/>
<category slug="version/1.7"/>
@@ -14,25 +14,24 @@
<longdesc>
<p>This method returns the Callbacks object onto which it is attached (<code>this</code>). </p>
<h2 id="example-1">Example</h2>
- <p>Using <code>callbacks.fireWith()</code> to fire a list of callbacks with a specific context and an array of arguments:</p>
- <pre><code>
-// a sample logging function to be added to a callbacks list
-var log = function( value1, value2 ){
- console.log( 'Received:' + value1 + ',' + value2 );
-}
+ <p>Use <code>callbacks.fireWith()</code> to fire a list of callbacks with a specific context and an array of arguments:</p>
+ <pre><code><![CDATA[// a sample logging function to be added to a callbacks list
+var log = function( value1, value2 ) {
+ console.log( "Received: " + value1 + "," + value2 );
+};
var callbacks = $.Callbacks();
// add the log method to the callbacks list
callbacks.add( log );
-// fire the callbacks on the list using the context 'window'
+// fire the callbacks on the list using the context "window"
// and an arguments array
-callbacks.fireWith( window, ['foo','bar']);
+callbacks.fireWith( window, ["foo","bar"]);
-// outputs: Received: foo, bar
-</code></pre>
+// outputs: "Received: foo, bar"
+]]></code></pre>
</longdesc>
<category slug="callbacks-object"/>
<category slug="version/1.7"/>
@@ -7,26 +7,25 @@
<desc>Determine if the callbacks have already been called at least once.</desc>
<longdesc>
<h2 id="example-1">Example</h2>
- <p>Using <code>callbacks.fired()</code> to determine if the callbacks in a list have been called at least once:</p>
- <pre><code>
-// a sample logging function to be added to a callbacks list
-var foo = function( value ){
- console.log( 'foo:' + value );
-}
+ <p>Use <code>callbacks.fired()</code> to determine if the callbacks in a list have been called at least once:</p>
+ <pre><code><![CDATA[// a sample logging function to be added to a callbacks list
+var foo = function( value ) {
+ console.log( "foo:" + value );
+};
var callbacks = $.Callbacks();
-// add the function 'foo' to the list
+// add the function "foo" to the list
callbacks.add( foo );
// fire the items on the list
-callbacks.fire( 'hello' ); // outputs: 'foo: hello'
-callbacks.fire( 'world '); // outputs: 'foo: world'
+callbacks.fire( "hello" ); // outputs: "foo: hello"
+callbacks.fire( "world" ); // outputs: "foo: world"
// test to establish if the callbacks have been called
console.log( callbacks.fired() );
-</code></pre>
+]]></code></pre>
</longdesc>
<category slug="callbacks-object"/>
<category slug="version/1.7"/>
-</entry>
+</entry>
View
@@ -10,15 +10,15 @@
<desc>Determine whether a supplied callback is in a list</desc>
<longdesc/>
<example>
- <desc>Using <code>callbacks.has()</code> to check if a callback list contains a specific callback:</desc>
+ <desc>Use <code>callbacks.has()</code> to check if a callback list contains a specific callback:</desc>
<code><![CDATA[// a sample logging function to be added to a callbacks list
-var foo = function( value1, value2 ){
- console.log( 'Received:' + value1 + ',' + value2 );
-}
+var foo = function( value1, value2 ) {
+ console.log( "Received: " + value1 + "," + value2 );
+};
// a second function which will not be added to the list
-var bar = function( value1, value2 ){
- console.log( 'foobar');
+var bar = function( value1, value2 ) {
+ console.log( "foobar" );
}
var callbacks = $.Callbacks();
@@ -28,10 +28,12 @@ callbacks.add( foo );
// determine which callbacks are in the list
-console.log( callbacks.has( foo ) ); // true
-console.log( callbacks.has( bar ) ); // false
+console.log( callbacks.has( foo ) );
+// true
+console.log( callbacks.has( bar ) );
+// false
]]></code>
</example>
<category slug="callbacks-object"/>
<category slug="version/1.7"/>
-</entry>
+</entry>
Oops, something went wrong.

0 comments on commit cd94e78

Please sign in to comment.