Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add events.js to /resources/ and update script reference in key* entries

Closes #208
  • Loading branch information...
commit a7f305fbaaae69fca654384426c0f331dfe0d0b0 1 parent d7240b8
@kswedberg kswedberg authored
View
2  entries/keydown.xml
@@ -87,7 +87,7 @@ input { display: block; margin-bottom: .25em; }
<button id="other">
Trigger the handler
</button>
-<script type="text/javascript" src="/scripts/events.js"></script>]]></html>
+<script type="text/javascript" src="/resources/events.js"></script>]]></html>
</example>
<category slug="events/keyboard-events"/>
<category slug="version/1.0"/>
View
4 entries/keypress.xml
@@ -52,7 +52,7 @@
<p>Note that <code>keydown</code> and <code>keyup</code> provide a code indicating which key is pressed, while <code>keypress</code> indicates which character was entered. For example, a lowercase "a" will be reported as 65 by <code>keydown</code> and <code>keyup</code>, but as 97 by <code>keypress</code>. An uppercase "A" is reported as 65 by all events. Because of this distinction, when catching special keystrokes such as arrow keys, <code>.keydown()</code> or <code>.keyup()</code> is a better choice.</p>
</longdesc>
<example>
- <desc>Show the event object when a key is pressed in the input. Note: This demo relies on a simple $.print() plugin (http://api.jquery.com/scripts/events.js) for the event object's output.</desc>
+ <desc>Show the event object when a key is pressed in the input. Note: This demo relies on a simple $.print() plugin (http://api.jquery.com/resources/events.js) for the event object's output.</desc>
<code><![CDATA[
var xTriggered = 0;
$("#target").keypress(function(event) {
@@ -92,7 +92,7 @@ input { display: block; margin-bottom: .25em; }
<button id="other">
Trigger the handler
</button>
-<script src="http://api.jquery.com/scripts/events.js"></script>
+<script src="http://api.jquery.com/resources/events.js"></script>
@scottgonzalez Owner

This should be /resources/events.js so it loads the correct script on stage and local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
]]></html>
</example>
<category slug="events/keyboard-events"/>
View
2  entries/keyup.xml
@@ -89,7 +89,7 @@ input { display: block; margin-bottom: .25em; }
<button id="other">
Trigger the handler
</button>
-<script type="text/javascript" src="/scripts/events.js"></script>]]></html>
+<script type="text/javascript" src="/resources/events.js"></script>]]></html>
</example>
<category slug="events/keyboard-events"/>
<category slug="version/1.0"/>
View
31 resources/events.js
@@ -0,0 +1,31 @@
+jQuery.print = function(message, insertionType) {
@scottgonzalez Owner

We should update this file to match our style guide.

@kswedberg Collaborator

agreed. in my haste to fix the problem, I didn't even think of that. will do it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (typeof(message) == 'object') {
+ var string = '{<br />',
+ values = [],
+ counter = 0;
+ $.each(message, function(key, value) {
+ if (value && value.nodeName) {
+ var domnode = '&lt;' + value.nodeName.toLowerCase();
+ domnode += value.className ? ' class="' + value.className + '"' : '';
+ domnode += value.id ? ' id="' + value.id + '"' : '';
+ domnode += '&gt;';
+ value = domnode;
+ }
+ values[counter++] = key + ': ' + value;
+ });
+ string += values.join(',<br />');
+ string += '<br />}';
+ message = string;
+ }
+
+ var $output = $('#print-output');
+
+ if ($output.length === 0) {
+ $output = $('<div id="print-output" />').appendTo('body');
+ }
+
+ var $newMessage = $('<div class="print-output-line" />');
+ $newMessage.html(message);
+ insertionType = insertionType || 'append';
+ $output[insertionType]($newMessage);
+};
Please sign in to comment.
Something went wrong with that request. Please try again.