zurb-foundation 3.2.5 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/.gitignore +6 -2
  2. data/CHANGELOG.md +1 -26
  3. data/CONTRIBUTING.md +18 -0
  4. data/Gemfile.lock +19 -0
  5. data/Gruntfile.js +27 -0
  6. data/README.md +5 -6
  7. data/{Capfile → docs/Capfile} +0 -1
  8. data/docs/Gemfile +8 -0
  9. data/docs/Gemfile.lock +43 -0
  10. data/docs/Procfile +2 -0
  11. data/docs/README.md +1 -0
  12. data/docs/_sidebar-components.html.erb +109 -0
  13. data/docs/_sidebar.html.erb +109 -0
  14. data/docs/_zurb-jobs.html.erb +5 -0
  15. data/docs/changelog.html.erb +185 -0
  16. data/docs/compile.rb +43 -0
  17. data/docs/components/alert-boxes.html.erb +202 -0
  18. data/docs/components/block-grid.html.erb +118 -0
  19. data/docs/components/breadcrumbs.html.erb +146 -0
  20. data/docs/components/button-groups.html.erb +174 -0
  21. data/docs/components/buttons.html.erb +220 -0
  22. data/docs/components/clearing.html.erb +152 -0
  23. data/docs/components/custom-forms.html.erb +306 -0
  24. data/docs/components/dropdown-buttons.html.erb +233 -0
  25. data/docs/components/dropdown.html.erb +186 -0
  26. data/docs/components/flex-video.html.erb +93 -0
  27. data/docs/components/forms.html.erb +468 -0
  28. data/docs/components/grid.html.erb +355 -0
  29. data/docs/components/inline-lists.html.erb +89 -0
  30. data/docs/components/joyride.html.erb +178 -0
  31. data/docs/components/keystrokes.html.erb +74 -0
  32. data/docs/components/labels.html.erb +98 -0
  33. data/docs/components/magellan.html.erb +84 -0
  34. data/docs/components/orbit.html.erb +262 -0
  35. data/docs/components/pagination.html.erb +181 -0
  36. data/docs/components/panels.html.erb +121 -0
  37. data/docs/components/pricing-tables.html.erb +154 -0
  38. data/docs/components/progress-bars.html.erb +120 -0
  39. data/docs/components/reveal.html.erb +147 -0
  40. data/docs/components/section.html.erb +156 -0
  41. data/docs/components/side-nav.html.erb +122 -0
  42. data/docs/components/split-buttons.html.erb +218 -0
  43. data/docs/components/sub-nav.html.erb +120 -0
  44. data/docs/components/switch.html.erb +288 -0
  45. data/docs/components/tables.html.erb +123 -0
  46. data/docs/components/thumbnails.html.erb +87 -0
  47. data/docs/components/tooltips.html.erb +73 -0
  48. data/docs/components/top-bar.html.erb +219 -0
  49. data/docs/components/type.html.erb +359 -0
  50. data/docs/components/visibility.html.erb +102 -0
  51. data/docs/config.ru +12 -0
  52. data/docs/config/deploy.rb +33 -0
  53. data/docs/controller.rb +43 -0
  54. data/docs/css/_coderay.scss +116 -0
  55. data/docs/css/_settings.scss +1 -0
  56. data/docs/css/docs.scss +174 -0
  57. data/docs/css/normalize.scss +396 -0
  58. data/docs/css/qunit-composite.css +13 -0
  59. data/docs/css/qunit.css +235 -0
  60. data/docs/faq.html.erb +61 -0
  61. data/docs/img/demos/demo1-th.png +0 -0
  62. data/docs/img/demos/demo1.png +0 -0
  63. data/docs/img/demos/demo2-th.png +0 -0
  64. data/docs/img/demos/demo2.png +0 -0
  65. data/docs/img/demos/demo3-th.png +0 -0
  66. data/docs/img/demos/demo3.png +0 -0
  67. data/docs/img/demos/demo4-th.png +0 -0
  68. data/docs/img/demos/demo4.png +0 -0
  69. data/docs/img/demos/demo5-th.png +0 -0
  70. data/docs/img/demos/demo5.png +0 -0
  71. data/docs/index.html.erb +299 -0
  72. data/docs/javascript.html.erb +133 -0
  73. data/docs/js/docs.js +3 -0
  74. data/docs/js/qunit-composite.js +105 -0
  75. data/docs/js/qunit.js +1977 -0
  76. data/docs/js/tests/tabs/simple_tabs.html +57 -0
  77. data/docs/js/tests/tabs/simple_tabs.js +54 -0
  78. data/docs/js/tests/tooltips/tooltips.html +39 -0
  79. data/docs/js/tests/tooltips/tooltips.js +11 -0
  80. data/docs/layout.html.erb +99 -0
  81. data/docs/rails.html.erb +66 -0
  82. data/docs/sass.html.erb +299 -0
  83. data/docs/support.html.erb +134 -0
  84. data/foundation.gemspec +2 -4
  85. data/index.html +3 -23
  86. data/js/foundation/foundation.alerts.js +50 -0
  87. data/js/foundation/foundation.clearing.js +478 -0
  88. data/{vendor/assets/javascripts/foundation/jquery.cookie.js → js/foundation/foundation.cookie.js} +3 -1
  89. data/js/foundation/foundation.dropdown.js +122 -0
  90. data/js/foundation/foundation.forms.js +403 -0
  91. data/js/foundation/foundation.joyride.js +613 -0
  92. data/js/foundation/foundation.js +331 -0
  93. data/js/foundation/foundation.magellan.js +130 -0
  94. data/js/foundation/foundation.orbit.js +355 -0
  95. data/{vendor/assets/javascripts/foundation/jquery.placeholder.js → js/foundation/foundation.placeholder.js} +4 -2
  96. data/js/foundation/foundation.reveal.js +264 -0
  97. data/js/foundation/foundation.section.js +180 -0
  98. data/js/foundation/foundation.tooltips.js +195 -0
  99. data/js/foundation/foundation.topbar.js +187 -0
  100. data/js/foundation/index.js +16 -0
  101. data/{vendor/assets/javascripts/foundation/modernizr.foundation.js → js/vendor/custom.modernizr.js} +0 -0
  102. data/js/vendor/jquery.js +9597 -0
  103. data/js/vendor/zepto.js +1782 -0
  104. data/lib/foundation/engine.rb +8 -1
  105. data/lib/foundation/generators/install_generator.rb +24 -1
  106. data/lib/foundation/generators/templates/application.html.erb +20 -6
  107. data/lib/foundation/generators/templates/application.html.haml +2 -6
  108. data/lib/foundation/generators/templates/application.html.slim +2 -5
  109. data/lib/foundation/version.rb +1 -1
  110. data/lib/zurb-foundation.rb +7 -9
  111. data/package.json +9 -0
  112. data/scss/foundation.scss +42 -15
  113. data/scss/foundation/_foundation-global.scss +226 -0
  114. data/scss/foundation/components/_alert-boxes.scss +106 -0
  115. data/scss/foundation/components/_block-grid.scss +63 -0
  116. data/scss/foundation/components/_breadcrumbs.scss +117 -0
  117. data/scss/foundation/components/_button-groups.scss +59 -0
  118. data/scss/foundation/components/_buttons.scss +217 -0
  119. data/scss/foundation/components/_clearing.scss +209 -0
  120. data/scss/foundation/components/_custom-forms.scss +232 -0
  121. data/scss/foundation/components/_dropdown-buttons.scss +114 -0
  122. data/scss/foundation/components/_dropdown.scss +137 -0
  123. data/scss/foundation/components/_flex-video.scss +45 -0
  124. data/scss/foundation/components/_forms.scss +309 -0
  125. data/scss/foundation/components/_grid.scss +149 -71
  126. data/scss/foundation/components/_inline-lists.scss +47 -0
  127. data/scss/foundation/components/_joyride.scss +193 -0
  128. data/scss/foundation/components/_keystrokes.scss +56 -0
  129. data/scss/foundation/components/_labels.scss +81 -0
  130. data/scss/foundation/components/_magellan.scss +15 -0
  131. data/scss/foundation/components/_orbit.scss +193 -0
  132. data/scss/foundation/components/_pagination.scss +99 -0
  133. data/scss/foundation/components/_panels.scss +76 -0
  134. data/scss/foundation/components/_pricing-tables.scss +130 -0
  135. data/scss/foundation/components/_progress-bars.scss +68 -0
  136. data/scss/foundation/components/_reveal.scss +131 -0
  137. data/scss/foundation/components/_section.scss +194 -0
  138. data/scss/foundation/components/_side-nav.scss +68 -0
  139. data/scss/foundation/components/_split-buttons.scss +159 -0
  140. data/scss/foundation/components/_sub-nav.scss +67 -0
  141. data/scss/foundation/components/_switch.scss +242 -0
  142. data/scss/foundation/components/_tables.scss +80 -0
  143. data/scss/foundation/components/_thumbs.scss +45 -0
  144. data/scss/foundation/components/_tooltips.scss +113 -0
  145. data/scss/foundation/components/_top-bar.scss +443 -0
  146. data/scss/foundation/components/_type.scss +411 -0
  147. data/scss/foundation/components/_visibility.scss +117 -0
  148. data/scss/normalize.scss +396 -0
  149. data/templates/project/config.rb +26 -0
  150. data/templates/project/index.html +28 -43
  151. data/templates/project/manifest.rb +21 -28
  152. data/templates/project/scss/_settings.scss +4 -243
  153. data/templates/project/scss/app.scss +37 -44
  154. data/templates/project/scss/normalize.scss +396 -0
  155. data/test/stylesheets/styles.css +955 -0
  156. metadata +144 -153
  157. data/config/deploy.rb +0 -42
  158. data/lib/foundation/generators/layout_generator.rb +0 -28
  159. data/scss/foundation/_settings.scss +0 -281
  160. data/scss/foundation/common/_base.scss +0 -4
  161. data/scss/foundation/common/_forms.scss +0 -117
  162. data/scss/foundation/common/_globals.scss +0 -35
  163. data/scss/foundation/common/_ratios.scss +0 -19
  164. data/scss/foundation/common/_typography.scss +0 -104
  165. data/scss/foundation/components/modules/_all.scss +0 -10
  166. data/scss/foundation/components/modules/_buttons.scss +0 -178
  167. data/scss/foundation/components/modules/_clearing.scss +0 -61
  168. data/scss/foundation/components/modules/_joyride.scss +0 -33
  169. data/scss/foundation/components/modules/_mqueries.scss +0 -458
  170. data/scss/foundation/components/modules/_navbar.scss +0 -74
  171. data/scss/foundation/components/modules/_offcanvas.scss +0 -55
  172. data/scss/foundation/components/modules/_orbit.scss +0 -90
  173. data/scss/foundation/components/modules/_reveal.scss +0 -34
  174. data/scss/foundation/components/modules/_tabs.scss +0 -67
  175. data/scss/foundation/components/modules/_topbar.scss +0 -167
  176. data/scss/foundation/components/modules/_ui.scss +0 -292
  177. data/scss/foundation/functions/_all.scss +0 -2
  178. data/scss/foundation/functions/_convert-number-to-word.scss +0 -10
  179. data/scss/foundation/functions/_grid-calc.scss +0 -5
  180. data/scss/foundation/functions/modular-scale.scss +0 -3
  181. data/scss/foundation/mixins/_all.scss +0 -5
  182. data/scss/foundation/mixins/_clearfix.scss +0 -13
  183. data/scss/foundation/mixins/_css-triangle.scss +0 -22
  184. data/scss/foundation/mixins/_font-size.scss +0 -13
  185. data/scss/foundation/mixins/_respond-to.scss +0 -11
  186. data/scss/foundation/mixins/_semantic-grid.scss +0 -66
  187. data/test/buttons.html +0 -189
  188. data/test/clearing.html +0 -85
  189. data/test/config.rb +0 -11
  190. data/test/elements.html +0 -490
  191. data/test/forms.html +0 -371
  192. data/test/grid.html +0 -543
  193. data/test/images/orbit-demo/demo1.jpeg +0 -0
  194. data/test/images/orbit-demo/demo2.jpeg +0 -0
  195. data/test/images/orbit-demo/demo3.jpeg +0 -0
  196. data/test/images/orbit-demo/slider-background.jpeg +0 -0
  197. data/test/index.html +0 -83
  198. data/test/joyride.html +0 -127
  199. data/test/magellan.html +0 -112
  200. data/test/navigation.html +0 -269
  201. data/test/orbit.html +0 -112
  202. data/test/reveal.html +0 -91
  203. data/test/scss/_settings.scss +0 -245
  204. data/test/scss/styles.scss +0 -50
  205. data/test/tabs.html +0 -197
  206. data/test/template.html +0 -52
  207. data/test/topbar-login.html +0 -194
  208. data/test/topbar.html +0 -139
  209. data/test/type.html +0 -188
  210. data/vendor/assets/images/foundation/orbit/bullets.jpg +0 -0
  211. data/vendor/assets/images/foundation/orbit/left-arrow-small.png +0 -0
  212. data/vendor/assets/images/foundation/orbit/left-arrow.png +0 -0
  213. data/vendor/assets/images/foundation/orbit/loading.gif +0 -0
  214. data/vendor/assets/images/foundation/orbit/mask-black.png +0 -0
  215. data/vendor/assets/images/foundation/orbit/pause-black.png +0 -0
  216. data/vendor/assets/images/foundation/orbit/right-arrow-small.png +0 -0
  217. data/vendor/assets/images/foundation/orbit/right-arrow.png +0 -0
  218. data/vendor/assets/images/foundation/orbit/rotator-black.png +0 -0
  219. data/vendor/assets/images/foundation/orbit/timer-black.png +0 -0
  220. data/vendor/assets/javascripts/foundation/app.js +0 -41
  221. data/vendor/assets/javascripts/foundation/index.js +0 -19
  222. data/vendor/assets/javascripts/foundation/jquery.event.move.js +0 -580
  223. data/vendor/assets/javascripts/foundation/jquery.event.swipe.js +0 -130
  224. data/vendor/assets/javascripts/foundation/jquery.foundation.accordion.js +0 -47
  225. data/vendor/assets/javascripts/foundation/jquery.foundation.alerts.js +0 -20
  226. data/vendor/assets/javascripts/foundation/jquery.foundation.buttons.js +0 -83
  227. data/vendor/assets/javascripts/foundation/jquery.foundation.clearing.js +0 -413
  228. data/vendor/assets/javascripts/foundation/jquery.foundation.forms.js +0 -502
  229. data/vendor/assets/javascripts/foundation/jquery.foundation.joyride.js +0 -639
  230. data/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js +0 -96
  231. data/vendor/assets/javascripts/foundation/jquery.foundation.mediaQueryToggle.js +0 -27
  232. data/vendor/assets/javascripts/foundation/jquery.foundation.navigation.js +0 -55
  233. data/vendor/assets/javascripts/foundation/jquery.foundation.orbit.js +0 -919
  234. data/vendor/assets/javascripts/foundation/jquery.foundation.reveal.js +0 -794
  235. data/vendor/assets/javascripts/foundation/jquery.foundation.tabs.js +0 -66
  236. data/vendor/assets/javascripts/foundation/jquery.foundation.tooltips.js +0 -211
  237. data/vendor/assets/javascripts/foundation/jquery.foundation.topbar.js +0 -174
  238. data/vendor/assets/javascripts/foundation/jquery.js +0 -9555
  239. data/vendor/assets/javascripts/foundation/jquery.offcanvas.js +0 -50
