Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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
Karl Swedberg kswedberg authored
2  entries/keydown.xml
View
@@ -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"/>
4 entries/keypress.xml
View
@@ -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>
Scott González 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"/>
2  entries/keyup.xml
View
@@ -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"/>
31 resources/events.js
View
@@ -0,0 +1,31 @@
+jQuery.print = function(message, insertionType) {
Scott González Owner

We should update this file to match our style guide.

Karl Swedberg 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);
+};
Scott González

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

Scott González

We should update this file to match our style guide.

Karl Swedberg
Collaborator

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

Please sign in to comment.
Something went wrong with that request. Please try again.