Skip to content
Browse files

dom example

  • Loading branch information...
1 parent 83b98f3 commit 682bd1177e944ccf6c39f4ddc97f3e0cad97eeaf Keith Donald committed Oct 26, 2011
Showing with 9,337 additions and 0 deletions.
  1. +5 −0 dom/dom.js
  2. +11 −0 dom/index.html
  3. +8 −0 dom/main.js
  4. +19 −0 key-concepts/notes-about-new.js
  5. +15 −0 key-concepts/notes-about-this.js
  6. +9,279 −0 lib/jquery-1.7b2/jquery.js
View
5 dom/dom.js
@@ -0,0 +1,5 @@
+define(["jquery"], function($) {
+ $("p").on("click", function() {
+ console.log("p clicked");
+ });
+});
View
11 dom/index.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>DOM (jQuery)</title>
+</head>
+<body>
+ <p>This is a paragraph. Click me to fire an attached event handler.</p>
+ <script data-main="main.js" src="../lib/requirejs-1.0.0/require.js"></script>
+</body>
+</html>
View
8 dom/main.js
@@ -0,0 +1,8 @@
+require.config({
+ paths: {
+ jquery: "../lib/jquery-1.7b2/jquery"
+ }
+});
+require(["dom"], function() {
+
+});
View
19 key-concepts/notes-about-new.js
@@ -0,0 +1,19 @@
+var User = function(name) {
+ this.name = name;
+}
+User.prototype.awesome = true;
+
+var keith = new User("keith");
+var roy = new User("roy");
+console.log(keith);
+console.log(roy);
+
+// new operator psudocode
+function psudoNew(initializer, args) {
+ var obj = Object.create(initializer.prototype);
+ initializer.apply(obj, args);
+ return obj;
+}
+var craig = psudoNew(User, ["craig"]);
+
+console.log(craig);
View
15 key-concepts/notes-about-this.js
@@ -0,0 +1,15 @@
+var fx = function() {
+ console.log("fx function invoked");
+ console.log(this);
+}
+fx(); // this === window
+
+var obj = { name: "keith" };
+obj.property = fx;
+obj.property(); // this === obj
+
+// jQuery(“#myDiv”).click(fx); // on click, this === myDiv
+
+// key Function primitives - ‘obj’ becomes ‘this’ when ‘fx’ is invoked
+fx.call(obj, "arg1", "arg2", "...");
+fx.apply(obj, ["arg1", "arg2", "..."]);
View
9,279 lib/jquery-1.7b2/jquery.js
9,279 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 682bd11

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