diff --git a/README.md b/README.md
index 87ab0a3..8e81e5e 100644
--- a/README.md
+++ b/README.md
@@ -1,53 +1,6 @@
#JavaScript Patterns
-
+
-Common JS Patterns based on the ideas of Stoyan Stefanov, Paul Irish, John Resig, Mathias Bynens, Addy Osmani, Dustin Diaz and many others.
+Project page at: http://shichuan.github.io/javascript-patterns
-##Design Patterns
-
-###Creational
-* Abstract factory
-* Builder (added)
-* Factory method (added)
-* Prototype
-* Singleton (added)
-
-###Structural
-* Adapter
-* Bridge
-* Composite
-* Decorator (added)
-* Facade (added)
-* Flyweight
-* Proxy (added)
-
-###Behavioral
-* Chain of responsibility (added)
-* Command (added)
-* Interpreter
-* Iterator (added)
-* Mediator (added)
-* Memento
-* Observer (added)
-* State
-* Strategy (added)
-* Template method
-* Visitor
-
-##Function Patterns
-
-###API patterns
-* Callback patterns
-* Configuration objects
-* Returning functions
-* Currying
-
-###Initialization patterns
-* Immediate functions
-* Immediate object initialization
-* Init-time branching
-
-###Performance patterns
-* Memoization
-* Self-defining functions
\ No newline at end of file
diff --git a/cn/index.html b/cn/index.html
new file mode 100644
index 0000000..cdc6888
--- /dev/null
+++ b/cn/index.html
@@ -0,0 +1,233 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript的模式和反模式集合
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
JavaScript的模式集合
+
+
+
+
+
+
+
+
+ A JavaScript pattern and antipattern code collection that covers function patterns, jQuery patterns, design patterns, general patterns, literals and constructor patterns, object creation patterns (upcoming ), code reuse patterns (upcoming ), DOM and browser patterns (upcoming ).
+ Weekly roundups (pattern updates) will be regularly tweeted .
+
+
+ Function Patterns
+ API Patterns
+
+ Callback patterns - when you pass function A to function B as a parameter, function A is a callback function
+ Configuration objects - keep control of function arguments and makes it easily configurable
+ Returning functions - one function returns another function or create another function on-demand
+ Currying - used to create new functions dynamically by partially applying a set of arguments
+
+
+ Initialization patterns
+
+
+ Performance patterns
+
+ Memoization - use function properties to avoid repeated computation
+ Self-defining functions - self-overwrite with new bodies to do less work from the second invocation and after
+
+
+
+
+ jQuery Patterns
+
+ requery - avoid requery by using jQuery chaining
+ append - use string concatenate and set innerHTML
+ data - pattern and antipattern of using data
+ context and find - use find over context
+ detach - take element off the DOM while manipulating them
+ event delegation - event delegation pattern and antipattern
+ selector cache - using selector cache to avoid requery
+ window scroll event - avoid attaching handlers to the window scroll event
+
+ Selector
+
+
+
+
+ Literals and Constructors Patterns
+
+ Object literal - use the simpler and reliable object literal instead of new Object();
+ Enforcing new - when you forget `new`, `this` inside the constructor will point to the global object
+ Array literal - use array literal notation to avoid potential errors when creating dynamic arrays at runtime
+ Working with JSON - use library from JSON.org, YUI, jQuery instead of eval for parsing
+ Primitive wrappers - try to use the primitive without wrapper
+ Regular expression literal - try to use the shorter literal notation
+
+
+
+
+ Design Patterns
+ Creational
+
+ Builder - constructs complex objects by separating construction and representation
+ Factory method - creates objects without specifying the exact class to create
+ Singleton - restricts object creation for a class to only one instance
+
+ Structural
+
+ Decorator - dynamically adds/overrides behaviour in an existing method of an object
+ Facade - provides a simplified interface to a large body of code
+ Proxy - provides a placeholder for another object to control access, reduce cost, and reduce complexity
+
+ Behavioral
+
+ Chain of responsibility - delegates commands to a chain of processing objects
+ Command - creates objects which encapsulate actions and parameters
+ Iterator - implements a specialized language
+ Mediator - allows loose coupling between classes by being the only class that has detailed knowledge of their methods
+ Observer - is a publish/subscribe pattern which allows a number of observer objects to see an event
+ Strategy - allows one of a family of algorithms to be selected on-the-fly at runtime
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/code-reuse-patterns/borrowing-methods.html b/code-reuse-patterns/borrowing-methods.html
new file mode 100644
index 0000000..90934a6
--- /dev/null
+++ b/code-reuse-patterns/borrowing-methods.html
@@ -0,0 +1,83 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
diff --git a/code-reuse-patterns/cp1-default.html b/code-reuse-patterns/cp1-default.html
new file mode 100644
index 0000000..e16f25f
--- /dev/null
+++ b/code-reuse-patterns/cp1-default.html
@@ -0,0 +1,50 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/cp2-rent-a-constructor.html b/code-reuse-patterns/cp2-rent-a-constructor.html
new file mode 100644
index 0000000..429c14e
--- /dev/null
+++ b/code-reuse-patterns/cp2-rent-a-constructor.html
@@ -0,0 +1,60 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/cp3-rent-and-set-prototype.html b/code-reuse-patterns/cp3-rent-and-set-prototype.html
new file mode 100644
index 0000000..1d71593
--- /dev/null
+++ b/code-reuse-patterns/cp3-rent-and-set-prototype.html
@@ -0,0 +1,45 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/cp4-share-the-prototype.html b/code-reuse-patterns/cp4-share-the-prototype.html
new file mode 100644
index 0000000..93eb152
--- /dev/null
+++ b/code-reuse-patterns/cp4-share-the-prototype.html
@@ -0,0 +1,45 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/cp5-a-temporary-constructor.html b/code-reuse-patterns/cp5-a-temporary-constructor.html
new file mode 100644
index 0000000..86f7397
--- /dev/null
+++ b/code-reuse-patterns/cp5-a-temporary-constructor.html
@@ -0,0 +1,77 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/inheritance-by-copying-properties.html b/code-reuse-patterns/inheritance-by-copying-properties.html
new file mode 100644
index 0000000..6fdb245
--- /dev/null
+++ b/code-reuse-patterns/inheritance-by-copying-properties.html
@@ -0,0 +1,78 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/klass.html b/code-reuse-patterns/klass.html
new file mode 100644
index 0000000..ab91738
--- /dev/null
+++ b/code-reuse-patterns/klass.html
@@ -0,0 +1,151 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
diff --git a/code-reuse-patterns/mix-ins.html b/code-reuse-patterns/mix-ins.html
new file mode 100644
index 0000000..3ef8e98
--- /dev/null
+++ b/code-reuse-patterns/mix-ins.html
@@ -0,0 +1,40 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code-reuse-patterns/prototypal-inheritance.html b/code-reuse-patterns/prototypal-inheritance.html
new file mode 100644
index 0000000..cc070b0
--- /dev/null
+++ b/code-reuse-patterns/prototypal-inheritance.html
@@ -0,0 +1,82 @@
+
+
+
+ JavaScript Patterns
+
+
+
+
+
+
\ No newline at end of file
diff --git a/css/style.css b/css/style.css
new file mode 100644
index 0000000..e9d7625
--- /dev/null
+++ b/css/style.css
@@ -0,0 +1,425 @@
+/*
+ * HTML5 ✰ Boilerplate
+ *
+ * What follows is the result of much research on cross-browser styling.
+ * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
+ * Kroc Camen, and the H5BP dev community and team.
+ *
+ * Detailed information about this CSS: h5bp.com/css
+ *
+ * ==|== normalize ==========================================================
+ */
+
+
+/* =============================================================================
+ HTML5 display definitions
+ ========================================================================== */
+
+article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; }
+audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
+audio:not([controls]) { display: none; }
+[hidden] { display: none; }
+
+
+/* =============================================================================
+ Base
+ ========================================================================== */
+
+/*
+ * 1. Correct text resizing oddly in IE6/7 when body font-size is set using em units
+ * 2. Force vertical scrollbar in non-IE
+ * 3. Prevent iOS text size adjust on device orientation change, without disabling user zoom: h5bp.com/g
+ */
+
+html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
+
+body { margin: 0; font-size: 1em; line-height: 1.4; }
+
+body, button, input, select, textarea { font-family: sans-serif; color: #222; }
+
+/*
+ * Remove text-shadow in selection highlight: h5bp.com/i
+ * These selection declarations have to be separate
+ * Also: hot pink! (or customize the background color to match your design)
+ */
+
+::-moz-selection { background: #fe57a1; color: #fff; text-shadow: none; }
+::selection { background: #fe57a1; color: #fff; text-shadow: none; }
+
+
+/* =============================================================================
+ Links
+ ========================================================================== */
+
+a { color: #06e; }
+a:visited { color: #06e; }
+a:hover { color: #06e; }
+a:focus { outline: thin dotted; }
+
+/* Improve readability when focused and hovered in all browsers: h5bp.com/h */
+a:hover, a:active { outline: 0; }
+
+
+/* =============================================================================
+ Typography
+ ========================================================================== */
+
+abbr[title] { border-bottom: 1px dotted; }
+
+b, strong { font-weight: bold; }
+
+blockquote { margin: 1em 40px; }
+
+dfn { font-style: italic; }
+
+hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }
+
+ins { background: #ff9; color: #000; text-decoration: none; }
+
+mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
+
+/* Redeclare monospace font family: h5bp.com/j */
+pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; }
+
+/* Improve readability of pre-formatted text in all browsers */
+pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
+
+q { quotes: none; }
+q:before, q:after { content: ""; content: none; }
+
+small { font-size: 85%; }
+
+/* Position subscript and superscript content without affecting line-height: h5bp.com/k */
+sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
+sup { top: -0.5em; }
+sub { bottom: -0.25em; }
+
+
+/* =============================================================================
+ Lists
+ ========================================================================== */
+
+ul, ol { margin: 1em 0; padding: 0 0 0 40px; }
+dd { margin: 0 0 0 40px; }
+nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; }
+
+
+/* =============================================================================
+ Embedded content
+ ========================================================================== */
+
+/*
+ * 1. Improve image quality when scaled in IE7: h5bp.com/d
+ * 2. Remove the gap between images and borders on image containers: h5bp.com/e
+ */
+
+img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
+
+/*
+ * Correct overflow not hidden in IE9
+ */
+
+svg:not(:root) { overflow: hidden; }
+
+
+/* =============================================================================
+ Figures
+ ========================================================================== */
+
+figure { margin: 0; }
+
+
+/* =============================================================================
+ Forms
+ ========================================================================== */
+
+form { margin: 0; }
+fieldset { border: 0; margin: 0; padding: 0; }
+
+/* Indicate that 'label' will shift focus to the associated form element */
+label { cursor: pointer; }
+
+/*
+ * 1. Correct color not inheriting in IE6/7/8/9
+ * 2. Correct alignment displayed oddly in IE6/7
+ */
+
+legend { border: 0; *margin-left: -7px; padding: 0; }
+
+/*
+ * 1. Correct font-size not inheriting in all browsers
+ * 2. Remove margins in FF3/4 S5 Chrome
+ * 3. Define consistent vertical alignment display in all browsers
+ */
+
+button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; }
+
+/*
+ * 1. Define line-height as normal to match FF3/4 (set using !important in the UA stylesheet)
+ */
+
+button, input { line-height: normal; }
+
+/*
+ * 1. Display hand cursor for clickable form elements
+ * 2. Allow styling of clickable form elements in iOS
+ * 3. Correct inner spacing displayed oddly in IE7 (doesn't effect IE6)
+ */
+
+button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; }
+
+/*
+ * Consistent box sizing and appearance
+ */
+
+input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; }
+input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }
+input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
+
+/*
+ * Remove inner padding and border in FF3/4: h5bp.com/l
+ */
+
+button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
+
+/*
+ * 1. Remove default vertical scrollbar in IE6/7/8/9
+ * 2. Allow only vertical resizing
+ */
+
+textarea { overflow: auto; vertical-align: top; resize: vertical; }
+
+/* Colors for form validity */
+input:valid, textarea:valid { }
+input:invalid, textarea:invalid { background-color: #f0dddd; }
+
+
+/* =============================================================================
+ Tables
+ ========================================================================== */
+
+table { border-collapse: collapse; border-spacing: 0; }
+td { vertical-align: top; }
+
+
+/* ==|== primary styles =====================================================
+ Author: Shi Chuan
+ ========================================================================== */
+
+.fork img {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+
+html {
+ background:#F8FAF0;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+ font-size: 100%;
+}
+
+body {
+ margin:0 auto;
+ padding: 1em;
+ word-wrap: break-word;
+ word-break: break-word;
+}
+
+header {
+ position: relative;
+ margin-top: 2em;
+ margin-bottom: 1em;
+}
+
+header img {padding-top:5px; border-top:1px solid #ccc; display:block;}
+
+h1, h2, h3 {font-family: 'Tinos', serif; padding:0; margin:0;}
+
+h1 {
+ font-size: 1.6em;
+ float:left;
+ margin-top:7px;
+}
+#btns {float:right; margin-bottom:10px;}
+
+#btns span {display:block; float:left;}
+.st_sharethis {margin-top:2px;}
+h2 {
+ font-size: 1.4em;
+ display:block;
+ padding-bottom:0.5em;
+ border-bottom:1px solid #ccc;
+ margin-bottom:1em;
+ margin-top:1.5em;
+}
+h3 {
+ font-size: 1.2em;
+ color:#555;
+}
+a {
+ text-decoration:none;
+
+}
+
+ul, ul li {
+ list-style:none; margin-left:0; padding-left:10px; color:#444;
+}
+
+ul {
+ margin-bottom:1em;
+}
+
+li {
+ margin-bottom:0.5em;
+}
+
+iframe,
+object,
+embed,
+img {
+ max-width: 100%;
+}
+
+nav {
+ text-align: left;
+ background: #324A69;
+ background: -o-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ background: -webkit-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ background: -moz-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ background: -ms-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ margin: 1em 0;
+}
+
+nav li {
+ color: #fff;
+ list-style-position: inside;
+ list-style-type: disc;
+ border-bottom: solid 1px rgba(255, 255, 255, 0.2);
+ margin: 0;
+}
+
+nav li a:visited,
+nav li a {
+ color: #fff;
+}
+nav li a {
+ font-size: 0.9em;
+ display: block;
+ padding: 0.5em 0.3em;
+}
+
+nav li a:hover {
+ color: #ccc;
+}
+
+nav #toggle-nav {
+ background: none;
+ background: #546377;
+ /*background: -o-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ background: -webkit-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ background: -moz-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));
+ background: -ms-linear-gradient(rgba(50, 74, 105, 0.8), rgba(50, 74, 105, 1));*/
+ border: none;
+ color: #fff;
+ left: 0;
+ height: 40px;
+ position: absolute;
+ bottom: 100%;
+ width: 70px;
+}
+
+nav #toggle-nav:hover {
+ background: #2A3B50;
+ /*background: -webkit-linear-gradient(rgba(69, 105, 151, 0.8), rgba(50, 74, 105, 1));
+ background: -moz-linear-gradient(rgba(69, 105, 151, 0.8), rgba(50, 74, 105, 1));
+ background: -ms-linear-gradient(rgba(69, 105, 151, 0.8), rgba(50, 74, 105, 1));*/
+}
+
+nav #toggle-nav:active {
+ background: #2A3B50;
+}
+
+footer {
+ text-align:center;
+ margin-top:2em;
+ margin-bottom:1em;
+}
+
+
+
+/* ==|== media queries ======================================================
+ PLACEHOLDER Media Queries for Responsive Design.
+ These override the primary ('mobile first') styles
+ Modify as content requires.
+ ========================================================================== */
+@media only screen and (min-width: 48em) {
+ body {
+ max-width: 66%;
+ }
+
+ .sticky {
+ position: fixed;
+ margin: 0;
+ left: 0;
+ top: 3em;
+ width: 16%;
+ z-index: 2;
+ }
+
+ nav.sty {
+ width: 16%;
+ }
+}
+
+
+/* ==|== non-semantic helper classes ========================================
+ Please define your styles before this section.
+ ========================================================================== */
+
+/* For image replacement */
+.ir { display: block; border: 0; text-indent: -999em; overflow: hidden; background-color: transparent; background-repeat: no-repeat; text-align: left; direction: ltr; *line-height: 0; }
+.ir br { display: none; }
+
+/* Hide from both screenreaders and browsers: h5bp.com/u */
+.hidden { display: none !important; visibility: hidden; }
+
+/* Hide only visually, but have it available for screenreaders: h5bp.com/v */
+.visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
+
+/* Extends the .visuallyhidden class to allow the element to be focusable when navigated to via the keyboard: h5bp.com/p */
+.visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; }
+
+/* Hide visually and from screenreaders, but maintain layout */
+.invisible { visibility: hidden; }
+
+/* Contain floats: h5bp.com/q */
+.clearfix:before, .clearfix:after { content: ""; display: table; }
+.clearfix:after { clear: both; }
+.clearfix { *zoom: 1; }
+
+/*@media screen and (min-width: 20em){
+ body {}
+}*/
+
+/* ==|== print styles =======================================================
+ Print styles.
+ Inlined to avoid required HTTP connection: h5bp.com/r
+ ========================================================================== */
+
+@media print {
+ * { background: transparent !important; color: black !important; box-shadow:none !important; text-shadow: none !important; filter:none !important; -ms-filter: none !important; } /* Black prints faster: h5bp.com/s */
+ a, a:visited { text-decoration: underline; }
+ a[href]:after { content: " (" attr(href) ")"; }
+ abbr[title]:after { content: " (" attr(title) ")"; }
+ .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } /* Don't show links for images, or javascript/internal links */
+ pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
+ thead { display: table-header-group; } /* h5bp.com/t */
+ tr, img { page-break-inside: avoid; }
+ img { max-width: 100% !important; }
+ @page { margin: 0.5cm; }
+ p, h2, h3 { orphans: 3; widows: 3; }
+ h2, h3 { page-break-after: avoid; }
+}
\ No newline at end of file
diff --git a/design-patterns/builder.html b/design-patterns/builder.html
index 52a4741..ecaca5b 100644
--- a/design-patterns/builder.html
+++ b/design-patterns/builder.html
@@ -1,33 +1,31 @@
-
-JavaScript Patterns
-
-
-
-Test
-
-
-
\ No newline at end of file
+
+ JavaScript Patterns
+
+
+
+ Test
+
+
+