Permalink
Browse files

deprecating base.stopEvent() in favor of Event.prototype.stop()

  • Loading branch information...
1 parent 0264ec5 commit ee2335ca3556ff437df5a2bfacf303c590288582 @paularmstrong committed Mar 2, 2009
Showing with 41 additions and 37 deletions.
  1. +30 −28 docs/index.html
  2. +10 −8 source/base.js
  3. +1 −1 source/base.min.js
View
@@ -27,6 +27,7 @@
<li><a href="#Array">Array, NodeList</a></li>
<li><a href="#document">document</a></li>
<li><a href="#Element">Element</a></li>
+ <li><a href="#Event">Event</a></li>
<li><a href="#Function">Function</a></li>
<li><a href="#HTMLElement">HTMLElement</a></li>
<li><a href="#io">io (AJAX)</a></li>
@@ -52,7 +53,6 @@ <h2 id="base">base</h2>
<li><a href="#browser">browser</a></li>
<li><a href="#isArray">isArray()</a></li>
<li><a href="#toQueryString">toQueryString()</a></li>
- <li><a href="#stopEvent">stopEvent()</a></li>
</ul>
<h4 id="extend">extend(destination[, &hellip;], properties)</h4>
@@ -165,32 +165,6 @@ <h4 id="toQueryString">toQueryString(object)</h4>
<pre class="sh_javascript"><p><code>var person = { first_name: 'Paul', last_name: 'Armstrong' };
base.toQueryString(person); // "first_name=Paul&amp;last_name=Armstrong"</code></p></pre>
- <h4 id="stopEvent">stopEvent(event)</h4>
-
- <p>Shortcut to preventDefault and stopPropagation on events.</p>
-
- <table>
- <thead>
- <tr>
- <th scope="col">Parameter</th>
- <th scope="col">Type</th>
- <th scope="col">Description</th>
- <th scope="col">Optional</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th scope="row">event</th>
- <td>Event</td>
- <td>Event to stop</td>
- <td>&times;</td>
- </tr>
- </tbody>
- </table>
-
- <h5>Example</h5>
-
- <pre class="sh_javascript"><p><code>base.stopEvent(event);</code></p></pre>
</div>
<hr />
@@ -407,7 +381,35 @@ <h4 id="Element">Element(type[, atts, content])</h4>
<pre class="sh_javascript"><p><code>new Element('a', { class: 'topLink', href: '#top' }, 'Back to Top');
// Returns the HTMLElement &lt;a class="topLink" href="#top"&gt;Back to Top&lt;/a&gt;</code></p></pre>
- </div>
+ </div>
+
+ <hr />
+
+ <div>
+ <!-- EVENT -->
+ <h2 id="Event">Event</h2>
+
+ <h3>Available Methods and Properties</h3>
+
+ <ul class="methods">
+ <li><a href="#stopEvent">stop()</a></li>
+ </ul>
+
+ <h4 id="stopEvent">stop()</h4>
+
+ <p>Shortcut to preventDefault and stopPropagation on events.</p>
+
+ <h5>Example</h5>
+
+ <pre class="sh_javascript"><p><code>// Stop all links on the page from continuing to their destination href
+$('a').each(function(el) {
+ el.addEventListener('click', function(event) {
+ event.stop();
+ }, true);
+});
+</code></p></pre>
+
+ </div>
<hr />
View
@@ -82,14 +82,6 @@ var base = {
element.dispatchEvent(event);
},
- /**
- * Shortcut to preventDefault and stopPropagation on events.
- * @param e {Event} Event to stop
- */
- stopEvent: function(e) {
- e.preventDefault();
- e.stopPropagation();
- },
selectors: false,
sizzleSrc: '../sizzle/sizzle.js'
};
@@ -366,6 +358,16 @@ base.extend(String.prototype, {
}
});
+base.extend(Event.prototype, {
+ /**
+ * Shortcut to preventDefault and stopPropagation on events.
+ */
+ stop: function() {
+ this.preventDefault();
+ this.stopPropagation();
+ }
+});
+
base.extend(HTMLElement.prototype, {
/**
* Add a className to an element
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit ee2335c

Please sign in to comment.