[Pkg-javascript-commits] [backbone] 72/74: tweaking annotated source.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.3.0
in repository backbone.

commit 46d196d1c0f531c375b611236f83f64f501e10b5
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Tue Nov 9 13:25:52 2010 -0500

    tweaking annotated source.
---
 backbone.js        | 21 ++++++++++++---------
 docs/backbone.html | 21 ++++++++++++---------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/backbone.js b/backbone.js
index 379e857..083d3da 100644
--- a/backbone.js
+++ b/backbone.js
@@ -588,7 +588,7 @@
 
     // Manually bind a single named route to a callback. For example:
     //
-    //     this.route('search/:query/p:page', 'search', function(query, page) {
+    //     this.route('search/:query/p:num', 'search', function(query, num) {
     //       ...
     //     });
     //
@@ -602,7 +602,8 @@
       }, this));
     },
 
-    // Simply proxy to `Backbone.history` to save a fragment into the history.
+    // Simple proxy to `Backbone.history` to save a fragment into the history,
+    // without triggering routes.
     saveLocation : function(fragment) {
       Backbone.history.saveLocation(fragment);
     },
@@ -617,7 +618,7 @@
     },
 
     // Convert a route string into a regular expression, suitable for matching
-    // against the current hash state.
+    // against the current location fragment.
     _routeToRegExp : function(route) {
       route = route.replace(namedParam, "([^\/]*)").replace(splatParam, "(.*?)");
       return new RegExp('^' + route + '$');
@@ -648,7 +649,8 @@
   // Set up all inheritable **Backbone.History** properties and methods.
   _.extend(Backbone.History.prototype, {
 
-    // The default interval to poll for hash changes in IE is twenty times a second.
+    // The default interval to poll for hash changes, if necessary, is
+    // twenty times a second.
     interval: 50,
 
     // Get the cross-browser normalized URL fragment.
@@ -656,8 +658,8 @@
       return (loc || window.location).hash.replace(hashStrip, '');
     },
 
-    // Start the hash change handling, returning true if the current URL matches
-    // an existing route, and false otherwise.
+    // Start the hash change handling, returning `true` if the current URL matches
+    // an existing route, and `false` otherwise.
     start : function() {
       var docMode = document.documentMode;
       var oldIE = ($.browser.msie && docMode < 7);
@@ -679,7 +681,7 @@
     },
 
     // Checks the current URL to see if it has changed, and if it has,
-    // calls `loadUrl`.
+    // calls `loadUrl`, normalizing across the hidden iframe.
     checkUrl : function() {
       var current = this.getFragment();
       if (current == this.fragment && this.iframe) {
@@ -694,8 +696,9 @@
       this.loadUrl();
     },
 
-    // Attempt to load the current URL fragment. If no defined route matches
-    // the fragment, returns `false`.
+    // Attempt to load the current URL fragment. If a route succeeds with a
+    // match, returns `true`. If no defined routes matches the fragment,
+    // returns `false`.
     loadUrl : function() {
       var fragment = this.fragment = this.getFragment();
       var matched = _.any(this.handlers, function(handler) {
diff --git a/docs/backbone.html b/docs/backbone.html
index b57511e..3787579 100644
--- a/docs/backbone.html
+++ b/docs/backbone.html
@@ -375,7 +375,7 @@ matched. Creating a new one sets its <code>routes</code> hash, if not set static
 parts of route strings.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">namedParam</span> <span class="o">=</span> <span class="sr">/:([\w\d]+)/g</span><span class="p">;</span>
   <span class="kd">var</span> <span class="nx">splatParam</span> <span class="o">=</span> <span class="sr">/\*([\w\d]+)/g</span><span class="p">;</span></pre></div>             </td>           </tr>                               <tr id="section-71">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-71">¶</a>               </div>               <p>Set up all inheritable <strong>Backbone.Controller</strong> properties an [...]
 
-<pre><code>this.route('search/:query/p:page', 'search', function(query, page) {
+<pre><code>this.route('search/:query/p:num', 'search', function(query, num) {
   ...
 });
 </code></pre>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">route</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">route</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
@@ -386,7 +386,8 @@ parts of route strings.</p>             </td>             <td class="code">
         <span class="nx">callback</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span>
         <span class="k">this</span><span class="p">.</span><span class="nx">trigger</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="p">[</span><span class="s1">'route:'</span> <span class="o">+</span> <span class="nx">name</span><span class="p">].</span><span class="nx">concat</span><span class="p">(</span><span class="nx">args</span><span class="p">));</span>
       <span class="p">},</span> <span class="k">this</span><span class="p">));</span>
-    <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-73">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-73">¶</a>               </div>               <p>Simply proxy to <code>Backbone.history</code> to save a fragment into the history.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx [...]
+    <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-73">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-73">¶</a>               </div>               <p>Simple proxy to <code>Backbone.history</code> to save a fragment into the history,
+without triggering routes.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">saveLocation</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">fragment</span><span class="p">)</span> <span class="p">{</span>
       <span class="nx">Backbone</span><span class="p">.</span><span class="nx">history</span><span class="p">.</span><span class="nx">saveLocation</span><span class="p">(</span><span class="nx">fragment</span><span class="p">);</span>
     <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-74">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-74">¶</a>               </div>               <p>Bind all defined routes to <code>Backbone.history</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">_bindRoutes</span> <spa [...]
       <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">routes</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span>
@@ -395,7 +396,7 @@ parts of route strings.</p>             </td>             <td class="code">
         <span class="k">this</span><span class="p">.</span><span class="nx">route</span><span class="p">(</span><span class="nx">route</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="k">this</span><span class="p">[</span><span class="nx">name</span><span class="p">]);</span>
       <span class="p">}</span>
     <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-75">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-75">¶</a>               </div>               <p>Convert a route string into a regular expression, suitable for matching
-against the current hash state.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">_routeToRegExp</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">route</span><span class="p">)</span> <span class="p">{</span>
+against the current location fragment.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">_routeToRegExp</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">route</span><span class="p">)</span> <span class="p">{</span>
       <span class="nx">route</span> <span class="o">=</span> <span class="nx">route</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">namedParam</span><span class="p">,</span> <span class="s2">"([^\/]*)"</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="nx">splatParam</span><span class="p">,</span> <span class="s2">"(.*?)"</span><span class="p">);</span>
       <span class="k">return</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s1">'^'</span> <span class="o">+</span> <span class="nx">route</span> <span class="o">+</span> <span class="s1">'$'</span><span class="p">);</span>
     <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-76">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-76">¶</a>               </div>               <p>Given a route, and a URL fragment that it matches, return the array of
@@ -408,10 +409,11 @@ browser does not support <code>onhashchange</code>, falls back to polling.</p>
     <span class="k">this</span><span class="p">.</span><span class="nx">handlers</span> <span class="o">=</span> <span class="p">[];</span>
     <span class="k">this</span><span class="p">.</span><span class="nx">fragment</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getFragment</span><span class="p">();</span>
     <span class="nx">_</span><span class="p">.</span><span class="nx">bindAll</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">'checkUrl'</span><span class="p">);</span>
-  <span class="p">};</span></pre></div>             </td>           </tr>                               <tr id="section-79">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-79">¶</a>               </div>               <p>Cached regex for cleaning hashes.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">hashStrip</span> <span  [...]
+  <span class="p">};</span></pre></div>             </td>           </tr>                               <tr id="section-79">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-79">¶</a>               </div>               <p>Cached regex for cleaning hashes.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">hashStrip</span> <span  [...]
+twenty times a second.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">interval</span><span class="o">:</span> <span class="mi">50</span><span class="p">,</span></pre></div>             </td>           </tr>                               <tr id="section-82">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-82">¶</a>               </div>                [...]
       <span class="k">return</span> <span class="p">(</span><span class="nx">loc</span> <span class="o">||</span> <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">).</span><span class="nx">hash</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">hashStrip</span><span class="p">,</span> <span class="s1">''</span><span class="p">);</span>
-    <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-83">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-83">¶</a>               </div>               <p>Start the hash change handling, returning true if the current URL matches
-an existing route, and false otherwise.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">start</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+    <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-83">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-83">¶</a>               </div>               <p>Start the hash change handling, returning <code>true</code> if the current URL matches
+an existing route, and <code>false</code> otherwise.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">start</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
       <span class="kd">var</span> <span class="nx">docMode</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">documentMode</span><span class="p">;</span>
       <span class="kd">var</span> <span class="nx">oldIE</span> <span class="o">=</span> <span class="p">(</span><span class="nx">$</span><span class="p">.</span><span class="nx">browser</span><span class="p">.</span><span class="nx">msie</span> <span class="o">&&</span> <span class="nx">docMode</span> <span class="o"><</span> <span class="mi">7</span><span class="p">);</span>
       <span class="k">if</span> <span class="p">(</span><span class="nx">oldIE</span><span class="p">)</span> <span class="p">{</span>
@@ -427,7 +429,7 @@ an existing route, and false otherwise.</p>             </td>             <td cl
 order they are added.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">route</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">route</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
       <span class="k">this</span><span class="p">.</span><span class="nx">handlers</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span><span class="nx">route</span> <span class="o">:</span> <span class="nx">route</span><span class="p">,</span> <span class="nx">callback</span> <span class="o">:</span> <span class="nx">callback</span><span class="p">});</span>
     <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-85">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-85">¶</a>               </div>               <p>Checks the current URL to see if it has changed, and if it has,
