sports_db 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascripts/clients/android/client.js +53 -0
- data/app/assets/javascripts/clients/ios/client.js +58 -0
- data/app/assets/javascripts/core/Application.js +173 -0
- data/app/assets/javascripts/core/BaseView.js +117 -0
- data/app/assets/javascripts/core/History.js +45 -0
- data/app/assets/javascripts/core/Mock.js +90 -0
- data/app/assets/javascripts/core/Timer.js +18 -0
- data/app/assets/javascripts/core/View.js +56 -0
- data/app/assets/javascripts/core/utilities.js +81 -0
- data/app/assets/javascripts/libs/SimpleInheritance.js +53 -0
- data/app/assets/javascripts/libs/microjungle.zepto.js +45 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/ajax.js +279 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/assets.js +21 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/data.js +66 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/detect.js +40 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/event.js +224 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/form.js +40 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/fx.js +91 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/fx_methods.js +72 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/gesture.js +35 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/polyfill.js +36 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/selector.js +70 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/stack.js +22 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/touch.js +85 -0
- data/app/assets/javascripts/libs/zepto-v1.0rc1/zepto.js +591 -0
- data/app/assets/javascripts/libs/zepto_0.8.js +1213 -0
- data/app/assets/javascripts/plugins/assert.js +11 -0
- data/app/assets/javascripts/plugins/calnav.js +18 -0
- data/app/assets/javascripts/plugins/detect.js +16 -0
- data/app/assets/javascripts/plugins/filterable.js +12 -0
- data/app/assets/javascripts/plugins/flash.js +15 -0
- data/app/assets/javascripts/plugins/jquery.zumobi-0.2.js +57 -0
- data/app/assets/javascripts/plugins/loading.js +47 -0
- data/app/assets/javascripts/plugins/params.js +27 -0
- data/app/assets/javascripts/plugins/resizeable.js +40 -0
- data/app/assets/stylesheets/_base.css.scss +42 -0
- data/app/assets/stylesheets/_filterable.css.scss +19 -0
- data/app/assets/stylesheets/_flash.css.scss +9 -0
- data/app/assets/stylesheets/_loading.css.scss +28 -0
- data/app/assets/stylesheets/_play.css.scss +38 -0
- data/app/assets/stylesheets/_reset.css.scss +33 -0
- data/app/assets/stylesheets/_table_base.scss +121 -0
- data/app/assets/stylesheets/mock.css.scss +52 -0
- data/app/controllers/application_controller.rb +39 -0
- data/app/views/application/load.html.erb +1 -0
- data/app/views/layouts/application.html.erb +27 -0
- data/lib/sports_db/version.rb +1 -1
- metadata +90 -5
@@ -0,0 +1,591 @@
|
|
1
|
+
// Zepto.js
|
2
|
+
// (c) 2010-2012 Thomas Fuchs
|
3
|
+
// Zepto.js may be freely distributed under the MIT license.
|
4
|
+
|
5
|
+
var Zepto = (function() {
|
6
|
+
var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice,
|
7
|
+
document = window.document,
|
8
|
+
elementDisplay = {}, classCache = {},
|
9
|
+
getComputedStyle = document.defaultView.getComputedStyle,
|
10
|
+
cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
|
11
|
+
fragmentRE = /^\s*<(\w+|!)[^>]*>/,
|
12
|
+
|
13
|
+
// Used by `$.zepto.init` to wrap elements, text/comment nodes, document,
|
14
|
+
// and document fragment node types.
|
15
|
+
elementTypes = [1, 3, 8, 9, 11],
|
16
|
+
|
17
|
+
adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
|
18
|
+
table = document.createElement('table'),
|
19
|
+
tableRow = document.createElement('tr'),
|
20
|
+
containers = {
|
21
|
+
'tr': document.createElement('tbody'),
|
22
|
+
'tbody': table, 'thead': table, 'tfoot': table,
|
23
|
+
'td': tableRow, 'th': tableRow,
|
24
|
+
'*': document.createElement('div')
|
25
|
+
},
|
26
|
+
readyRE = /complete|loaded|interactive/,
|
27
|
+
classSelectorRE = /^\.([\w-]+)$/,
|
28
|
+
idSelectorRE = /^#([\w-]+)$/,
|
29
|
+
tagSelectorRE = /^[\w-]+$/,
|
30
|
+
toString = ({}).toString,
|
31
|
+
zepto = {},
|
32
|
+
camelize, uniq,
|
33
|
+
tempParent = document.createElement('div')
|
34
|
+
|
35
|
+
zepto.matches = function(element, selector) {
|
36
|
+
if (!element || element.nodeType !== 1) return false
|
37
|
+
var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||
|
38
|
+
element.oMatchesSelector || element.matchesSelector
|
39
|
+
if (matchesSelector) return matchesSelector.call(element, selector)
|
40
|
+
// fall back to performing a selector:
|
41
|
+
var match, parent = element.parentNode, temp = !parent
|
42
|
+
if (temp) (parent = tempParent).appendChild(element)
|
43
|
+
match = ~zepto.qsa(parent, selector).indexOf(element)
|
44
|
+
temp && tempParent.removeChild(element)
|
45
|
+
return match
|
46
|
+
}
|
47
|
+
|
48
|
+
function isFunction(value) { return toString.call(value) == "[object Function]" }
|
49
|
+
function isObject(value) { return value instanceof Object }
|
50
|
+
function isPlainObject(value) {
|
51
|
+
var key, ctor
|
52
|
+
if (toString.call(value) !== "[object Object]") return false
|
53
|
+
ctor = (isFunction(value.constructor) && value.constructor.prototype)
|
54
|
+
if (!ctor || !hasOwnProperty.call(ctor, 'isPrototypeOf')) return false
|
55
|
+
for (key in value);
|
56
|
+
return key === undefined || hasOwnProperty.call(value, key)
|
57
|
+
}
|
58
|
+
function isArray(value) { return value instanceof Array }
|
59
|
+
function likeArray(obj) { return typeof obj.length == 'number' }
|
60
|
+
|
61
|
+
function compact(array) { return array.filter(function(item){ return item !== undefined && item !== null }) }
|
62
|
+
function flatten(array) { return array.length > 0 ? [].concat.apply([], array) : array }
|
63
|
+
camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
|
64
|
+
function dasherize(str) {
|
65
|
+
return str.replace(/::/g, '/')
|
66
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
|
67
|
+
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
|
68
|
+
.replace(/_/g, '-')
|
69
|
+
.toLowerCase()
|
70
|
+
}
|
71
|
+
uniq = function(array){ return array.filter(function(item, idx){ return array.indexOf(item) == idx }) }
|
72
|
+
|
73
|
+
function classRE(name) {
|
74
|
+
return name in classCache ?
|
75
|
+
classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'))
|
76
|
+
}
|
77
|
+
|
78
|
+
function maybeAddPx(name, value) {
|
79
|
+
return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value
|
80
|
+
}
|
81
|
+
|
82
|
+
function defaultDisplay(nodeName) {
|
83
|
+
var element, display
|
84
|
+
if (!elementDisplay[nodeName]) {
|
85
|
+
element = document.createElement(nodeName)
|
86
|
+
document.body.appendChild(element)
|
87
|
+
display = getComputedStyle(element, '').getPropertyValue("display")
|
88
|
+
element.parentNode.removeChild(element)
|
89
|
+
display == "none" && (display = "block")
|
90
|
+
elementDisplay[nodeName] = display
|
91
|
+
}
|
92
|
+
return elementDisplay[nodeName]
|
93
|
+
}
|
94
|
+
|
95
|
+
// `$.zepto.fragment` takes a html string and an optional tag name
|
96
|
+
// to generate DOM nodes nodes from the given html string.
|
97
|
+
// The generated DOM nodes are returned as an array.
|
98
|
+
// This function can be overriden in plugins for example to make
|
99
|
+
// it compatible with browsers that don't support the DOM fully.
|
100
|
+
zepto.fragment = function(html, name) {
|
101
|
+
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
|
102
|
+
if (!(name in containers)) name = '*'
|
103
|
+
var container = containers[name]
|
104
|
+
container.innerHTML = '' + html
|
105
|
+
return $.each(slice.call(container.childNodes), function(){
|
106
|
+
container.removeChild(this)
|
107
|
+
})
|
108
|
+
}
|
109
|
+
|
110
|
+
// `$.zepto.Z` swaps out the prototype of the given `dom` array
|
111
|
+
// of nodes with `$.fn` and thus supplying all the Zepto functions
|
112
|
+
// to the array. Note that `__proto__` is not supported on Internet
|
113
|
+
// Explorer. This method can be overriden in plugins.
|
114
|
+
zepto.Z = function(dom, selector) {
|
115
|
+
dom = dom || []
|
116
|
+
dom.__proto__ = arguments.callee.prototype
|
117
|
+
dom.selector = selector || ''
|
118
|
+
return dom
|
119
|
+
}
|
120
|
+
|
121
|
+
// `$.zepto.isZ` should return `true` if the given object is a Zepto
|
122
|
+
// collection. This method can be overriden in plugins.
|
123
|
+
zepto.isZ = function(object) {
|
124
|
+
return object instanceof zepto.Z
|
125
|
+
}
|
126
|
+
|
127
|
+
// `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
|
128
|
+
// takes a CSS selector and an optional context (and handles various
|
129
|
+
// special cases).
|
130
|
+
// This method can be overriden in plugins.
|
131
|
+
zepto.init = function(selector, context) {
|
132
|
+
// If nothing given, return an empty Zepto collection
|
133
|
+
if (!selector) return zepto.Z()
|
134
|
+
// If a function is given, call it when the DOM is ready
|
135
|
+
else if (isFunction(selector)) return $(document).ready(selector)
|
136
|
+
// If a Zepto collection is given, juts return it
|
137
|
+
else if (zepto.isZ(selector)) return selector
|
138
|
+
else {
|
139
|
+
var dom
|
140
|
+
// normalize array if an array of nodes is given
|
141
|
+
if (isArray(selector)) dom = compact(selector)
|
142
|
+
// if a JavaScript object is given, return a copy of it
|
143
|
+
// this is a somewhat peculiar option, but supported by
|
144
|
+
// jQuery so we'll do it, too
|
145
|
+
else if (isPlainObject(selector))
|
146
|
+
dom = [$.extend({}, selector)], selector = null
|
147
|
+
// wrap stuff like `document` or `window`
|
148
|
+
else if (elementTypes.indexOf(selector.nodeType) >= 0 || selector === window)
|
149
|
+
dom = [selector], selector = null
|
150
|
+
// If it's a html fragment, create nodes from it
|
151
|
+
else if (fragmentRE.test(selector))
|
152
|
+
dom = zepto.fragment(selector.trim(), RegExp.$1), selector = null
|
153
|
+
// If there's a context, create a collection on that context first, and select
|
154
|
+
// nodes from there
|
155
|
+
else if (context !== undefined) return $(context).find(selector)
|
156
|
+
// And last but no least, if it's a CSS selector, use it to select nodes.
|
157
|
+
else dom = zepto.qsa(document, selector)
|
158
|
+
// create a new Zepto collection from the nodes found
|
159
|
+
return zepto.Z(dom, selector)
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
// `$` will be the base `Zepto` object. When calling this
|
164
|
+
// function just call `$.zepto.init, whichs makes the implementation
|
165
|
+
// details of selecting nodes and creating Zepto collections
|
166
|
+
// patchable in plugins.
|
167
|
+
$ = function(selector, context){
|
168
|
+
return zepto.init(selector, context)
|
169
|
+
}
|
170
|
+
|
171
|
+
// Copy all but undefined properties from one or more
|
172
|
+
// objects to the `target` object.
|
173
|
+
$.extend = function(target){
|
174
|
+
slice.call(arguments, 1).forEach(function(source) {
|
175
|
+
for (key in source)
|
176
|
+
if (source[key] !== undefined)
|
177
|
+
target[key] = source[key]
|
178
|
+
})
|
179
|
+
return target
|
180
|
+
}
|
181
|
+
|
182
|
+
// `$.zepto.qsa` is Zepto's CSS selector implementation which
|
183
|
+
// uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
|
184
|
+
// This method can be overriden in plugins.
|
185
|
+
zepto.qsa = function(element, selector){
|
186
|
+
var found
|
187
|
+
return (element === document && idSelectorRE.test(selector)) ?
|
188
|
+
( (found = element.getElementById(RegExp.$1)) ? [found] : emptyArray ) :
|
189
|
+
(element.nodeType !== 1 && element.nodeType !== 9) ? emptyArray :
|
190
|
+
slice.call(
|
191
|
+
classSelectorRE.test(selector) ? element.getElementsByClassName(RegExp.$1) :
|
192
|
+
tagSelectorRE.test(selector) ? element.getElementsByTagName(selector) :
|
193
|
+
element.querySelectorAll(selector)
|
194
|
+
)
|
195
|
+
}
|
196
|
+
|
197
|
+
function filtered(nodes, selector) {
|
198
|
+
return selector === undefined ? $(nodes) : $(nodes).filter(selector)
|
199
|
+
}
|
200
|
+
|
201
|
+
function funcArg(context, arg, idx, payload) {
|
202
|
+
return isFunction(arg) ? arg.call(context, idx, payload) : arg
|
203
|
+
}
|
204
|
+
|
205
|
+
$.isFunction = isFunction
|
206
|
+
$.isObject = isObject
|
207
|
+
$.isArray = isArray
|
208
|
+
$.isPlainObject = isPlainObject
|
209
|
+
|
210
|
+
$.inArray = function(elem, array, i){
|
211
|
+
return emptyArray.indexOf.call(array, elem, i)
|
212
|
+
}
|
213
|
+
|
214
|
+
$.trim = function(str) { return str.trim() }
|
215
|
+
|
216
|
+
// plugin compatibility
|
217
|
+
$.uuid = 0
|
218
|
+
|
219
|
+
$.map = function(elements, callback){
|
220
|
+
var value, values = [], i, key
|
221
|
+
if (likeArray(elements))
|
222
|
+
for (i = 0; i < elements.length; i++) {
|
223
|
+
value = callback(elements[i], i)
|
224
|
+
if (value != null) values.push(value)
|
225
|
+
}
|
226
|
+
else
|
227
|
+
for (key in elements) {
|
228
|
+
value = callback(elements[key], key)
|
229
|
+
if (value != null) values.push(value)
|
230
|
+
}
|
231
|
+
return flatten(values)
|
232
|
+
}
|
233
|
+
|
234
|
+
$.each = function(elements, callback){
|
235
|
+
var i, key
|
236
|
+
if (likeArray(elements)) {
|
237
|
+
for (i = 0; i < elements.length; i++)
|
238
|
+
if (callback.call(elements[i], i, elements[i]) === false) return elements
|
239
|
+
} else {
|
240
|
+
for (key in elements)
|
241
|
+
if (callback.call(elements[key], key, elements[key]) === false) return elements
|
242
|
+
}
|
243
|
+
|
244
|
+
return elements
|
245
|
+
}
|
246
|
+
|
247
|
+
// Define methods that will be available on all
|
248
|
+
// Zepto collections
|
249
|
+
$.fn = {
|
250
|
+
// Because a collection acts like an array
|
251
|
+
// copy over these useful array functions.
|
252
|
+
forEach: emptyArray.forEach,
|
253
|
+
reduce: emptyArray.reduce,
|
254
|
+
push: emptyArray.push,
|
255
|
+
indexOf: emptyArray.indexOf,
|
256
|
+
concat: emptyArray.concat,
|
257
|
+
|
258
|
+
// `map` and `slice` in the jQuery API work differently
|
259
|
+
// from their array counterparts
|
260
|
+
map: function(fn){
|
261
|
+
return $.map(this, function(el, i){ return fn.call(el, i, el) })
|
262
|
+
},
|
263
|
+
slice: function(){
|
264
|
+
return $(slice.apply(this, arguments))
|
265
|
+
},
|
266
|
+
|
267
|
+
ready: function(callback){
|
268
|
+
if (readyRE.test(document.readyState)) callback($)
|
269
|
+
else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
|
270
|
+
return this
|
271
|
+
},
|
272
|
+
get: function(idx){
|
273
|
+
return idx === undefined ? slice.call(this) : this[idx]
|
274
|
+
},
|
275
|
+
toArray: function(){ return this.get() },
|
276
|
+
size: function(){
|
277
|
+
return this.length
|
278
|
+
},
|
279
|
+
remove: function(){
|
280
|
+
return this.each(function(){
|
281
|
+
if (this.parentNode != null)
|
282
|
+
this.parentNode.removeChild(this)
|
283
|
+
})
|
284
|
+
},
|
285
|
+
each: function(callback){
|
286
|
+
this.forEach(function(el, idx){ callback.call(el, idx, el) })
|
287
|
+
return this
|
288
|
+
},
|
289
|
+
filter: function(selector){
|
290
|
+
return $([].filter.call(this, function(element){
|
291
|
+
return zepto.matches(element, selector)
|
292
|
+
}))
|
293
|
+
},
|
294
|
+
add: function(selector,context){
|
295
|
+
return $(uniq(this.concat($(selector,context))))
|
296
|
+
},
|
297
|
+
is: function(selector){
|
298
|
+
return this.length > 0 && zepto.matches(this[0], selector)
|
299
|
+
},
|
300
|
+
not: function(selector){
|
301
|
+
var nodes=[]
|
302
|
+
if (isFunction(selector) && selector.call !== undefined)
|
303
|
+
this.each(function(idx){
|
304
|
+
if (!selector.call(this,idx)) nodes.push(this)
|
305
|
+
})
|
306
|
+
else {
|
307
|
+
var excludes = typeof selector == 'string' ? this.filter(selector) :
|
308
|
+
(likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)
|
309
|
+
this.forEach(function(el){
|
310
|
+
if (excludes.indexOf(el) < 0) nodes.push(el)
|
311
|
+
})
|
312
|
+
}
|
313
|
+
return $(nodes)
|
314
|
+
},
|
315
|
+
eq: function(idx){
|
316
|
+
return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)
|
317
|
+
},
|
318
|
+
first: function(){
|
319
|
+
var el = this[0]
|
320
|
+
return el && !isObject(el) ? el : $(el)
|
321
|
+
},
|
322
|
+
last: function(){
|
323
|
+
var el = this[this.length - 1]
|
324
|
+
return el && !isObject(el) ? el : $(el)
|
325
|
+
},
|
326
|
+
find: function(selector){
|
327
|
+
var result
|
328
|
+
if (this.length == 1) result = zepto.qsa(this[0], selector)
|
329
|
+
else result = this.map(function(){ return zepto.qsa(this, selector) })
|
330
|
+
return $(result)
|
331
|
+
},
|
332
|
+
closest: function(selector, context){
|
333
|
+
var node = this[0]
|
334
|
+
while (node && !zepto.matches(node, selector))
|
335
|
+
node = node !== context && node !== document && node.parentNode
|
336
|
+
return $(node)
|
337
|
+
},
|
338
|
+
parents: function(selector){
|
339
|
+
var ancestors = [], nodes = this
|
340
|
+
while (nodes.length > 0)
|
341
|
+
nodes = $.map(nodes, function(node){
|
342
|
+
if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {
|
343
|
+
ancestors.push(node)
|
344
|
+
return node
|
345
|
+
}
|
346
|
+
})
|
347
|
+
return filtered(ancestors, selector)
|
348
|
+
},
|
349
|
+
parent: function(selector){
|
350
|
+
return filtered(uniq(this.pluck('parentNode')), selector)
|
351
|
+
},
|
352
|
+
children: function(selector){
|
353
|
+
return filtered(this.map(function(){ return slice.call(this.children) }), selector)
|
354
|
+
},
|
355
|
+
siblings: function(selector){
|
356
|
+
return filtered(this.map(function(i, el){
|
357
|
+
return slice.call(el.parentNode.children).filter(function(child){ return child!==el })
|
358
|
+
}), selector)
|
359
|
+
},
|
360
|
+
empty: function(){
|
361
|
+
return this.each(function(){ this.innerHTML = '' })
|
362
|
+
},
|
363
|
+
// `pluck` is borrowed from Prototype.js
|
364
|
+
pluck: function(property){
|
365
|
+
return this.map(function(){ return this[property] })
|
366
|
+
},
|
367
|
+
show: function(){
|
368
|
+
return this.each(function(){
|
369
|
+
this.style.display == "none" && (this.style.display = null)
|
370
|
+
if (getComputedStyle(this, '').getPropertyValue("display") == "none")
|
371
|
+
this.style.display = defaultDisplay(this.nodeName)
|
372
|
+
})
|
373
|
+
},
|
374
|
+
replaceWith: function(newContent){
|
375
|
+
return this.before(newContent).remove()
|
376
|
+
},
|
377
|
+
wrap: function(newContent){
|
378
|
+
return this.each(function(){
|
379
|
+
$(this).wrapAll($(newContent)[0].cloneNode(false))
|
380
|
+
})
|
381
|
+
},
|
382
|
+
wrapAll: function(newContent){
|
383
|
+
if (this[0]) {
|
384
|
+
$(this[0]).before(newContent = $(newContent))
|
385
|
+
newContent.append(this)
|
386
|
+
}
|
387
|
+
return this
|
388
|
+
},
|
389
|
+
unwrap: function(){
|
390
|
+
this.parent().each(function(){
|
391
|
+
$(this).replaceWith($(this).children())
|
392
|
+
})
|
393
|
+
return this
|
394
|
+
},
|
395
|
+
clone: function(){
|
396
|
+
return $(this.map(function(){ return this.cloneNode(true) }))
|
397
|
+
},
|
398
|
+
hide: function(){
|
399
|
+
return this.css("display", "none")
|
400
|
+
},
|
401
|
+
toggle: function(setting){
|
402
|
+
return (setting === undefined ? this.css("display") == "none" : setting) ? this.show() : this.hide()
|
403
|
+
},
|
404
|
+
prev: function(){ return $(this.pluck('previousElementSibling')) },
|
405
|
+
next: function(){ return $(this.pluck('nextElementSibling')) },
|
406
|
+
html: function(html){
|
407
|
+
return html === undefined ?
|
408
|
+
(this.length > 0 ? this[0].innerHTML : null) :
|
409
|
+
this.each(function(idx){
|
410
|
+
var originHtml = this.innerHTML
|
411
|
+
$(this).empty().append( funcArg(this, html, idx, originHtml) )
|
412
|
+
})
|
413
|
+
},
|
414
|
+
text: function(text){
|
415
|
+
return text === undefined ?
|
416
|
+
(this.length > 0 ? this[0].textContent : null) :
|
417
|
+
this.each(function(){ this.textContent = text })
|
418
|
+
},
|
419
|
+
attr: function(name, value){
|
420
|
+
var result
|
421
|
+
return (typeof name == 'string' && value === undefined) ?
|
422
|
+
(this.length == 0 || this[0].nodeType !== 1 ? undefined :
|
423
|
+
(name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :
|
424
|
+
(!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
|
425
|
+
) :
|
426
|
+
this.each(function(idx){
|
427
|
+
if (this.nodeType !== 1) return
|
428
|
+
if (isObject(name)) for (key in name) this.setAttribute(key, name[key])
|
429
|
+
else this.setAttribute(name, funcArg(this, value, idx, this.getAttribute(name)))
|
430
|
+
})
|
431
|
+
},
|
432
|
+
removeAttr: function(name){
|
433
|
+
return this.each(function(){ if (this.nodeType === 1) this.removeAttribute(name) })
|
434
|
+
},
|
435
|
+
prop: function(name, value){
|
436
|
+
return (value === undefined) ?
|
437
|
+
(this[0] ? this[0][name] : undefined) :
|
438
|
+
this.each(function(idx){
|
439
|
+
this[name] = funcArg(this, value, idx, this[name])
|
440
|
+
})
|
441
|
+
},
|
442
|
+
data: function(name, value){
|
443
|
+
var data = this.attr('data-' + dasherize(name), value)
|
444
|
+
return data !== null ? data : undefined
|
445
|
+
},
|
446
|
+
val: function(value){
|
447
|
+
return (value === undefined) ?
|
448
|
+
(this.length > 0 ? this[0].value : undefined) :
|
449
|
+
this.each(function(idx){
|
450
|
+
this.value = funcArg(this, value, idx, this.value)
|
451
|
+
})
|
452
|
+
},
|
453
|
+
offset: function(){
|
454
|
+
if (this.length==0) return null
|
455
|
+
var obj = this[0].getBoundingClientRect()
|
456
|
+
return {
|
457
|
+
left: obj.left + window.pageXOffset,
|
458
|
+
top: obj.top + window.pageYOffset,
|
459
|
+
width: obj.width,
|
460
|
+
height: obj.height
|
461
|
+
}
|
462
|
+
},
|
463
|
+
css: function(property, value){
|
464
|
+
if (value === undefined && typeof property == 'string')
|
465
|
+
return (
|
466
|
+
this.length == 0
|
467
|
+
? undefined
|
468
|
+
: this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
|
469
|
+
|
470
|
+
var css = ''
|
471
|
+
for (key in property)
|
472
|
+
if(typeof property[key] == 'string' && property[key] == '')
|
473
|
+
this.each(function(){ this.style.removeProperty(dasherize(key)) })
|
474
|
+
else
|
475
|
+
css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
|
476
|
+
|
477
|
+
if (typeof property == 'string')
|
478
|
+
if (value == '')
|
479
|
+
this.each(function(){ this.style.removeProperty(dasherize(property)) })
|
480
|
+
else
|
481
|
+
css = dasherize(property) + ":" + maybeAddPx(property, value)
|
482
|
+
|
483
|
+
return this.each(function(){ this.style.cssText += ';' + css })
|
484
|
+
},
|
485
|
+
index: function(element){
|
486
|
+
return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])
|
487
|
+
},
|
488
|
+
hasClass: function(name){
|
489
|
+
if (this.length < 1) return false
|
490
|
+
else return classRE(name).test(this[0].className)
|
491
|
+
},
|
492
|
+
addClass: function(name){
|
493
|
+
return this.each(function(idx){
|
494
|
+
classList = []
|
495
|
+
var cls = this.className, newName = funcArg(this, name, idx, cls)
|
496
|
+
newName.split(/\s+/g).forEach(function(klass){
|
497
|
+
if (!$(this).hasClass(klass)) classList.push(klass)
|
498
|
+
}, this)
|
499
|
+
classList.length && (this.className += (cls ? " " : "") + classList.join(" "))
|
500
|
+
})
|
501
|
+
},
|
502
|
+
removeClass: function(name){
|
503
|
+
return this.each(function(idx){
|
504
|
+
if (name === undefined)
|
505
|
+
return this.className = ''
|
506
|
+
classList = this.className
|
507
|
+
funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){
|
508
|
+
classList = classList.replace(classRE(klass), " ")
|
509
|
+
})
|
510
|
+
this.className = classList.trim()
|
511
|
+
})
|
512
|
+
},
|
513
|
+
toggleClass: function(name, when){
|
514
|
+
return this.each(function(idx){
|
515
|
+
var newName = funcArg(this, name, idx, this.className)
|
516
|
+
;(when === undefined ? !$(this).hasClass(newName) : when) ?
|
517
|
+
$(this).addClass(newName) : $(this).removeClass(newName)
|
518
|
+
})
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
522
|
+
// Generate the `width` and `height` functions
|
523
|
+
;['width', 'height'].forEach(function(dimension){
|
524
|
+
$.fn[dimension] = function(value){
|
525
|
+
var offset, Dimension = dimension.replace(/./, function(m){ return m[0].toUpperCase() })
|
526
|
+
if (value === undefined) return this[0] == window ? window['inner' + Dimension] :
|
527
|
+
this[0] == document ? document.documentElement['offset' + Dimension] :
|
528
|
+
(offset = this.offset()) && offset[dimension]
|
529
|
+
else return this.each(function(idx){
|
530
|
+
var el = $(this)
|
531
|
+
el.css(dimension, funcArg(this, value, idx, el[dimension]()))
|
532
|
+
})
|
533
|
+
}
|
534
|
+
})
|
535
|
+
|
536
|
+
function insert(operator, target, node) {
|
537
|
+
var parent = (operator % 2) ? target : target.parentNode
|
538
|
+
parent ? parent.insertBefore(node,
|
539
|
+
!operator ? target.nextSibling : // after
|
540
|
+
operator == 1 ? parent.firstChild : // prepend
|
541
|
+
operator == 2 ? target : // before
|
542
|
+
null) : // append
|
543
|
+
$(node).remove()
|
544
|
+
}
|
545
|
+
|
546
|
+
function traverseNode(node, fun) {
|
547
|
+
fun(node)
|
548
|
+
for (var key in node.childNodes) traverseNode(node.childNodes[key], fun)
|
549
|
+
}
|
550
|
+
|
551
|
+
// Generate the `after`, `prepend`, `before`, `append`,
|
552
|
+
// `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
|
553
|
+
adjacencyOperators.forEach(function(key, operator) {
|
554
|
+
$.fn[key] = function(){
|
555
|
+
// arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
|
556
|
+
var nodes = $.map(arguments, function(n){ return isObject(n) ? n : zepto.fragment(n) })
|
557
|
+
if (nodes.length < 1) return this
|
558
|
+
var size = this.length, copyByClone = size > 1, inReverse = operator < 2
|
559
|
+
|
560
|
+
return this.each(function(index, target){
|
561
|
+
for (var i = 0; i < nodes.length; i++) {
|
562
|
+
var node = nodes[inReverse ? nodes.length-i-1 : i]
|
563
|
+
traverseNode(node, function(node){
|
564
|
+
if (node.nodeName != null && node.nodeName.toUpperCase() === 'SCRIPT' && (!node.type || node.type === 'text/javascript'))
|
565
|
+
window['eval'].call(window, node.innerHTML)
|
566
|
+
})
|
567
|
+
if (copyByClone && index < size - 1) node = node.cloneNode(true)
|
568
|
+
insert(operator, target, node)
|
569
|
+
}
|
570
|
+
})
|
571
|
+
}
|
572
|
+
|
573
|
+
$.fn[(operator % 2) ? key+'To' : 'insert'+(operator ? 'Before' : 'After')] = function(html){
|
574
|
+
$(html)[key](this)
|
575
|
+
return this
|
576
|
+
}
|
577
|
+
})
|
578
|
+
|
579
|
+
zepto.Z.prototype = $.fn
|
580
|
+
|
581
|
+
// Export internal API functions in the `$.zepto` namespace
|
582
|
+
zepto.camelize = camelize
|
583
|
+
zepto.uniq = uniq
|
584
|
+
$.zepto = zepto
|
585
|
+
|
586
|
+
return $
|
587
|
+
})()
|
588
|
+
|
589
|
+
// If `$` is not yet defined, point it to `Zepto`
|
590
|
+
window.Zepto = Zepto
|
591
|
+
'$' in window || (window.$ = Zepto)
|