[Pkg-javascript-commits] [backbone] 43/101: more comments, more docs
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:27 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.1.0
in repository backbone.
commit 2081bbf3316cc6826616e8eca6cc044d029914c5
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Wed Oct 6 14:48:01 2010 -0400
more comments, more docs
---
backbone.js | 25 ++++++++++++++++---------
docs/backbone.html | 33 ++++++++++++++++++++++-----------
2 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/backbone.js b/backbone.js
index c411310..4aeb267 100644
--- a/backbone.js
+++ b/backbone.js
@@ -1,7 +1,7 @@
-// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
-// Backbone may be freely distributed under the terms of the MIT license.
-// For all details and documentation:
-// http://documentcloud.github.com/backbone
+// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
+// Backbone may be freely distributed under the terms of the MIT license.
+// For all details and documentation:
+// http://documentcloud.github.com/backbone
(function(){
@@ -39,9 +39,9 @@
// custom events. You may `bind` or `unbind` a callback function to an event;
// `trigger`-ing an event fires all callbacks in succession.
//
- // _.extend(object, Backbone.Bindable);
- // object.bind('expand', function(){ alert('expanded'); });
- // object.trigger('expand');
+ // _.extend(object, Backbone.Bindable);
+ // object.bind('expand', function(){ alert('expanded'); });
+ // object.trigger('expand');
//
Backbone.Bindable = {
@@ -507,7 +507,7 @@
// For small amounts of DOM Elements, where a full-blown template isn't
// needed, use **make** to manufacture elements, one at a time.
//
- // var el = this.make('li', {'class': 'row'}, this.model.get('title'));
+ // var el = this.make('li', {'class': 'row'}, this.model.get('title'));
//
make : function(tagName, attributes, content) {
var el = document.createElement(tagName);
@@ -528,7 +528,14 @@
},
// Set callbacks, where this.callbacks is a hash of
- // {selector.event_name, callback_name}
+ //
+ // *{selector.event_name: callback_name}*
+ //
+ // {
+ // '.icon.pencil.mousedown': 'edit',
+ // '.button.click': 'save'
+ // }
+ //
// pairs. Callbacks will be bound to the view, with `this` set properly.
// Uses jQuery event delegation for efficiency.
// Passing a selector of `el` binds to the view's root element.
diff --git a/docs/backbone.html b/docs/backbone.html
index 2b94b02..4974c9d 100644
--- a/docs/backbone.html
+++ b/docs/backbone.html
@@ -1,7 +1,8 @@
-<!DOCTYPE html> <html> <head> <title>backbone.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> backbone.js </h1> </th> <th class="code"> </th> </ [...]
- Backbone may be freely distributed under the terms of the MIT license.
- For all details and documentation:
- http://documentcloud.github.com/backbone</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <h2>Initia [...]
+<!DOCTYPE html> <html> <head> <title>backbone.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> backbone.js </h1> </th> <th class="code"> </th> </ [...]
+Backbone may be freely distributed under the terms of the MIT license.
+For all details and documentation:
+http://documentcloud.github.com/backbone
+</code></pre> </td> <td class="code"> <div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <h2>Initial Setup</h2> </td> [...]
Similar to <code>goog.inherits</code>, but uses a hash of prototype properties and
static properties to be extended.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">inherits</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">parent</span><span class="p">,</span> <span class="nx">protoProps</span><span class="p">,</span> <span class="nx">classProps</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">child</span> <span class="o">=</span> <span class="nx">protoProps</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="s1">'constructor'</span><span class="p">)</span> <span class="o">?</span> <span class="nx">protoProps</span><span class="p">.</span><span class="nx">constructor</span> <span class="o">:</span>
@@ -17,9 +18,10 @@ static properties to be extended.</p> </td> <td class="c
custom events. You may <code>bind</code> or <code>unbind</code> a callback function to an event;
<code>trigger</code>-ing an event fires all callbacks in succession.</p>
-<p>_.extend(object, Backbone.Bindable);
- object.bind('expand', function(){ alert('expanded'); });
- object.trigger('expand');</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">Backbone</span><span class="p">.</span><span class="nx">Bindable</span> <span class="o">=</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">¶</a> [...]
+<pre><code>_.extend(object, Backbone.Bindable);
+object.bind('expand', function(){ alert('expanded'); });
+object.trigger('expand');
+</code></pre> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">Backbone</span><span class="p">.</span><span class="nx">Bindable</span> <span class="o">=</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">¶</a> </div> [...]
Passing <code>"all"</code> will bind the callback to all events fired.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">bind</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">calls</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span> <span class="o">||</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span> <span class="o">=</span> <span class="p">{});</span>
<span class="kd">var</span> <span class="nx">list</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span><span class="p">[</span><span class="nx">ev</span><span class="p">]</span> <span class="o">||</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span><span class="p">[</span><span class="nx">ev</span><span class="p">]</span> <span class="o">=</span> <span cl [...]
@@ -322,7 +324,8 @@ convention is for <strong>render</strong> to always return <code>this</code>.</p
<span class="p">},</span></pre></div> </td> </tr> <tr id="section-62"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-62">¶</a> </div> <p>For small amounts of DOM Elements, where a full-blown template isn't
needed, use <strong>make</strong> to manufacture elements, one at a time.</p>
-<p>var el = this.make('li', {'class': 'row'}, this.model.get('title'));</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">make</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">tagName</span><span class="p">,</span> <span class="nx">attributes</span><span class="p">,</span> <span class="nx">content</span><span class="p">)</span> <span class="p">{</span>
+<pre><code>var el = this.make('li', {'class': 'row'}, this.model.get('title'));
+</code></pre> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">make</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">tagName</span><span class="p">,</span> <span class="nx">attributes</span><span class="p">,</span> <span class="nx">content</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="nx">tagName</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">attributes</span><span class="p">)</span> <span class="nx">$</span><span class="p">(</span><span class="nx">el</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="nx">attributes</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">content</span><span class="p">)</span> <span class="nx">$</span><span class="p">(</span><span class="nx">el</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="nx">content</span><span class="p">);</span>
@@ -335,9 +338,17 @@ and behavior.</p> </td> <td class="code">
<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">modes</span><span class="p">[</span><span class="nx">group</span><span class="p">]</span> <span class="o">==</span> <span class="nx">mode</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">el</span><span class="p">).</span><span class="nx">setMode</span><span class="p">(</span><span class="nx">mode</span><span class="p">,</span> <span class="nx">group</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">modes</span><span class="p">[</span><span class="nx">group</span><span class="p">]</span> <span class="o">=</span> <span class="nx">mode</span><span class="p">;</span>
- <span class="p">},</span></pre></div> </td> </tr> <tr id="section-64"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-64">¶</a> </div> <p>Set callbacks, where this.callbacks is a hash of
- {selector.event<em>name, callback</em>name}
-pairs. Callbacks will be bound to the view, with <code>this</code> set properly.
+ <span class="p">},</span></pre></div> </td> </tr> <tr id="section-64"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-64">¶</a> </div> <p>Set callbacks, where this.callbacks is a hash of</p>
+
+<p><em>{selector.event_name: callback_name}</em></p>
+
+<pre><code>{
+ '.icon.pencil.mousedown': 'edit',
+ '.button.click': 'save'
+}
+</code></pre>
+
+<p>pairs. Callbacks will be bound to the view, with <code>this</code> set properly.
Uses jQuery event delegation for efficiency.
Passing a selector of <code>el</code> binds to the view's root element.
Change events are not delegated through the view because IE does not
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list