-calls <code>loadUrl</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">checkUrl</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+calls <code>loadUrl</code>, normalizing across the hidden iframe.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">checkUrl</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
       <span class="kd">var</span> <span class="nx">current</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getFragment</span><span class="p">();</span>
       <span class="k">if</span> <span class="p">(</span><span class="nx">current</span> <span class="o">==</span> <span class="k">this</span><span class="p">.</span><span class="nx">fragment</span> <span class="o">&&</span> <span class="k">this</span><span class="p">.</span><span class="nx">iframe</span><span class="p">)</span> <span class="p">{</span>
         <span class="nx">current</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getFragment</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">iframe</span><span class="p">.</span><span class="nx">location</span><span class="p">);</span>
@@ -439,8 +441,9 @@ calls <code>loadUrl</code>.</p>             </td>             <td class="code">
         <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">hash</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">iframe</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">hash</span> <span class="o">=</span> <span class="nx">current</span><span class="p">;</span>
       <span class="p">}</span>
       <span class="k">this</span><span class="p">.</span><span class="nx">loadUrl</span><span class="p">();</span>
-    <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-86">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-86">¶</a>               </div>               <p>Attempt to load the current URL fragment. If no defined route matches
-the fragment, returns <code>false</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">loadUrl</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+    <span class="p">},</span></pre></div>             </td>           </tr>                               <tr id="section-86">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-86">¶</a>               </div>               <p>Attempt to load the current URL fragment. If a route succeeds with a
+match, returns <code>true</code>. If no defined routes matches the fragment,
+returns <code>false</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">loadUrl</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
       <span class="kd">var</span> <span class="nx">fragment</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">fragment</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getFragment</span><span class="p">();</span>
       <span class="kd">var</span> <span class="nx">matched</span> <span class="o">=</span> <span class="nx">_</span><span class="p">.</span><span class="nx">any</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">handlers</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">handler</span><span class="p">)</span> <span class="p">{</span>
         <span class="k">if</span> <span class="p">(</span><span class="nx">handler</span><span class="p">.</span><span class="nx">route</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">fragment</span><span class="p">))</span> <span class="p">{</span>

-- 
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