@@ -0,0 +1,1782 @@
1
+ // Zepto.js
2
+ // (c) 2010-2012 Thomas Fuchs
3
+ // Zepto.js may be freely distributed under the MIT license.
4
+
5
+ ;(function(undefined){
6
+ if (String.prototype.trim === undefined) // fix for iOS 3.2
7
+ String.prototype.trim = function(){ return this.replace(/^\s+/, '').replace(/\s+$/, '') }
8
+
9
+ // For iOS 3.x
10
+ // from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
11
+ if (Array.prototype.reduce === undefined)
12
+ Array.prototype.reduce = function(fun){
13
+ if(this === void 0 || this === null) throw new TypeError()
14
+ var t = Object(this), len = t.length >>> 0, k = 0, accumulator
15
+ if(typeof fun != 'function') throw new TypeError()
16
+ if(len == 0 && arguments.length == 1) throw new TypeError()
17
+
18
+ if(arguments.length >= 2)
19
+ accumulator = arguments[1]
20
+ else
21
+ do{
22
+ if(k in t){
23
+ accumulator = t[k++]
24
+ break
25
+ }
26
+ if(++k >= len) throw new TypeError()
27
+ } while (true)
28
+
29
+ while (k < len){
30
+ if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t)
31
+ k++
32
+ }
33
+ return accumulator
34
+ }
35
+
36
+ })();
37
+
38
+ var Zepto = (function() {
39
+ var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
40
+ document = window.document,
41
+ elementDisplay = {}, classCache = {},
42
+ getComputedStyle = document.defaultView.getComputedStyle,
43
+ cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
44
+ fragmentRE = /^\s*<(\w+|!)[^>]*>/,
45
+ tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
46
+ rootNodeRE = /^(?:body|html)$/i,
47
+
48
+ // special attributes that should be get/set via method calls
49
+ methodAttributes = ['val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset'],
50
+
51
+ adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
52
+ table = document.createElement('table'),
53
+ tableRow = document.createElement('tr'),
54
+ containers = {
55
+ 'tr': document.createElement('tbody'),
56
+ 'tbody': table, 'thead': table, 'tfoot': table,
57
+ 'td': tableRow, 'th': tableRow,
58
+ '*': document.createElement('div')
59
+ },
60
+ readyRE = /complete|loaded|interactive/,
61
+ classSelectorRE = /^\.([\w-]+)$/,
62
+ idSelectorRE = /^#([\w-]*)$/,
63
+ tagSelectorRE = /^[\w-]+$/,
64
+ toString = {}.toString,
65
+ zepto = {},
66
+ camelize, uniq,
67
+ tempParent = document.createElement('div')
68
+
69
+ zepto.matches = function(element, selector) {
70
+ if (!element || element.nodeType !== 1) return false
71
+ var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||
72
+ element.oMatchesSelector || element.matchesSelector
73
+ if (matchesSelector) return matchesSelector.call(element, selector)
74
+ // fall back to performing a selector:
75
+ var match, parent = element.parentNode, temp = !parent
76
+ if (temp) (parent = tempParent).appendChild(element)
77
+ match = ~zepto.qsa(parent, selector).indexOf(element)
78
+ temp && tempParent.removeChild(element)
79
+ return match
80
+ }
81
+
82
+ function isFunction(value) { return toString.call(value) == "[object Function]" }
83
+ function isObject(value) { return value instanceof Object }
84
+ function isPlainObject(value) {
85
+ return isObject(value) && value != window && value.__proto__ == Object.prototype
86
+ }
87
+ function isArray(value) { return value instanceof Array }
88
+ function likeArray(obj) { return typeof obj.length == 'number' }
89
+
90
+ function compact(array) { return filter.call(array, function(item){ return item != null }) }
91
+ function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
92
+ camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
93
+ function dasherize(str) {
94
+ return str.replace(/::/g, '/')
95
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
96
+ .replace(/([a-z\d])([A-Z])/g, '$1_$2')
97
+ .replace(/_/g, '-')
98
+ .toLowerCase()
99
+ }
100
+ uniq = function(array){ return filter.call(array, function(item, idx){ return array.indexOf(item) == idx }) }
101
+
102
+ function classRE(name) {
103
+ return name in classCache ?
104
+ classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'))
105
+ }
106
+
107
+ function maybeAddPx(name, value) {
108
+ return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value
109
+ }
110
+
111
+ function defaultDisplay(nodeName) {
112
+ var element, display
113
+ if (!elementDisplay[nodeName]) {
114
+ element = document.createElement(nodeName)
115
+ document.body.appendChild(element)
116
+ display = getComputedStyle(element, '').getPropertyValue("display")
117
+ element.parentNode.removeChild(element)
118
+ display == "none" && (display = "block")
119
+ elementDisplay[nodeName] = display
120
+ }
121
+ return elementDisplay[nodeName]
122
+ }
123
+
124
+ function children(element) {
125
+ return 'children' in element ?
126
+ slice.call(element.children) :
127
+ $.map(element.childNodes, function(node){ if (node.nodeType == 1) return node })
128
+ }
129
+
130
+ // `$.zepto.fragment` takes a html string and an optional tag name
131
+ // to generate DOM nodes nodes from the given html string.
132
+ // The generated DOM nodes are returned as an array.
133
+ // This function can be overriden in plugins for example to make
134
+ // it compatible with browsers that don't support the DOM fully.
135
+ zepto.fragment = function(html, name, properties) {
136
+ if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
137
+ if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
138
+ if (!(name in containers)) name = '*'
139
+
140
+ var nodes, dom, container = containers[name]
141
+ container.innerHTML = '' + html
142
+ dom = $.each(slice.call(container.childNodes), function(){
143
+ container.removeChild(this)
144
+ })
145
+ if (isPlainObject(properties)) {
146
+ nodes = $(dom)
147
+ $.each(properties, function(key, value) {
148
+ if (methodAttributes.indexOf(key) > -1) nodes[key](value)
149
+ else nodes.attr(key, value)
150
+ })
151
+ }
152
+ return dom
153
+ }
154
+
155
+ // `$.zepto.Z` swaps out the prototype of the given `dom` array
156
+ // of nodes with `$.fn` and thus supplying all the Zepto functions
157
+ // to the array. Note that `__proto__` is not supported on Internet
158
+ // Explorer. This method can be overriden in plugins.
159
+ zepto.Z = function(dom, selector) {
160
+ dom = dom || []
161
+ dom.__proto__ = arguments.callee.prototype
162
+ dom.selector = selector || ''
163
+ return dom
164
+ }
165
+
166
+ // `$.zepto.isZ` should return `true` if the given object is a Zepto
167
+ // collection. This method can be overriden in plugins.
168
+ zepto.isZ = function(object) {
169
+ return object instanceof zepto.Z
170
+ }
171
+
172
+ // `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
173
+ // takes a CSS selector and an optional context (and handles various
174
+ // special cases).
175
+ // This method can be overriden in plugins.
176
+ zepto.init = function(selector, context) {
177
+ // If nothing given, return an empty Zepto collection
178
+ if (!selector) return zepto.Z()
179
+ // If a function is given, call it when the DOM is ready
180
+ else if (isFunction(selector)) return $(document).ready(selector)
181
+ // If a Zepto collection is given, juts return it
182
+ else if (zepto.isZ(selector)) return selector
183
+ else {
184
+ var dom
185
+ // normalize array if an array of nodes is given
186
+ if (isArray(selector)) dom = compact(selector)
187
+ // Wrap DOM nodes. If a plain object is given, duplicate it.
188
+ else if (isObject(selector))
189
+ dom = [isPlainObject(selector) ? $.extend({}, selector) : selector], selector = null
190
+ // If it's a html fragment, create nodes from it
191
+ else if (fragmentRE.test(selector))
192
+ dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null
193
+ // If there's a context, create a collection on that context first, and select
194
+ // nodes from there
195
+ else if (context !== undefined) return $(context).find(selector)
196
+ // And last but no least, if it's a CSS selector, use it to select nodes.
197
+ else dom = zepto.qsa(document, selector)
198
+ // create a new Zepto collection from the nodes found
199
+ return zepto.Z(dom, selector)
200
+ }
201
+ }
202
+
203
+ // `$` will be the base `Zepto` object. When calling this
204
+ // function just call `$.zepto.init, which makes the implementation
205
+ // details of selecting nodes and creating Zepto collections
206
+ // patchable in plugins.
207
+ $ = function(selector, context){
208
+ return zepto.init(selector, context)
209
+ }
210
+
211
+ function extend(target, source, deep) {
212
+ for (key in source)
213
+ if (deep && isPlainObject(source[key])) {
214
+ if (!isPlainObject(target[key])) target[key] = {}
215
+ extend(target[key], source[key], deep)
216
+ }
217
+ else if (source[key] !== undefined) target[key] = source[key]
218
+ }
219
+
220
+ // Copy all but undefined properties from one or more
221
+ // objects to the `target` object.
222
+ $.extend = function(target){
223
+ var deep, args = slice.call(arguments, 1)
224
+ if (typeof target == 'boolean') {
225
+ deep = target
226
+ target = args.shift()
227
+ }
228
+ args.forEach(function(arg){ extend(target, arg, deep) })
229
+ return target
230
+ }
231
+
232
+ // `$.zepto.qsa` is Zepto's CSS selector implementation which
233
+ // uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
234
+ // This method can be overriden in plugins.
235
+ zepto.qsa = function(element, selector){
236
+ var found
237
+ return (element === document && idSelectorRE.test(selector)) ?
238
+ ( (found = element.getElementById(RegExp.$1)) ? [found] : [] ) :
239
+ (element.nodeType !== 1 && element.nodeType !== 9) ? [] :
240
+ slice.call(
241
+ classSelectorRE.test(selector) ? element.getElementsByClassName(RegExp.$1) :
242
+ tagSelectorRE.test(selector) ? element.getElementsByTagName(selector) :
243
+ element.querySelectorAll(selector)
244
+ )
245
+ }
246
+
247
+ function filtered(nodes, selector) {
248
+ return selector === undefined ? $(nodes) : $(nodes).filter(selector)
249
+ }
250
+
251
+ $.contains = function(parent, node) {
252
+ return parent !== node && parent.contains(node)
253
+ }
254
+
255
+ function funcArg(context, arg, idx, payload) {
256
+ return isFunction(arg) ? arg.call(context, idx, payload) : arg
257
+ }
258
+
259
+ function setAttribute(node, name, value) {
260
+ value == null ? node.removeAttribute(name) : node.setAttribute(name, value)
261
+ }
262
+
263
+ // access className property while respecting SVGAnimatedString
264
+ function className(node, value){
265
+ var klass = node.className,
266
+ svg = klass && klass.baseVal !== undefined
267
+
268
+ if (value === undefined) return svg ? klass.baseVal : klass
269
+ svg ? (klass.baseVal = value) : (node.className = value)
270
+ }
271
+
272
+ // "true" => true
273
+ // "false" => false
274
+ // "null" => null
275
+ // "42" => 42
276
+ // "42.5" => 42.5
277
+ // JSON => parse if valid
278
+ // String => self
279
+ function deserializeValue(value) {
280
+ var num
281
+ try {
282
+ return value ?
283
+ value == "true" ||
284
+ ( value == "false" ? false :
285
+ value == "null" ? null :
286
+ !isNaN(num = Number(value)) ? num :
287
+ /^[\[\{]/.test(value) ? $.parseJSON(value) :
288
+ value )
289
+ : value
290
+ } catch(e) {
291
+ return value
292
+ }
293
+ }
294
+
295
+ $.isFunction = isFunction
296
+ $.isObject = isObject
297
+ $.isArray = isArray
298
+ $.isPlainObject = isPlainObject
299
+
300
+ $.inArray = function(elem, array, i){
301
+ return emptyArray.indexOf.call(array, elem, i)
302
+ }
303
+
304
+ $.camelCase = camelize
305
+ $.trim = function(str) { return str.trim() }
306
+
307
+ // plugin compatibility
308
+ $.uuid = 0
309
+ $.support = { }
310
+ $.expr = { }
311
+
312
+ $.map = function(elements, callback){
313
+ var value, values = [], i, key
314
+ if (likeArray(elements))
315
+ for (i = 0; i < elements.length; i++) {
316
+ value = callback(elements[i], i)
317
+ if (value != null) values.push(value)
318
+ }
319
+ else
320
+ for (key in elements) {
321
+ value = callback(elements[key], key)
322
+ if (value != null) values.push(value)
323
+ }
324
+ return flatten(values)
325
+ }
326
+
327
+ $.each = function(elements, callback){
328
+ var i, key
329
+ if (likeArray(elements)) {
330
+ for (i = 0; i < elements.length; i++)
331
+ if (callback.call(elements[i], i, elements[i]) === false) return elements
332
+ } else {
333
+ for (key in elements)
334
+ if (callback.call(elements[key], key, elements[key]) === false) return elements
335
+ }
336
+
337
+ return elements
338
+ }
339
+
340
+ $.grep = function(elements, callback){
341
+ return filter.call(elements, callback)
342
+ }
343
+
344
+ if (window.JSON) $.parseJSON = JSON.parse
345
+
346
+ // Define methods that will be available on all
347
+ // Zepto collections
348
+ $.fn = {
349
+ // Because a collection acts like an array
350
+ // copy over these useful array functions.
351
+ forEach: emptyArray.forEach,
352
+ reduce: emptyArray.reduce,
353
+ push: emptyArray.push,
354
+ sort: emptyArray.sort,
355
+ indexOf: emptyArray.indexOf,
356
+ concat: emptyArray.concat,
357
+
358
+ // `map` and `slice` in the jQuery API work differently
359
+ // from their array counterparts
360
+ map: function(fn){
361
+ return $($.map(this, function(el, i){ return fn.call(el, i, el) }))
362
+ },
363
+ slice: function(){
364
+ return $(slice.apply(this, arguments))
365
+ },
366
+
367
+ ready: function(callback){
368
+ if (readyRE.test(document.readyState)) callback($)
369
+ else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
370
+ return this
371
+ },
372
+ get: function(idx){
373
+ return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length]
374
+ },
375
+ toArray: function(){ return this.get() },
376
+ size: function(){
377
+ return this.length
378
+ },
379
+ remove: function(){
380
+ return this.each(function(){
381
+ if (this.parentNode != null)
382
+ this.parentNode.removeChild(this)
383
+ })
384
+ },
385
+ each: function(callback){
386
+ emptyArray.every.call(this, function(el, idx){
387
+ return callback.call(el, idx, el) !== false
388
+ })
389
+ return this
390
+ },
391
+ filter: function(selector){
392
+ if (isFunction(selector)) return this.not(this.not(selector))
393
+ return $(filter.call(this, function(element){
394
+ return zepto.matches(element, selector)
395
+ }))
396
+ },
397
+ add: function(selector,context){
398
+ return $(uniq(this.concat($(selector,context))))
399
+ },
400
+ is: function(selector){
401
+ return this.length > 0 && zepto.matches(this[0], selector)
402
+ },
403
+ not: function(selector){
404
+ var nodes=[]
405
+ if (isFunction(selector) && selector.call !== undefined)
406
+ this.each(function(idx){
407
+ if (!selector.call(this,idx)) nodes.push(this)
408
+ })
409
+ else {
410
+ var excludes = typeof selector == 'string' ? this.filter(selector) :
411
+ (likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)
412
+ this.forEach(function(el){
413
+ if (excludes.indexOf(el) < 0) nodes.push(el)
414
+ })
415
+ }
416
+ return $(nodes)
417
+ },
418
+ has: function(selector){
419
+ return this.filter(function(){
420
+ return isObject(selector) ?
421
+ $.contains(this, selector) :
422
+ $(this).find(selector).size()
423
+ })
424
+ },
425
+ eq: function(idx){
426
+ return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)
427
+ },
428
+ first: function(){
429
+ var el = this[0]
430
+ return el && !isObject(el) ? el : $(el)
431
+ },
432
+ last: function(){
433
+ var el = this[this.length - 1]
434
+ return el && !isObject(el) ? el : $(el)
435
+ },
436
+ find: function(selector){
437
+ var result
438
+ if (this.length == 1) result = $(zepto.qsa(this[0], selector))
439
+ else result = this.map(function(){ return zepto.qsa(this, selector) })
440
+ return result
441
+ },
442
+ closest: function(selector, context){
443
+ var node = this[0]
444
+ while (node && !zepto.matches(node, selector))
445
+ node = node !== context && node !== document && node.parentNode
446
+ return $(node)
447
+ },
448
+ parents: function(selector){
449
+ var ancestors = [], nodes = this
450
+ while (nodes.length > 0)
451
+ nodes = $.map(nodes, function(node){
452
+ if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {
453
+ ancestors.push(node)
454
+ return node
455
+ }
456
+ })
457
+ return filtered(ancestors, selector)
458
+ },
459
+ parent: function(selector){
460
+ return filtered(uniq(this.pluck('parentNode')), selector)
461
+ },
462
+ children: function(selector){
463
+ return filtered(this.map(function(){ return children(this) }), selector)
464
+ },
465
+ contents: function() {
466
+ return this.map(function() { return slice.call(this.childNodes) })
467
+ },
468
+ siblings: function(selector){
469
+ return filtered(this.map(function(i, el){
470
+ return filter.call(children(el.parentNode), function(child){ return child!==el })
471
+ }), selector)
472
+ },
473
+ empty: function(){
474
+ return this.each(function(){ this.innerHTML = '' })
475
+ },
476
+ // `pluck` is borrowed from Prototype.js
477
+ pluck: function(property){
478
+ return $.map(this, function(el){ return el[property] })
479
+ },
480
+ show: function(){
481
+ return this.each(function(){
482
+ this.style.display == "none" && (this.style.display = null)
483
+ if (getComputedStyle(this, '').getPropertyValue("display") == "none")
484
+ this.style.display = defaultDisplay(this.nodeName)
485
+ })
486
+ },
487
+ replaceWith: function(newContent){
488
+ return this.before(newContent).remove()
489
+ },
490
+ wrap: function(structure){
491
+ var func = isFunction(structure)
492
+ if (this[0] && !func)
493
+ var dom = $(structure).get(0),
494
+ clone = dom.parentNode || this.length > 1
495
+
496
+ return this.each(function(index){
497
+ $(this).wrapAll(
498
+ func ? structure.call(this, index) :
499
+ clone ? dom.cloneNode(true) : dom
500
+ )
501
+ })
502
+ },
503
+ wrapAll: function(structure){
504
+ if (this[0]) {
505
+ $(this[0]).before(structure = $(structure))
506
+ var children
507
+ // drill down to the inmost element
508
+ while ((children = structure.children()).length) structure = children.first()
509
+ $(structure).append(this)
510
+ }
511
+ return this
512
+ },
513
+ wrapInner: function(structure){
514
+ var func = isFunction(structure)
515
+ return this.each(function(index){
516
+ var self = $(this), contents = self.contents(),
517
+ dom = func ? structure.call(this, index) : structure
518
+ contents.length ? contents.wrapAll(dom) : self.append(dom)
519
+ })
520
+ },
521
+ unwrap: function(){
522
+ this.parent().each(function(){
523
+ $(this).replaceWith($(this).children())
524
+ })
525
+ return this
526
+ },
527
+ clone: function(){
528
+ return this.map(function(){ return this.cloneNode(true) })
529
+ },
530
+ hide: function(){
531
+ return this.css("display", "none")
532
+ },
533
+ toggle: function(setting){
534
+ return this.each(function(){
535
+ var el = $(this)
536
+ ;(setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide()
537
+ })
538
+ },
539
+ prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') },
540
+ next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') },
541
+ html: function(html){
542
+ return html === undefined ?
543
+ (this.length > 0 ? this[0].innerHTML : null) :
544
+ this.each(function(idx){
545
+ var originHtml = this.innerHTML
546
+ $(this).empty().append( funcArg(this, html, idx, originHtml) )
547
+ })
548
+ },
549
+ text: function(text){
550
+ return text === undefined ?
551
+ (this.length > 0 ? this[0].textContent : null) :
552
+ this.each(function(){ this.textContent = text })
553
+ },
554
+ attr: function(name, value){
555
+ var result
556
+ return (typeof name == 'string' && value === undefined) ?
557
+ (this.length == 0 || this[0].nodeType !== 1 ? undefined :
558
+ (name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :
559
+ (!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
560
+ ) :
561
+ this.each(function(idx){
562
+ if (this.nodeType !== 1) return
563
+ if (isObject(name)) for (key in name) setAttribute(this, key, name[key])
564
+ else setAttribute(this, name, funcArg(this, value, idx, this.getAttribute(name)))
565
+ })
566
+ },
567
+ removeAttr: function(name){
568
+ return this.each(function(){ this.nodeType === 1 && setAttribute(this, name) })
569
+ },
570
+ prop: function(name, value){
571
+ return (value === undefined) ?
572
+ (this[0] && this[0][name]) :
573
+ this.each(function(idx){
574
+ this[name] = funcArg(this, value, idx, this[name])
575
+ })
576
+ },
577
+ data: function(name, value){
578
+ var data = this.attr('data-' + dasherize(name), value)
579
+ return data !== null ? deserializeValue(data) : undefined
580
+ },
581
+ val: function(value){
582
+ return (value === undefined) ?
583
+ (this[0] && (this[0].multiple ?
584
+ $(this[0]).find('option').filter(function(o){ return this.selected }).pluck('value') :
585
+ this[0].value)
586
+ ) :
587
+ this.each(function(idx){
588
+ this.value = funcArg(this, value, idx, this.value)
589
+ })
590
+ },
591
+ offset: function(coordinates){
592
+ if (coordinates) return this.each(function(index){
593
+ var $this = $(this),
594
+ coords = funcArg(this, coordinates, index, $this.offset()),
595
+ parentOffset = $this.offsetParent().offset(),
596
+ props = {
597
+ top: coords.top - parentOffset.top,
598
+ left: coords.left - parentOffset.left
599
+ }
600
+
601
+ if ($this.css('position') == 'static') props['position'] = 'relative'
602
+ $this.css(props)
603
+ })
604
+ if (this.length==0) return null
605
+ var obj = this[0].getBoundingClientRect()
606
+ return {
607
+ left: obj.left + window.pageXOffset,
608
+ top: obj.top + window.pageYOffset,
609
+ width: obj.width,
610
+ height: obj.height
611
+ }
612
+ },
613
+ css: function(property, value){
614
+ if (arguments.length < 2 && typeof property == 'string')
615
+ return this[0] && (this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
616
+
617
+ var css = ''
618
+ for (key in property)
619
+ if (!property[key] && property[key] !== 0)
620
+ this.each(function(){ this.style.removeProperty(dasherize(key)) })
621
+ else
622
+ css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
623
+
624
+ if (typeof property == 'string')
625
+ if (!value && value !== 0)
626
+ this.each(function(){ this.style.removeProperty(dasherize(property)) })
627
+ else
628
+ css = dasherize(property) + ":" + maybeAddPx(property, value)
629
+
630
+ return this.each(function(){ this.style.cssText += ';' + css })
631
+ },
632
+ index: function(element){
633
+ return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])
634
+ },
635
+ hasClass: function(name){
636
+ return emptyArray.some.call(this, function(el){
637
+ return this.test(className(el))
638
+ }, classRE(name))
639
+ },
640
+ addClass: function(name){
641
+ return this.each(function(idx){
642
+ classList = []
643
+ var cls = className(this), newName = funcArg(this, name, idx, cls)
644
+ newName.split(/\s+/g).forEach(function(klass){
645
+ if (!$(this).hasClass(klass)) classList.push(klass)
646
+ }, this)
647
+ classList.length && className(this, cls + (cls ? " " : "") + classList.join(" "))
648
+ })
649
+ },
650
+ removeClass: function(name){
651
+ return this.each(function(idx){
652
+ if (name === undefined) return className(this, '')
653
+ classList = className(this)
654
+ funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){
655
+ classList = classList.replace(classRE(klass), " ")
656
+ })
657
+ className(this, classList.trim())
658
+ })
659
+ },
660
+ toggleClass: function(name, when){
661
+ return this.each(function(idx){
662
+ var $this = $(this), names = funcArg(this, name, idx, className(this))
663
+ names.split(/\s+/g).forEach(function(klass){
664
+ (when === undefined ? !$this.hasClass(klass) : when) ?
665
+ $this.addClass(klass) : $this.removeClass(klass)
666
+ })
667
+ })
668
+ },
669
+ scrollTop: function(){
670
+ if (!this.length) return
671
+ return ('scrollTop' in this[0]) ? this[0].scrollTop : this[0].scrollY
672
+ },
673
+ position: function() {
674
+ if (!this.length) return
675
+
676
+ var elem = this[0],
677
+ // Get *real* offsetParent
678
+ offsetParent = this.offsetParent(),
679
+ // Get correct offsets
680
+ offset = this.offset(),
681
+ parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset()
682
+
683
+ // Subtract element margins
684
+ // note: when an element has margin: auto the offsetLeft and marginLeft
685
+ // are the same in Safari causing offset.left to incorrectly be 0
686
+ offset.top -= parseFloat( $(elem).css('margin-top') ) || 0
687
+ offset.left -= parseFloat( $(elem).css('margin-left') ) || 0
688
+
689
+ // Add offsetParent borders
690
+ parentOffset.top += parseFloat( $(offsetParent[0]).css('border-top-width') ) || 0
691
+ parentOffset.left += parseFloat( $(offsetParent[0]).css('border-left-width') ) || 0
692
+
693
+ // Subtract the two offsets
694
+ return {
695
+ top: offset.top - parentOffset.top,
696
+ left: offset.left - parentOffset.left
697
+ }
698
+ },
699
+ offsetParent: function() {
700
+ return this.map(function(){
701
+ var parent = this.offsetParent || document.body
702
+ while (parent && !rootNodeRE.test(parent.nodeName) && $(parent).css("position") == "static")
703
+ parent = parent.offsetParent
704
+ return parent
705
+ })
706
+ }
707
+ }
708
+
709
+ // for now
710
+ $.fn.detach = $.fn.remove
711
+
712
+ // Generate the `width` and `height` functions
713
+ ;['width', 'height'].forEach(function(dimension){
714
+ $.fn[dimension] = function(value){
715
+ var offset, Dimension = dimension.replace(/./, function(m){ return m[0].toUpperCase() })
716
+ if (value === undefined) return this[0] == window ? window['inner' + Dimension] :
717
+ this[0] == document ? document.documentElement['offset' + Dimension] :
718
+ (offset = this.offset()) && offset[dimension]
719
+ else return this.each(function(idx){
720
+ var el = $(this)
721
+ el.css(dimension, funcArg(this, value, idx, el[dimension]()))
722
+ })
723
+ }
724
+ })
725
+
726
+ function traverseNode(node, fun) {
727
+ fun(node)
728
+ for (var key in node.childNodes) traverseNode(node.childNodes[key], fun)
729
+ }
730
+
731
+ // Generate the `after`, `prepend`, `before`, `append`,
732
+ // `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
733
+ adjacencyOperators.forEach(function(operator, operatorIndex) {
734
+ var inside = operatorIndex % 2 //=> prepend, append
735
+
736
+ $.fn[operator] = function(){
737
+ // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
738
+ var nodes = $.map(arguments, function(n){ return isObject(n) ? n : zepto.fragment(n) }),
739
+ parent, copyByClone = this.length > 1
740
+ if (nodes.length < 1) return this
741
+
742
+ return this.each(function(_, target){
743
+ parent = inside ? target : target.parentNode
744
+
745
+ // convert all methods to a "before" operation
746
+ target = operatorIndex == 0 ? target.nextSibling :
747
+ operatorIndex == 1 ? target.firstChild :
748
+ operatorIndex == 2 ? target :
749
+ null
750
+
751
+ nodes.forEach(function(node){
752
+ if (copyByClone) node = node.cloneNode(true)
753
+ else if (!parent) return $(node).remove()
754
+
755
+ traverseNode(parent.insertBefore(node, target), function(el){
756
+ if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
757
+ (!el.type || el.type === 'text/javascript') && !el.src)
758
+ window['eval'].call(window, el.innerHTML)
759
+ })
760
+ })
761
+ })
762
+ }
763
+
764
+ // after => insertAfter
765
+ // prepend => prependTo
766
+ // before => insertBefore
767
+ // append => appendTo
768
+ $.fn[inside ? operator+'To' : 'insert'+(operatorIndex ? 'Before' : 'After')] = function(html){
769
+ $(html)[operator](this)
770
+ return this
771
+ }
772
+ })
773
+
774
+ zepto.Z.prototype = $.fn
775
+
776
+ // Export internal API functions in the `$.zepto` namespace
777
+ zepto.uniq = uniq
778
+ zepto.deserializeValue = deserializeValue
779
+ $.zepto = zepto
780
+
781
+ return $
782
+ })()
783
+
784
+ // If `$` is not yet defined, point it to `Zepto`
785
+ window.Zepto = Zepto
786
+ '$' in window || (window.$ = Zepto);
787
+
788
+ // Zepto.js
789
+ // (c) 2010-2012 Thomas Fuchs
790
+ // Zepto.js may be freely distributed under the MIT license.
791
+
792
+ ;(function($){
793
+ var $$ = $.zepto.qsa, handlers = {}, _zid = 1, specialEvents={},
794
+ hover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }
795
+
796
+ specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'
797
+
798
+ function zid(element) {
799
+ return element._zid || (element._zid = _zid++)
800
+ }
801
+ function findHandlers(element, event, fn, selector) {
802
+ event = parse(event)
803
+ if (event.ns) var matcher = matcherFor(event.ns)
804
+ return (handlers[zid(element)] || []).filter(function(handler) {
805
+ return handler
806
+ && (!event.e || handler.e == event.e)
807
+ && (!event.ns || matcher.test(handler.ns))
808
+ && (!fn || zid(handler.fn) === zid(fn))
809
+ && (!selector || handler.sel == selector)
810
+ })
811
+ }
812
+ function parse(event) {
813
+ var parts = ('' + event).split('.')
814
+ return {e: parts[0], ns: parts.slice(1).sort().join(' ')}
815
+ }
816
+ function matcherFor(ns) {
817
+ return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)')
818
+ }
819
+
820
+ function eachEvent(events, fn, iterator){
821
+ if ($.isObject(events)) $.each(events, iterator)
822
+ else events.split(/\s/).forEach(function(type){ iterator(type, fn) })
823
+ }
824
+
825
+ function eventCapture(handler, captureSetting) {
826
+ return handler.del &&
827
+ (handler.e == 'focus' || handler.e == 'blur') ||
828
+ !!captureSetting
829
+ }
830
+
831
+ function realEvent(type) {
832
+ return hover[type] || type
833
+ }
834
+
835
+ function add(element, events, fn, selector, getDelegate, capture){
836
+ var id = zid(element), set = (handlers[id] || (handlers[id] = []))
837
+ eachEvent(events, fn, function(event, fn){
838
+ var handler = parse(event)
839
+ handler.fn = fn
840
+ handler.sel = selector
841
+ // emulate mouseenter, mouseleave
842
+ if (handler.e in hover) fn = function(e){
843
+ var related = e.relatedTarget
844
+ if (!related || (related !== this && !$.contains(this, related)))
845
+ return handler.fn.apply(this, arguments)
846
+ }
847
+ handler.del = getDelegate && getDelegate(fn, event)
848
+ var callback = handler.del || fn
849
+ handler.proxy = function (e) {
850
+ var result = callback.apply(element, [e].concat(e.data))
851
+ if (result === false) e.preventDefault(), e.stopPropagation()
852
+ return result
853
+ }
854
+ handler.i = set.length
855
+ set.push(handler)
856
+ element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
857
+ })
858
+ }
859
+ function remove(element, events, fn, selector, capture){
860
+ var id = zid(element)
861
+ eachEvent(events || '', fn, function(event, fn){
862
+ findHandlers(element, event, fn, selector).forEach(function(handler){
863
+ delete handlers[id][handler.i]
864
+ element.removeEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
865
+ })
866
+ })
867
+ }
868
+
869
+ $.event = { add: add, remove: remove }
870
+
871
+ $.proxy = function(fn, context) {
872
+ if ($.isFunction(fn)) {
873
+ var proxyFn = function(){ return fn.apply(context, arguments) }
874
+ proxyFn._zid = zid(fn)
875
+ return proxyFn
876
+ } else if (typeof context == 'string') {
877
+ return $.proxy(fn[context], fn)
878
+ } else {
879
+ throw new TypeError("expected function")
880
+ }
881
+ }
882
+
883
+ $.fn.bind = function(event, callback){
884
+ return this.each(function(){
885
+ add(this, event, callback)
886
+ })
887
+ }
888
+ $.fn.unbind = function(event, callback){
889
+ return this.each(function(){
890
+ remove(this, event, callback)
891
+ })
892
+ }
893
+ $.fn.one = function(event, callback){
894
+ return this.each(function(i, element){
895
+ add(this, event, callback, null, function(fn, type){
896
+ return function(){
897
+ var result = fn.apply(element, arguments)
898
+ remove(element, type, fn)
899
+ return result
900
+ }
901
+ })
902
+ })
903
+ }
904
+
905
+ var returnTrue = function(){return true},
906
+ returnFalse = function(){return false},
907
+ ignoreProperties = /^([A-Z]|layer[XY]$)/,
908
+ eventMethods = {
909
+ preventDefault: 'isDefaultPrevented',
910
+ stopImmediatePropagation: 'isImmediatePropagationStopped',
911
+ stopPropagation: 'isPropagationStopped'
912
+ }
913
+ function createProxy(event) {
914
+ var key, proxy = { originalEvent: event }
915
+ for (key in event)
916
+ if (!ignoreProperties.test(key) && event[key] !== undefined) proxy[key] = event[key]
917
+
918
+ $.each(eventMethods, function(name, predicate) {
919
+ proxy[name] = function(){
920
+ this[predicate] = returnTrue
921
+ return event[name].apply(event, arguments)
922
+ }
923
+ proxy[predicate] = returnFalse
924
+ })
925
+ return proxy
926
+ }
927
+
928
+ // emulates the 'defaultPrevented' property for browsers that have none
929
+ function fix(event) {
930
+ if (!('defaultPrevented' in event)) {
931
+ event.defaultPrevented = false
932
+ var prevent = event.preventDefault
933
+ event.preventDefault = function() {
934
+ this.defaultPrevented = true
935
+ prevent.call(this)
936
+ }
937
+ }
938
+ }
939
+
940
+ $.fn.delegate = function(selector, event, callback){
941
+ return this.each(function(i, element){
942
+ add(element, event, callback, selector, function(fn){
943
+ return function(e){
944
+ var evt, match = $(e.target).closest(selector, element).get(0)
945
+ if (match) {
946
+ evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
947
+ return fn.apply(match, [evt].concat([].slice.call(arguments, 1)))
948
+ }
949
+ }
950
+ })
951
+ })
952
+ }
953
+ $.fn.undelegate = function(selector, event, callback){
954
+ return this.each(function(){
955
+ remove(this, event, callback, selector)
956
+ })
957
+ }
958
+
959
+ $.fn.live = function(event, callback){
960
+ $(document.body).delegate(this.selector, event, callback)
961
+ return this
962
+ }
963
+ $.fn.die = function(event, callback){
964
+ $(document.body).undelegate(this.selector, event, callback)
965
+ return this
966
+ }
967
+
968
+ $.fn.on = function(event, selector, callback){
969
+ return !selector || $.isFunction(selector) ?
970
+ this.bind(event, selector || callback) : this.delegate(selector, event, callback)
971
+ }
972
+ $.fn.off = function(event, selector, callback){
973
+ return !selector || $.isFunction(selector) ?
974
+ this.unbind(event, selector || callback) : this.undelegate(selector, event, callback)
975
+ }
976
+
977
+ $.fn.trigger = function(event, data){
978
+ if (typeof event == 'string' || $.isPlainObject(event)) event = $.Event(event)
979
+ fix(event)
980
+ event.data = data
981
+ return this.each(function(){
982
+ // items in the collection might not be DOM elements
983
+ // (todo: possibly support events on plain old objects)
984
+ if('dispatchEvent' in this) this.dispatchEvent(event)
985
+ })
986
+ }
987
+
988
+ // triggers event handlers on current element just as if an event occurred,
989
+ // doesn't trigger an actual event, doesn't bubble
990
+ $.fn.triggerHandler = function(event, data){
991
+ var e, result
992
+ this.each(function(i, element){
993
+ e = createProxy(typeof event == 'string' ? $.Event(event) : event)
994
+ e.data = data
995
+ e.target = element
996
+ $.each(findHandlers(element, event.type || event), function(i, handler){
997
+ result = handler.proxy(e)
998
+ if (e.isImmediatePropagationStopped()) return false
999
+ })
1000
+ })
1001
+ return result
1002
+ }
1003
+
1004
+ // shortcut methods for `.bind(event, fn)` for each event type
1005
+ ;('focusin focusout load resize scroll unload click dblclick '+
1006
+ 'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave '+
1007
+ 'change select keydown keypress keyup error').split(' ').forEach(function(event) {
1008
+ $.fn[event] = function(callback) {
1009
+ return callback ?
1010
+ this.bind(event, callback) :
1011
+ this.trigger(event)
1012
+ }
1013
+ })
1014
+
1015
+ ;['focus', 'blur'].forEach(function(name) {
1016
+ $.fn[name] = function(callback) {
1017
+ if (callback) this.bind(name, callback)
1018
+ else this.each(function(){
1019
+ try { this[name]() }
1020
+ catch(e) {}
1021
+ })
1022
+ return this
1023
+ }
1024
+ })
1025
+
1026
+ $.Event = function(type, props) {
1027
+ if (typeof type != 'string') props = type, type = props.type
1028
+ var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true
1029
+ if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])
1030
+ event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null)
1031
+ event.isDefaultPrevented = function(){ return this.defaultPrevented }
1032
+ return event
1033
+ }
1034
+
1035
+ })(Zepto);
1036
+
1037
+ // Zepto.js
1038
+ // (c) 2010-2012 Thomas Fuchs
1039
+ // Zepto.js may be freely distributed under the MIT license.
1040
+
1041
+ ;(function($){
1042
+ function detect(ua){
1043
+ var os = this.os = {}, browser = this.browser = {},
1044
+ webkit = ua.match(/WebKit\/([\d.]+)/),
1045
+ android = ua.match(/(Android)\s+([\d.]+)/),
1046
+ ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
1047
+ iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
1048
+ webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
1049
+ touchpad = webos && ua.match(/TouchPad/),
1050
+ kindle = ua.match(/Kindle\/([\d.]+)/),
1051
+ silk = ua.match(/Silk\/([\d._]+)/),
1052
+ blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/),
1053
+ chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/)
1054
+
1055
+ // todo clean this up with a better OS/browser
1056
+ // separation. we need to discern between multiple
1057
+ // browsers on android, and decide if kindle fire in
1058
+ // silk mode is android or not
1059
+
1060
+ if (browser.webkit = !!webkit) browser.version = webkit[1]
1061
+
1062
+ if (android) os.android = true, os.version = android[2]
1063
+ if (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')
1064
+ if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')
1065
+ if (webos) os.webos = true, os.version = webos[2]
1066
+ if (touchpad) os.touchpad = true
1067
+ if (blackberry) os.blackberry = true, os.version = blackberry[2]
1068
+ if (kindle) os.kindle = true, os.version = kindle[1]
1069
+ if (silk) browser.silk = true, browser.version = silk[1]
1070
+ if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true
1071
+ if (chrome) browser.chrome = true, browser.version = chrome[1]
1072
+ }
1073
+
1074
+ detect.call($, navigator.userAgent)
1075
+ // make available to unit tests
1076
+ $.__detect = detect
1077
+
1078
+ })(Zepto);
1079
+
1080
+
1081
+ // Zepto.js
1082
+ // (c) 2010-2012 Thomas Fuchs
1083
+ // Zepto.js may be freely distributed under the MIT license.
1084
+
1085
+ ;(function($, undefined){
1086
+ var prefix = '', eventPrefix, endEventName, endAnimationName,
1087
+ vendors = { Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' },
1088
+ document = window.document, testEl = document.createElement('div'),
1089
+ supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,
1090
+ transform,
1091
+ transitionProperty, transitionDuration, transitionTiming,
1092
+ animationName, animationDuration, animationTiming,
1093
+ cssReset = {}
1094
+
1095
+ function dasherize(str) { return downcase(str.replace(/([a-z])([A-Z])/, '$1-$2')) }
1096
+ function downcase(str) { return str.toLowerCase() }
1097
+ function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }
1098
+
1099
+ $.each(vendors, function(vendor, event){
1100
+ if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
1101
+ prefix = '-' + downcase(vendor) + '-'
1102
+ eventPrefix = event
1103
+ return false
1104
+ }
1105
+ })
1106
+
1107
+ transform = prefix + 'transform'
1108
+ cssReset[transitionProperty = prefix + 'transition-property'] =
1109
+ cssReset[transitionDuration = prefix + 'transition-duration'] =
1110
+ cssReset[transitionTiming = prefix + 'transition-timing-function'] =
1111
+ cssReset[animationName = prefix + 'animation-name'] =
1112
+ cssReset[animationDuration = prefix + 'animation-duration'] =
1113
+ cssReset[animationTiming = prefix + 'animation-timing-function'] = ''
1114
+
1115
+ $.fx = {
1116
+ off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
1117
+ speeds: { _default: 400, fast: 200, slow: 600 },
1118
+ cssPrefix: prefix,
1119
+ transitionEnd: normalizeEvent('TransitionEnd'),
1120
+ animationEnd: normalizeEvent('AnimationEnd')
1121
+ }
1122
+
1123
+ $.fn.animate = function(properties, duration, ease, callback){
1124
+ if ($.isObject(duration))
1125
+ ease = duration.easing, callback = duration.complete, duration = duration.duration
1126
+ if (duration) duration = (typeof duration == 'number' ? duration :
1127
+ ($.fx.speeds[duration] || $.fx.speeds._default)) / 1000
1128
+ return this.anim(properties, duration, ease, callback)
1129
+ }
1130
+
1131
+ $.fn.anim = function(properties, duration, ease, callback){
1132
+ var key, cssValues = {}, cssProperties, transforms = '',
1133
+ that = this, wrappedCallback, endEvent = $.fx.transitionEnd
1134
+
1135
+ if (duration === undefined) duration = 0.4
1136
+ if ($.fx.off) duration = 0
1137
+
1138
+ if (typeof properties == 'string') {
1139
+ // keyframe animation
1140
+ cssValues[animationName] = properties
1141
+ cssValues[animationDuration] = duration + 's'
1142
+ cssValues[animationTiming] = (ease || 'linear')
1143
+ endEvent = $.fx.animationEnd
1144
+ } else {
1145
+ cssProperties = []
1146
+ // CSS transitions
1147
+ for (key in properties)
1148
+ if (supportedTransforms.test(key)) transforms += key + '(' + properties[key] + ') '
1149
+ else cssValues[key] = properties[key], cssProperties.push(dasherize(key))
1150
+
1151
+ if (transforms) cssValues[transform] = transforms, cssProperties.push(transform)
1152
+ if (duration > 0 && typeof properties === 'object') {
1153
+ cssValues[transitionProperty] = cssProperties.join(', ')
1154
+ cssValues[transitionDuration] = duration + 's'
1155
+ cssValues[transitionTiming] = (ease || 'linear')
1156
+ }
1157
+ }
1158
+
1159
+ wrappedCallback = function(event){
1160
+ if (typeof event !== 'undefined') {
1161
+ if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
1162
+ $(event.target).unbind(endEvent, arguments.callee)
1163
+ }
1164
+ $(this).css(cssReset)
1165
+ callback && callback.call(this)
1166
+ }
1167
+ if (duration > 0) this.bind(endEvent, wrappedCallback)
1168
+
1169
+ // trigger page reflow so new elements can animate
1170
+ this.size() && this.get(0).clientLeft
1171
+
1172
+ this.css(cssValues)
1173
+
1174
+ if (duration <= 0) setTimeout(function() {
1175
+ that.each(function(){ wrappedCallback.call(this) })
1176
+ }, 0)
1177
+
1178
+ return this
1179
+ }
1180
+
1181
+ testEl = null
1182
+ })(Zepto);
1183
+
1184
+
1185
+ // Zepto.js
1186
+ // (c) 2010-2012 Thomas Fuchs
1187
+ // Zepto.js may be freely distributed under the MIT license.
1188
+
1189
+ ;(function($){
1190
+ var jsonpID = 0,
1191
+ isObject = $.isObject,
1192
+ document = window.document,
1193
+ key,
1194
+ name,
1195
+ rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
1196
+ scriptTypeRE = /^(?:text|application)\/javascript/i,
1197
+ xmlTypeRE = /^(?:text|application)\/xml/i,
1198
+ jsonType = 'application/json',
1199
+ htmlType = 'text/html',
1200
+ blankRE = /^\s*$/
1201
+
1202
+ // trigger a custom event and return false if it was cancelled
1203
+ function triggerAndReturn(context, eventName, data) {
1204
+ var event = $.Event(eventName)
1205
+ $(context).trigger(event, data)
1206
+ return !event.defaultPrevented
1207
+ }
1208
+
1209
+ // trigger an Ajax "global" event
1210
+ function triggerGlobal(settings, context, eventName, data) {
1211
+ if (settings.global) return triggerAndReturn(context || document, eventName, data)
1212
+ }
1213
+
1214
+ // Number of active Ajax requests
1215
+ $.active = 0
1216
+
1217
+ function ajaxStart(settings) {
1218
+ if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart')
1219
+ }
1220
+ function ajaxStop(settings) {
1221
+ if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop')
1222
+ }
1223
+
1224
+ // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable
1225
+ function ajaxBeforeSend(xhr, settings) {
1226
+ var context = settings.context
1227
+ if (settings.beforeSend.call(context, xhr, settings) === false ||
1228
+ triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false)
1229
+ return false
1230
+
1231
+ triggerGlobal(settings, context, 'ajaxSend', [xhr, settings])
1232
+ }
1233
+ function ajaxSuccess(data, xhr, settings) {
1234
+ var context = settings.context, status = 'success'
1235
+ settings.success.call(context, data, status, xhr)
1236
+ triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])
1237
+ ajaxComplete(status, xhr, settings)
1238
+ }
1239
+ // type: "timeout", "error", "abort", "parsererror"
1240
+ function ajaxError(error, type, xhr, settings) {
1241
+ var context = settings.context
1242
+ settings.error.call(context, xhr, type, error)
1243
+ triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error])
1244
+ ajaxComplete(type, xhr, settings)
1245
+ }
1246
+ // status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
1247
+ function ajaxComplete(status, xhr, settings) {
1248
+ var context = settings.context
1249
+ settings.complete.call(context, xhr, status)
1250
+ triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings])
1251
+ ajaxStop(settings)
1252
+ }
1253
+
1254
+ // Empty function, used as default callback
1255
+ function empty() {}
1256
+
1257
+ $.ajaxJSONP = function(options){
1258
+ if (!('type' in options)) return $.ajax(options)
1259
+
1260
+ var callbackName = 'jsonp' + (++jsonpID),
1261
+ script = document.createElement('script'),
1262
+ abort = function(){
1263
+ $(script).remove()
1264
+ if (callbackName in window) window[callbackName] = empty
1265
+ ajaxComplete('abort', xhr, options)
1266
+ },
1267
+ xhr = { abort: abort }, abortTimeout
1268
+
1269
+ if (options.error) script.onerror = function() {
1270
+ xhr.abort()
1271
+ options.error()
1272
+ }
1273
+
1274
+ window[callbackName] = function(data){
1275
+ clearTimeout(abortTimeout)
1276
+ $(script).remove()
1277
+ delete window[callbackName]
1278
+ ajaxSuccess(data, xhr, options)
1279
+ }
1280
+
1281
+ serializeData(options)
1282
+ script.src = options.url.replace(/=\?/, '=' + callbackName)
1283
+ $('head').append(script)
1284
+
1285
+ if (options.timeout > 0) abortTimeout = setTimeout(function(){
1286
+ xhr.abort()
1287
+ ajaxComplete('timeout', xhr, options)
1288
+ }, options.timeout)
1289
+
1290
+ return xhr
1291
+ }
1292
+
1293
+ $.ajaxSettings = {
1294
+ // Default type of request
1295
+ type: 'GET',
1296
+ // Callback that is executed before request
1297
+ beforeSend: empty,
1298
+ // Callback that is executed if the request succeeds
1299
+ success: empty,
1300
+ // Callback that is executed the the server drops error
1301
+ error: empty,
1302
+ // Callback that is executed on request complete (both: error and success)
1303
+ complete: empty,
1304
+ // The context for the callbacks
1305
+ context: null,
1306
+ // Whether to trigger "global" Ajax events
1307
+ global: true,
1308
+ // Transport
1309
+ xhr: function () {
1310
+ return new window.XMLHttpRequest()
1311
+ },
1312
+ // MIME types mapping
1313
+ accepts: {
1314
+ script: 'text/javascript, application/javascript',
1315
+ json: jsonType,
1316
+ xml: 'application/xml, text/xml',
1317
+ html: htmlType,
1318
+ text: 'text/plain'
1319
+ },
1320
+ // Whether the request is to another domain
1321
+ crossDomain: false,
1322
+ // Default timeout
1323
+ timeout: 0,
1324
+ // Whether data should be serialized to string
1325
+ processData: true
1326
+ }
1327
+
1328
+ function mimeToDataType(mime) {
1329
+ return mime && ( mime == htmlType ? 'html' :
1330
+ mime == jsonType ? 'json' :
1331
+ scriptTypeRE.test(mime) ? 'script' :
1332
+ xmlTypeRE.test(mime) && 'xml' ) || 'text'
1333
+ }
1334
+
1335
+ function appendQuery(url, query) {
1336
+ return (url + '&' + query).replace(/[&?]{1,2}/, '?')
1337
+ }
1338
+
1339
+ // serialize payload and append it to the URL for GET requests
1340
+ function serializeData(options) {
1341
+ if (options.processData && isObject(options.data))
1342
+ options.data = $.param(options.data, options.traditional)
1343
+ if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
1344
+ options.url = appendQuery(options.url, options.data)
1345
+ }
1346
+
1347
+ $.ajax = function(options){
1348
+ var settings = $.extend({}, options || {})
1349
+ for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]
1350
+
1351
+ ajaxStart(settings)
1352
+
1353
+ if (!settings.crossDomain) settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) &&
1354
+ RegExp.$2 != window.location.host
1355
+
1356
+ var dataType = settings.dataType, hasPlaceholder = /=\?/.test(settings.url)
1357
+ if (dataType == 'jsonp' || hasPlaceholder) {
1358
+ if (!hasPlaceholder) settings.url = appendQuery(settings.url, 'callback=?')
1359
+ return $.ajaxJSONP(settings)
1360
+ }
1361
+
1362
+ if (!settings.url) settings.url = window.location.toString()
1363
+ serializeData(settings)
1364
+
1365
+ var mime = settings.accepts[dataType],
1366
+ baseHeaders = { },
1367
+ protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
1368
+ xhr = settings.xhr(), abortTimeout
1369
+
1370
+ if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest'
1371
+ if (mime) {
1372
+ baseHeaders['Accept'] = mime
1373
+ if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0]
1374
+ xhr.overrideMimeType && xhr.overrideMimeType(mime)
1375
+ }
1376
+ if (settings.contentType || (settings.contentType !== false && settings.data && settings.type.toUpperCase() != 'GET'))
1377
+ baseHeaders['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded')
1378
+ settings.headers = $.extend(baseHeaders, settings.headers || {})
1379
+
1380
+ xhr.onreadystatechange = function(){
1381
+ if (xhr.readyState == 4) {
1382
+ xhr.onreadystatechange = empty;
1383
+ clearTimeout(abortTimeout)
1384
+ var result, error = false
1385
+ if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
1386
+ dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
1387
+ result = xhr.responseText
1388
+
1389
+ try {
1390
+ if (dataType == 'script') (1,eval)(result)
1391
+ else if (dataType == 'xml') result = xhr.responseXML
1392
+ else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
1393
+ } catch (e) { error = e }
1394
+
1395
+ if (error) ajaxError(error, 'parsererror', xhr, settings)
1396
+ else ajaxSuccess(result, xhr, settings)
1397
+ } else {
1398
+ ajaxError(null, xhr.status ? 'error' : 'abort', xhr, settings)
1399
+ }
1400
+ }
1401
+ }
1402
+
1403
+ var async = 'async' in settings ? settings.async : true
1404
+ xhr.open(settings.type, settings.url, async)
1405
+
1406
+ for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name])
1407
+
1408
+ if (ajaxBeforeSend(xhr, settings) === false) {
1409
+ xhr.abort()
1410
+ return false
1411
+ }
1412
+
1413
+ if (settings.timeout > 0) abortTimeout = setTimeout(function(){
1414
+ xhr.onreadystatechange = empty
1415
+ xhr.abort()
1416
+ ajaxError(null, 'timeout', xhr, settings)
1417
+ }, settings.timeout)
1418
+
1419
+ // avoid sending empty string (#319)
1420
+ xhr.send(settings.data ? settings.data : null)
1421
+ return xhr
1422
+ }
1423
+
1424
+ $.get = function(url, success){ return $.ajax({ url: url, success: success }) }
1425
+
1426
+ $.post = function(url, data, success, dataType){
1427
+ if ($.isFunction(data)) dataType = dataType || success, success = data, data = null
1428
+ return $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType })
1429
+ }
1430
+
1431
+ $.getJSON = function(url, success){
1432
+ return $.ajax({ url: url, success: success, dataType: 'json' })
1433
+ }
1434
+
1435
+ $.fn.load = function(url, success){
1436
+ if (!this.length) return this
1437
+ var self = this, parts = url.split(/\s/), selector
1438
+ if (parts.length > 1) url = parts[0], selector = parts[1]
1439
+ $.get(url, function(response){
1440
+ self.html(selector ?
1441
+ $('<div>').html(response.replace(rscript, "")).find(selector)
1442
+ : response)
1443
+ success && success.apply(self, arguments)
1444
+ })
1445
+ return this
1446
+ }
1447
+
1448
+ var escape = encodeURIComponent
1449
+
1450
+ function serialize(params, obj, traditional, scope){
1451
+ var array = $.isArray(obj)
1452
+ $.each(obj, function(key, value) {
1453
+ if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'
1454
+ // handle data in serializeArray() format
1455
+ if (!scope && array) params.add(value.name, value.value)
1456
+ // recurse into nested objects
1457
+ else if (traditional ? $.isArray(value) : isObject(value))
1458
+ serialize(params, value, traditional, key)
1459
+ else params.add(key, value)
1460
+ })
1461
+ }
1462
+
1463
+ $.param = function(obj, traditional){
1464
+ var params = []
1465
+ params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }
1466
+ serialize(params, obj, traditional)
1467
+ return params.join('&').replace(/%20/g, '+')
1468
+ }
1469
+ })(Zepto);
1470
+
1471
+
1472
+ // Zepto.js
1473
+ // (c) 2010-2012 Thomas Fuchs
1474
+ // Zepto.js may be freely distributed under the MIT license.
1475
+
1476
+ ;(function ($) {
1477
+ $.fn.serializeArray = function () {
1478
+ var result = [], el
1479
+ $( Array.prototype.slice.call(this.get(0).elements) ).each(function () {
1480
+ el = $(this)
1481
+ var type = el.attr('type')
1482
+ if (this.nodeName.toLowerCase() != 'fieldset' &&
1483
+ !this.disabled && type != 'submit' && type != 'reset' && type != 'button' &&
1484
+ ((type != 'radio' && type != 'checkbox') || this.checked))
1485
+ result.push({
1486
+ name: el.attr('name'),
1487
+ value: el.val()
1488
+ })
1489
+ })
1490
+ return result
1491
+ }
1492
+
1493
+ $.fn.serialize = function () {
1494
+ var result = []
1495
+ this.serializeArray().forEach(function (elm) {
1496
+ result.push( encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value) )
1497
+ })
1498
+ return result.join('&')
1499
+ }
1500
+
1501
+ $.fn.submit = function (callback) {
1502
+ if (callback) this.bind('submit', callback)
1503
+ else if (this.length) {
1504
+ var event = $.Event('submit')
1505
+ this.eq(0).trigger(event)
1506
+ if (!event.defaultPrevented) this.get(0).submit()
1507
+ }
1508
+ return this
1509
+ }
1510
+
1511
+ })(Zepto);
1512
+
1513
+
1514
+ // Zepto.js
1515
+ // (c) 2010-2012 Thomas Fuchs
1516
+ // Zepto.js may be freely distributed under the MIT license.
1517
+
1518
+ ;(function($){
1519
+ var cache = [], timeout
1520
+
1521
+ $.fn.remove = function(){
1522
+ return this.each(function(){
1523
+ if(this.parentNode){
1524
+ if(this.tagName === 'IMG'){
1525
+ cache.push(this)
1526
+ this.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
1527
+ if (timeout) clearTimeout(timeout)
1528
+ timeout = setTimeout(function(){ cache = [] }, 60000)
1529
+ }
1530
+ this.parentNode.removeChild(this)
1531
+ }
1532
+ })
1533
+ }
1534
+ })(Zepto);
1535
+
1536
+
1537
+ // Zepto.js
1538
+ // (c) 2010-2012 Thomas Fuchs
1539
+ // Zepto.js may be freely distributed under the MIT license.
1540
+
1541
+ // The following code is heavily inspired by jQuery's $.fn.data()
1542
+
1543
+ ;(function($) {
1544
+ var data = {}, dataAttr = $.fn.data, camelize = $.camelCase,
1545
+ exp = $.expando = 'Zepto' + (+new Date())
1546
+
1547
+ // Get value from node:
1548
+ // 1. first try key as given,
1549
+ // 2. then try camelized key,
1550
+ // 3. fall back to reading "data-*" attribute.
1551
+ function getData(node, name) {
1552
+ var id = node[exp], store = id && data[id]
1553
+ if (name === undefined) return store || setData(node)
1554
+ else {
1555
+ if (store) {
1556
+ if (name in store) return store[name]
1557
+ var camelName = camelize(name)
1558
+ if (camelName in store) return store[camelName]
1559
+ }
1560
+ return dataAttr.call($(node), name)
1561
+ }
1562
+ }
1563
+
1564
+ // Store value under camelized key on node
1565
+ function setData(node, name, value) {
1566
+ var id = node[exp] || (node[exp] = ++$.uuid),
1567
+ store = data[id] || (data[id] = attributeData(node))
1568
+ if (name !== undefined) store[camelize(name)] = value
1569
+ return store
1570
+ }
1571
+
1572
+ // Read all "data-*" attributes from a node
1573
+ function attributeData(node) {
1574
+ var store = {}
1575
+ $.each(node.attributes, function(i, attr){
1576
+ if (attr.name.indexOf('data-') == 0)
1577
+ store[camelize(attr.name.replace('data-', ''))] =
1578
+ $.zepto.deserializeValue(attr.value)
1579
+ })
1580
+ return store
1581
+ }
1582
+
1583
+ $.fn.data = function(name, value) {
1584
+ return value === undefined ?
1585
+ // set multiple values via object
1586
+ $.isPlainObject(name) ?
1587
+ this.each(function(i, node){
1588
+ $.each(name, function(key, value){ setData(node, key, value) })
1589
+ }) :
1590
+ // get value from first element
1591
+ this.length == 0 ? undefined : getData(this[0], name) :
1592
+ // set value on all elements
1593
+ this.each(function(){ setData(this, name, value) })
1594
+ }
1595
+
1596
+ $.fn.removeData = function(names) {
1597
+ if (typeof names == 'string') names = names.split(/\s+/)
1598
+ return this.each(function(){
1599
+ var id = this[exp], store = id && data[id]
1600
+ if (store) $.each(names, function(){ delete store[camelize(this)] })
1601
+ })
1602
+ }
1603
+ })(Zepto);
1604
+
1605
+
1606
+ ;(function($){
1607
+ var zepto = $.zepto, oldQsa = zepto.qsa, oldMatches = zepto.matches
1608
+
1609
+ function visible(elem){
1610
+ elem = $(elem)
1611
+ return !!(elem.width() || elem.height()) && elem.css("display") !== "none"
1612
+ }
1613
+
1614
+ // Implements a subset from:
1615
+ // http://api.jquery.com/category/selectors/jquery-selector-extensions/
1616
+ //
1617
+ // Each filter function receives the current index, all nodes in the
1618
+ // considered set, and a value if there were parentheses. The value
1619
+ // of `this` is the node currently being considered. The function returns the
1620
+ // resulting node(s), null, or undefined.
1621
+ //
1622
+ // Complex selectors are not supported:
1623
+ // li:has(label:contains("foo")) + li:has(label:contains("bar"))
1624
+ // ul.inner:first > li
1625
+ var filters = $.expr[':'] = {
1626
+ visible: function(){ if (visible(this)) return this },
1627
+ hidden: function(){ if (!visible(this)) return this },
1628
+ selected: function(){ if (this.selected) return this },
1629
+ checked: function(){ if (this.checked) return this },
1630
+ parent: function(){ return this.parentNode },
1631
+ first: function(idx){ if (idx === 0) return this },
1632
+ last: function(idx, nodes){ if (idx === nodes.length - 1) return this },
1633
+ eq: function(idx, _, value){ if (idx === value) return this },
1634
+ contains: function(idx, _, text){ if ($(this).text().indexOf(text) > -1) return this },
1635
+ has: function(idx, _, sel){ if (zepto.qsa(this, sel).length) return this }
1636
+ }
1637
+
1638
+ var filterRe = new RegExp('(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*'),
1639
+ childRe = /^\s*>/,
1640
+ classTag = 'Zepto' + (+new Date())
1641
+
1642
+ function process(sel, fn) {
1643
+ // quote the hash in `a[href^=#]` expression
1644
+ sel = sel.replace(/=#\]/g, '="#"]')
1645
+ var filter, arg, match = filterRe.exec(sel)
1646
+ if (match && match[2] in filters) {
1647
+ var filter = filters[match[2]], arg = match[3]
1648
+ sel = match[1]
1649
+ if (arg) {
1650
+ var num = Number(arg)
1651
+ if (isNaN(num)) arg = arg.replace(/^["']|["']$/g, '')
1652
+ else arg = num
1653
+ }
1654
+ }
1655
+ return fn(sel, filter, arg)
1656
+ }
1657
+
1658
+ zepto.qsa = function(node, selector) {
1659
+ return process(selector, function(sel, filter, arg){
1660
+ try {
1661
+ var taggedParent
1662
+ if (!sel && filter) sel = '*'
1663
+ else if (childRe.test(sel))
1664
+ // support "> *" child queries by tagging the parent node with a
1665
+ // unique class and prepending that classname onto the selector
1666
+ taggedParent = $(node).addClass(classTag), sel = '.'+classTag+' '+sel
1667
+
1668
+ var nodes = oldQsa(node, sel)
1669
+ } catch(e) {
1670
+ console.error('error performing selector: %o', selector)
1671
+ throw e
1672
+ } finally {
1673
+ if (taggedParent) taggedParent.removeClass(classTag)
1674
+ }
1675
+ return !filter ? nodes :
1676
+ zepto.uniq($.map(nodes, function(n, i){ return filter.call(n, i, nodes, arg) }))
1677
+ })
1678
+ }
1679
+
1680
+ zepto.matches = function(node, selector){
1681
+ return process(selector, function(sel, filter, arg){
1682
+ return (!sel || oldMatches(node, sel)) &&
1683
+ (!filter || filter.call(node, null, arg) === node)
1684
+ })
1685
+ }
1686
+ })(Zepto);
1687
+
1688
+
1689
+ // Zepto.js
1690
+ // (c) 2010-2012 Thomas Fuchs
1691
+ // Zepto.js may be freely distributed under the MIT license.
1692
+
1693
+ ;(function($){
1694
+ $.fn.end = function(){
1695
+ return this.prevObject || $()
1696
+ }
1697
+
1698
+ $.fn.andSelf = function(){
1699
+ return this.add(this.prevObject || $())
1700
+ }
1701
+
1702
+ 'filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings'.split(',').forEach(function(property){
1703
+ var fn = $.fn[property]
1704
+ $.fn[property] = function(){
1705
+ var ret = fn.apply(this, arguments)
1706
+ ret.prevObject = this
1707
+ return ret
1708
+ }
1709
+ })
1710
+ })(Zepto);
1711
+
1712
+ // Zepto.js
1713
+ // (c) 2010-2012 Thomas Fuchs
1714
+ // Zepto.js may be freely distributed under the MIT license.
1715
+
1716
+ ;(function($, undefined){
1717
+ var document = window.document, docElem = document.documentElement,
1718
+ origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle
1719
+
1720
+ function anim(el, speed, opacity, scale, callback) {
1721
+ if (typeof speed == 'function' && !callback) callback = speed, speed = undefined
1722
+ var props = { opacity: opacity }
1723
+ if (scale) {
1724
+ props.scale = scale
1725
+ el.css($.fx.cssPrefix + 'transform-origin', '0 0')
1726
+ }
1727
+ return el.animate(props, speed, null, callback)
1728
+ }
1729
+
1730
+ function hide(el, speed, scale, callback) {
1731
+ return anim(el, speed, 0, scale, function(){
1732
+ origHide.call($(this))
1733
+ callback && callback.call(this)
1734
+ })
1735
+ }
1736
+
1737
+ $.fn.show = function(speed, callback) {
1738
+ origShow.call(this)
1739
+ if (speed === undefined) speed = 0
1740
+ else this.css('opacity', 0)
1741
+ return anim(this, speed, 1, '1,1', callback)
1742
+ }
1743
+
1744
+ $.fn.hide = function(speed, callback) {
1745
+ if (speed === undefined) return origHide.call(this)
1746
+ else return hide(this, speed, '0,0', callback)
1747
+ }
1748
+
1749
+ $.fn.toggle = function(speed, callback) {
1750
+ if (speed === undefined || typeof speed == 'boolean')
1751
+ return origToggle.call(this, speed)
1752
+ else return this.each(function(){
1753
+ var el = $(this)
1754
+ el[el.css('display') == 'none' ? 'show' : 'hide'](speed, callback)
1755
+ })
1756
+ }
1757
+
1758
+ $.fn.fadeTo = function(speed, opacity, callback) {
1759
+ return anim(this, speed, opacity, null, callback)
1760
+ }
1761
+
1762
+ $.fn.fadeIn = function(speed, callback) {
1763
+ var target = this.css('opacity')
1764
+ if (target > 0) this.css('opacity', 0)
1765
+ else target = 1
1766
+ return origShow.call(this).fadeTo(speed, target, callback)
1767
+ }
1768
+
1769
+ $.fn.fadeOut = function(speed, callback) {
1770
+ return hide(this, speed, null, callback)
1771
+ }
1772
+
1773
+ $.fn.fadeToggle = function(speed, callback) {
1774
+ return this.each(function(){
1775
+ var el = $(this)
1776
+ el[
1777
+ (el.css('opacity') == 0 || el.css('display') == 'none') ? 'fadeIn' : 'fadeOut'
1778
+ ](speed, callback)
1779
+ })
1780
+ }
1781
+
1782
+ })(Zepto)