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.
Files changed (48) hide show
  1. data/app/assets/javascripts/clients/android/client.js +53 -0
  2. data/app/assets/javascripts/clients/ios/client.js +58 -0
  3. data/app/assets/javascripts/core/Application.js +173 -0
  4. data/app/assets/javascripts/core/BaseView.js +117 -0
  5. data/app/assets/javascripts/core/History.js +45 -0
  6. data/app/assets/javascripts/core/Mock.js +90 -0
  7. data/app/assets/javascripts/core/Timer.js +18 -0
  8. data/app/assets/javascripts/core/View.js +56 -0
  9. data/app/assets/javascripts/core/utilities.js +81 -0
  10. data/app/assets/javascripts/libs/SimpleInheritance.js +53 -0
  11. data/app/assets/javascripts/libs/microjungle.zepto.js +45 -0
  12. data/app/assets/javascripts/libs/zepto-v1.0rc1/ajax.js +279 -0
  13. data/app/assets/javascripts/libs/zepto-v1.0rc1/assets.js +21 -0
  14. data/app/assets/javascripts/libs/zepto-v1.0rc1/data.js +66 -0
  15. data/app/assets/javascripts/libs/zepto-v1.0rc1/detect.js +40 -0
  16. data/app/assets/javascripts/libs/zepto-v1.0rc1/event.js +224 -0
  17. data/app/assets/javascripts/libs/zepto-v1.0rc1/form.js +40 -0
  18. data/app/assets/javascripts/libs/zepto-v1.0rc1/fx.js +91 -0
  19. data/app/assets/javascripts/libs/zepto-v1.0rc1/fx_methods.js +72 -0
  20. data/app/assets/javascripts/libs/zepto-v1.0rc1/gesture.js +35 -0
  21. data/app/assets/javascripts/libs/zepto-v1.0rc1/polyfill.js +36 -0
  22. data/app/assets/javascripts/libs/zepto-v1.0rc1/selector.js +70 -0
  23. data/app/assets/javascripts/libs/zepto-v1.0rc1/stack.js +22 -0
  24. data/app/assets/javascripts/libs/zepto-v1.0rc1/touch.js +85 -0
  25. data/app/assets/javascripts/libs/zepto-v1.0rc1/zepto.js +591 -0
  26. data/app/assets/javascripts/libs/zepto_0.8.js +1213 -0
  27. data/app/assets/javascripts/plugins/assert.js +11 -0
  28. data/app/assets/javascripts/plugins/calnav.js +18 -0
  29. data/app/assets/javascripts/plugins/detect.js +16 -0
  30. data/app/assets/javascripts/plugins/filterable.js +12 -0
  31. data/app/assets/javascripts/plugins/flash.js +15 -0
  32. data/app/assets/javascripts/plugins/jquery.zumobi-0.2.js +57 -0
  33. data/app/assets/javascripts/plugins/loading.js +47 -0
  34. data/app/assets/javascripts/plugins/params.js +27 -0
  35. data/app/assets/javascripts/plugins/resizeable.js +40 -0
  36. data/app/assets/stylesheets/_base.css.scss +42 -0
  37. data/app/assets/stylesheets/_filterable.css.scss +19 -0
  38. data/app/assets/stylesheets/_flash.css.scss +9 -0
  39. data/app/assets/stylesheets/_loading.css.scss +28 -0
  40. data/app/assets/stylesheets/_play.css.scss +38 -0
  41. data/app/assets/stylesheets/_reset.css.scss +33 -0
  42. data/app/assets/stylesheets/_table_base.scss +121 -0
  43. data/app/assets/stylesheets/mock.css.scss +52 -0
  44. data/app/controllers/application_controller.rb +39 -0
  45. data/app/views/application/load.html.erb +1 -0
  46. data/app/views/layouts/application.html.erb +27 -0
  47. data/lib/sports_db/version.rb +1 -1
  48. metadata +90 -5
@@ -0,0 +1,224 @@
1
+ // Zepto.js
2
+ // (c) 2010-2012 Thomas Fuchs
3
+ // Zepto.js may be freely distributed under the MIT license.
4
+
5
+ ;(function($){
6
+ var $$ = $.zepto.qsa, handlers = {}, _zid = 1, specialEvents={}
7
+
8
+ specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'
9
+
10
+ function zid(element) {
11
+ return element._zid || (element._zid = _zid++)
12
+ }
13
+ function findHandlers(element, event, fn, selector) {
14
+ event = parse(event)
15
+ if (event.ns) var matcher = matcherFor(event.ns)
16
+ return (handlers[zid(element)] || []).filter(function(handler) {
17
+ return handler
18
+ && (!event.e || handler.e == event.e)
19
+ && (!event.ns || matcher.test(handler.ns))
20
+ && (!fn || zid(handler.fn) === zid(fn))
21
+ && (!selector || handler.sel == selector)
22
+ })
23
+ }
24
+ function parse(event) {
25
+ var parts = ('' + event).split('.')
26
+ return {e: parts[0], ns: parts.slice(1).sort().join(' ')}
27
+ }
28
+ function matcherFor(ns) {
29
+ return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)')
30
+ }
31
+
32
+ function eachEvent(events, fn, iterator){
33
+ if ($.isObject(events)) $.each(events, iterator)
34
+ else events.split(/\s/).forEach(function(type){ iterator(type, fn) })
35
+ }
36
+
37
+ function add(element, events, fn, selector, getDelegate, capture){
38
+ capture = !!capture
39
+ var id = zid(element), set = (handlers[id] || (handlers[id] = []))
40
+ eachEvent(events, fn, function(event, fn){
41
+ var delegate = getDelegate && getDelegate(fn, event),
42
+ callback = delegate || fn
43
+ var proxyfn = function (event) {
44
+ var result = callback.apply(element, [event].concat(event.data))
45
+ if (result === false) event.preventDefault()
46
+ return result
47
+ }
48
+ var handler = $.extend(parse(event), {fn: fn, proxy: proxyfn, sel: selector, del: delegate, i: set.length})
49
+ set.push(handler)
50
+ element.addEventListener(handler.e, proxyfn, capture)
51
+ })
52
+ }
53
+ function remove(element, events, fn, selector){
54
+ var id = zid(element)
55
+ eachEvent(events || '', fn, function(event, fn){
56
+ findHandlers(element, event, fn, selector).forEach(function(handler){
57
+ delete handlers[id][handler.i]
58
+ element.removeEventListener(handler.e, handler.proxy, false)
59
+ })
60
+ })
61
+ }
62
+
63
+ $.event = { add: add, remove: remove }
64
+
65
+ $.proxy = function(fn, context) {
66
+ if ($.isFunction(fn)) {
67
+ var proxyFn = function(){ return fn.apply(context, arguments) }
68
+ proxyFn._zid = zid(fn)
69
+ return proxyFn
70
+ } else if (typeof context == 'string') {
71
+ return $.proxy(fn[context], fn)
72
+ } else {
73
+ throw new TypeError("expected function")
74
+ }
75
+ }
76
+
77
+ $.fn.bind = function(event, callback){
78
+ return this.each(function(){
79
+ add(this, event, callback)
80
+ })
81
+ }
82
+ $.fn.unbind = function(event, callback){
83
+ return this.each(function(){
84
+ remove(this, event, callback)
85
+ })
86
+ }
87
+ $.fn.one = function(event, callback){
88
+ return this.each(function(i, element){
89
+ add(this, event, callback, null, function(fn, type){
90
+ return function(){
91
+ var result = fn.apply(element, arguments)
92
+ remove(element, type, fn)
93
+ return result
94
+ }
95
+ })
96
+ })
97
+ }
98
+
99
+ var returnTrue = function(){return true},
100
+ returnFalse = function(){return false},
101
+ eventMethods = {
102
+ preventDefault: 'isDefaultPrevented',
103
+ stopImmediatePropagation: 'isImmediatePropagationStopped',
104
+ stopPropagation: 'isPropagationStopped'
105
+ }
106
+ function createProxy(event) {
107
+ var proxy = $.extend({originalEvent: event}, event)
108
+ $.each(eventMethods, function(name, predicate) {
109
+ proxy[name] = function(){
110
+ this[predicate] = returnTrue
111
+ return event[name].apply(event, arguments)
112
+ }
113
+ proxy[predicate] = returnFalse
114
+ })
115
+ return proxy
116
+ }
117
+
118
+ // emulates the 'defaultPrevented' property for browsers that have none
119
+ function fix(event) {
120
+ if (!('defaultPrevented' in event)) {
121
+ event.defaultPrevented = false
122
+ var prevent = event.preventDefault
123
+ event.preventDefault = function() {
124
+ this.defaultPrevented = true
125
+ prevent.call(this)
126
+ }
127
+ }
128
+ }
129
+
130
+ $.fn.delegate = function(selector, event, callback){
131
+ var capture = false
132
+ if(event == 'blur' || event == 'focus'){
133
+ if($.iswebkit)
134
+ event = event == 'blur' ? 'focusout' : event == 'focus' ? 'focusin' : event
135
+ else
136
+ capture = true
137
+ }
138
+
139
+ return this.each(function(i, element){
140
+ add(element, event, callback, selector, function(fn){
141
+ return function(e){
142
+ var evt, match = $(e.target).closest(selector, element).get(0)
143
+ if (match) {
144
+ evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
145
+ return fn.apply(match, [evt].concat([].slice.call(arguments, 1)))
146
+ }
147
+ }
148
+ }, capture)
149
+ })
150
+ }
151
+ $.fn.undelegate = function(selector, event, callback){
152
+ return this.each(function(){
153
+ remove(this, event, callback, selector)
154
+ })
155
+ }
156
+
157
+ $.fn.live = function(event, callback){
158
+ $(document.body).delegate(this.selector, event, callback)
159
+ return this
160
+ }
161
+ $.fn.die = function(event, callback){
162
+ $(document.body).undelegate(this.selector, event, callback)
163
+ return this
164
+ }
165
+
166
+ $.fn.on = function(event, selector, callback){
167
+ return selector == undefined || $.isFunction(selector) ?
168
+ this.bind(event, selector) : this.delegate(selector, event, callback)
169
+ }
170
+ $.fn.off = function(event, selector, callback){
171
+ return selector == undefined || $.isFunction(selector) ?
172
+ this.unbind(event, selector) : this.undelegate(selector, event, callback)
173
+ }
174
+
175
+ $.fn.trigger = function(event, data){
176
+ if (typeof event == 'string') event = $.Event(event)
177
+ fix(event)
178
+ event.data = data
179
+ return this.each(function(){
180
+ // items in the collection might not be DOM elements
181
+ // (todo: possibly support events on plain old objects)
182
+ if('dispatchEvent' in this) this.dispatchEvent(event)
183
+ })
184
+ }
185
+
186
+ // triggers event handlers on current element just as if an event occurred,
187
+ // doesn't trigger an actual event, doesn't bubble
188
+ $.fn.triggerHandler = function(event, data){
189
+ var e, result
190
+ this.each(function(i, element){
191
+ e = createProxy(typeof event == 'string' ? $.Event(event) : event)
192
+ e.data = data
193
+ e.target = element
194
+ $.each(findHandlers(element, event.type || event), function(i, handler){
195
+ result = handler.proxy(e)
196
+ if (e.isImmediatePropagationStopped()) return false
197
+ })
198
+ })
199
+ return result
200
+ }
201
+
202
+ // shortcut methods for `.bind(event, fn)` for each event type
203
+ ;('focusin focusout load resize scroll unload click dblclick '+
204
+ 'mousedown mouseup mousemove mouseover mouseout '+
205
+ 'change select keydown keypress keyup error').split(' ').forEach(function(event) {
206
+ $.fn[event] = function(callback){ return this.bind(event, callback) }
207
+ })
208
+
209
+ ;['focus', 'blur'].forEach(function(name) {
210
+ $.fn[name] = function(callback) {
211
+ if (callback) this.bind(name, callback)
212
+ else if (this.length) try { this.get(0)[name]() } catch(e){}
213
+ return this
214
+ }
215
+ })
216
+
217
+ $.Event = function(type, props) {
218
+ var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true
219
+ if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])
220
+ event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null)
221
+ return event
222
+ }
223
+
224
+ })(Zepto)
@@ -0,0 +1,40 @@
1
+ // Zepto.js
2
+ // (c) 2010-2012 Thomas Fuchs
3
+ // Zepto.js may be freely distributed under the MIT license.
4
+
5
+ ;(function ($) {
6
+ $.fn.serializeArray = function () {
7
+ var result = [], el
8
+ $( Array.prototype.slice.call(this.get(0).elements) ).each(function () {
9
+ el = $(this)
10
+ var type = el.attr('type')
11
+ if (this.nodeName.toLowerCase() != 'fieldset' &&
12
+ !this.disabled && type != 'submit' && type != 'reset' && type != 'button' &&
13
+ ((type != 'radio' && type != 'checkbox') || this.checked))
14
+ result.push({
15
+ name: el.attr('name'),
16
+ value: el.val()
17
+ })
18
+ })
19
+ return result
20
+ }
21
+
22
+ $.fn.serialize = function () {
23
+ var result = []
24
+ this.serializeArray().forEach(function (elm) {
25
+ result.push( encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value) )
26
+ })
27
+ return result.join('&')
28
+ }
29
+
30
+ $.fn.submit = function (callback) {
31
+ if (callback) this.bind('submit', callback)
32
+ else if (this.length) {
33
+ var event = $.Event('submit')
34
+ this.eq(0).trigger(event)
35
+ if (!event.defaultPrevented) this.get(0).submit()
36
+ }
37
+ return this
38
+ }
39
+
40
+ })(Zepto)
@@ -0,0 +1,91 @@
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
+ var prefix = '', eventPrefix, endEventName, endAnimationName,
7
+ vendors = { Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' },
8
+ document = window.document, testEl = document.createElement('div'),
9
+ supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,
10
+ clearProperties = {}
11
+
12
+ function downcase(str) { return str.toLowerCase() }
13
+ function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }
14
+
15
+ $.each(vendors, function(vendor, event){
16
+ if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
17
+ prefix = '-' + downcase(vendor) + '-'
18
+ eventPrefix = event
19
+ return false
20
+ }
21
+ })
22
+
23
+ clearProperties[prefix + 'transition-property'] =
24
+ clearProperties[prefix + 'transition-duration'] =
25
+ clearProperties[prefix + 'transition-timing-function'] =
26
+ clearProperties[prefix + 'animation-name'] =
27
+ clearProperties[prefix + 'animation-duration'] = ''
28
+
29
+ $.fx = {
30
+ off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
31
+ cssPrefix: prefix,
32
+ transitionEnd: normalizeEvent('TransitionEnd'),
33
+ animationEnd: normalizeEvent('AnimationEnd')
34
+ }
35
+
36
+ $.fn.animate = function(properties, duration, ease, callback){
37
+ if ($.isObject(duration))
38
+ ease = duration.easing, callback = duration.complete, duration = duration.duration
39
+ if (duration) duration = duration / 1000
40
+ return this.anim(properties, duration, ease, callback)
41
+ }
42
+
43
+ $.fn.anim = function(properties, duration, ease, callback){
44
+ var transforms, cssProperties = {}, key, that = this, wrappedCallback, endEvent = $.fx.transitionEnd
45
+ if (duration === undefined) duration = 0.4
46
+ if ($.fx.off) duration = 0
47
+
48
+ if (typeof properties == 'string') {
49
+ // keyframe animation
50
+ cssProperties[prefix + 'animation-name'] = properties
51
+ cssProperties[prefix + 'animation-duration'] = duration + 's'
52
+ endEvent = $.fx.animationEnd
53
+ } else {
54
+ // CSS transitions
55
+ for (key in properties)
56
+ if (supportedTransforms.test(key)) {
57
+ transforms || (transforms = [])
58
+ transforms.push(key + '(' + properties[key] + ')')
59
+ }
60
+ else cssProperties[key] = properties[key]
61
+
62
+ if (transforms) cssProperties[prefix + 'transform'] = transforms.join(' ')
63
+ if (!$.fx.off && typeof properties === 'object') {
64
+ cssProperties[prefix + 'transition-property'] = Object.keys(properties).join(', ')
65
+ cssProperties[prefix + 'transition-duration'] = duration + 's'
66
+ cssProperties[prefix + 'transition-timing-function'] = (ease || 'linear')
67
+ }
68
+ }
69
+
70
+ wrappedCallback = function(event){
71
+ if (typeof event !== 'undefined') {
72
+ if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
73
+ $(event.target).unbind(endEvent, arguments.callee)
74
+ }
75
+ $(this).css(clearProperties)
76
+ callback && callback.call(this)
77
+ }
78
+ if (duration > 0) this.bind(endEvent, wrappedCallback)
79
+
80
+ setTimeout(function() {
81
+ that.css(cssProperties)
82
+ if (duration <= 0) setTimeout(function() {
83
+ that.each(function(){ wrappedCallback.call(this) })
84
+ }, 0)
85
+ }, 0)
86
+
87
+ return this
88
+ }
89
+
90
+ testEl = null
91
+ })(Zepto)
@@ -0,0 +1,72 @@
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
+ var document = window.document, docElem = document.documentElement,
7
+ origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle,
8
+ speeds = { _default: 400, fast: 200, slow: 600 }
9
+
10
+ function translateSpeed(speed) {
11
+ return typeof speed == 'number' ? speed : (speeds[speed] || speeds._default)
12
+ }
13
+
14
+ function anim(el, speed, opacity, scale, callback) {
15
+ if (typeof speed == 'function' && !callback) callback = speed, speed = undefined
16
+ var props = { opacity: opacity }
17
+ if (scale) {
18
+ props.scale = scale
19
+ el.css($.fx.cssPrefix + 'transform-origin', '0 0')
20
+ }
21
+ return el.anim(props, translateSpeed(speed) / 1000, null, callback)
22
+ }
23
+
24
+ function hide(el, speed, scale, callback) {
25
+ return anim(el, speed, 0, scale, function(){
26
+ origHide.call($(this))
27
+ callback && callback.call(this)
28
+ })
29
+ }
30
+
31
+ $.fn.show = function(speed, callback) {
32
+ origShow.call(this)
33
+ if (speed === undefined) speed = 0
34
+ else this.css('opacity', 0)
35
+ return anim(this, speed, 1, '1,1', callback)
36
+ }
37
+
38
+ $.fn.hide = function(speed, callback) {
39
+ if (speed === undefined) return origHide.call(this)
40
+ else return hide(this, speed, '0,0', callback)
41
+ }
42
+
43
+ $.fn.toggle = function(speed, callback) {
44
+ if (speed === undefined || typeof speed == 'boolean') return origToggle.call(this, speed)
45
+ else return this[this.css('display') == 'none' ? 'show' : 'hide'](speed, callback)
46
+ }
47
+
48
+ $.fn.fadeTo = function(speed, opacity, callback) {
49
+ return anim(this, speed, opacity, null, callback)
50
+ }
51
+
52
+ $.fn.fadeIn = function(speed, callback) {
53
+ var target = this.css('opacity')
54
+ if (target > 0) this.css('opacity', 0)
55
+ else target = 1
56
+ return origShow.call(this).fadeTo(speed, target, callback)
57
+ }
58
+
59
+ $.fn.fadeOut = function(speed, callback) {
60
+ return hide(this, speed, null, callback)
61
+ }
62
+
63
+ $.fn.fadeToggle = function(speed, callback) {
64
+ var hidden = this.css('opacity') == 0 || this.css('display') == 'none'
65
+ return this[hidden ? 'fadeIn' : 'fadeOut'](speed, callback)
66
+ }
67
+
68
+ $.extend($.fx, {
69
+ speeds: speeds
70
+ })
71
+
72
+ })(Zepto)
@@ -0,0 +1,35 @@
1
+ // Zepto.js
2
+ // (c) 2010-2012 Thomas Fuchs
3
+ // Zepto.js may be freely distributed under the MIT license.
4
+
5
+ ;(function($){
6
+ if ($.os.ios) {
7
+ var gesture = {}, gestureTimeout
8
+
9
+ function parentIfText(node){
10
+ return 'tagName' in node ? node : node.parentNode
11
+ }
12
+
13
+ $(document).bind('gesturestart', function(e){
14
+ var now = Date.now(), delta = now - (gesture.last || now)
15
+ gesture.target = parentIfText(e.target)
16
+ gestureTimeout && clearTimeout(gestureTimeout)
17
+ gesture.e1 = e.scale
18
+ gesture.last = now
19
+ }).bind('gesturechange', function(e){
20
+ gesture.e2 = e.scale
21
+ }).bind('gestureend', function(e){
22
+ if (gesture.e2 > 0) {
23
+ Math.abs(gesture.e1 - gesture.e2) != 0 && $(gesture.target).trigger('pinch') &&
24
+ $(gesture.target).trigger('pinch' + (gesture.e1 - gesture.e2 > 0 ? 'In' : 'Out'))
25
+ gesture.e1 = gesture.e2 = gesture.last = 0
26
+ } else if ('last' in gesture) {
27
+ gesture = {}
28
+ }
29
+ })
30
+
31
+ ;['pinch', 'pinchIn', 'pinchOut'].forEach(function(m){
32
+ $.fn[m] = function(callback){ return this.bind(m, callback) }
33
+ })
34
+ }
35
+ })(Zepto)
@@ -0,0 +1,36 @@
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
+ })()
@@ -0,0 +1,70 @@
1
+ ;(function($){
2
+ var zepto = $.zepto, oldQsa = zepto.qsa, oldMatches = zepto.matches
3
+
4
+ function visible(elem){
5
+ elem = $(elem)
6
+ return !!(elem.width() || elem.height()) && elem.css("display") !== "none"
7
+ }
8
+
9
+ // Implements a subset from:
10
+ // http://api.jquery.com/category/selectors/jquery-selector-extensions/
11
+ //
12
+ // Each filter function receives the current index, all nodes in the
13
+ // considered set, and a value if there were parentheses. The value
14
+ // of `this` is the node currently being considered. The function returns the
15
+ // resulting node(s), null, or undefined.
16
+ //
17
+ // Complex selectors are not supported:
18
+ // li:has(label:contains("foo")) + li:has(label:contains("bar"))
19
+ // "> h2"
20
+ // ul.inner:first > li
21
+ var filters = zepto.cssFilters = {
22
+ visible: function(){ if (visible(this)) return this },
23
+ hidden: function(){ if (!visible(this)) return this },
24
+ selected: function(){ if (this.selected) return this },
25
+ checked: function(){ if (this.checked) return this },
26
+ parent: function(){ return this.parentNode },
27
+ first: function(idx){ if (idx === 0) return this },
28
+ last: function(idx, nodes){ if (idx === nodes.length - 1) return this },
29
+ eq: function(idx, _, value){ if (idx === value) return this },
30
+ contains: function(idx, _, text){ if ($(this).text().indexOf(text) > -1) return this },
31
+ has: function(idx, _, sel){ if (zepto.qsa(this, sel).length) return this }
32
+ }
33
+
34
+ var re = new RegExp('(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*')
35
+
36
+ function process(sel, fn) {
37
+ var filter, arg, match = sel.match(re)
38
+ if (match && match[2] in filters) {
39
+ var filter = filters[match[2]], arg = match[3]
40
+ sel = match[1]
41
+ if (arg) {
42
+ var num = Number(arg)
43
+ if (isNaN(num)) arg = arg.replace(/^["']|["']$/g, '')
44
+ else arg = num
45
+ }
46
+ }
47
+ return fn(sel, filter, arg)
48
+ }
49
+
50
+ zepto.qsa = function(node, selector) {
51
+ return process(selector, function(sel, filter, arg){
52
+ try {
53
+ if (!sel && filter) sel = '*'
54
+ var nodes = oldQsa(node, sel)
55
+ } catch(e) {
56
+ console.error('error performing selector: %o', selector)
57
+ throw e
58
+ }
59
+ return !filter ? nodes :
60
+ zepto.uniq($.map(nodes, function(n, i){ return filter.call(n, i, nodes, arg) }))
61
+ })
62
+ }
63
+
64
+ zepto.matches = function(node, selector){
65
+ return process(selector, function(sel, filter, arg){
66
+ return (!sel || oldMatches(node, sel)) &&
67
+ (!filter || filter.call(node, null, arg) === node)
68
+ })
69
+ }
70
+ })(Zepto)
@@ -0,0 +1,22 @@
1
+ // Zepto.js
2
+ // (c) 2010-2012 Thomas Fuchs
3
+ // Zepto.js may be freely distributed under the MIT license.
4
+
5
+ ;(function($){
6
+ $.fn.end = function(){
7
+ return this.prevObject || $()
8
+ }
9
+
10
+ $.fn.andSelf = function(){
11
+ return this.add(this.prevObject || $())
12
+ }
13
+
14
+ 'filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings'.split(',').forEach(function(property){
15
+ var fn = $.fn[property]
16
+ $.fn[property] = function(){
17
+ var ret = fn.apply(this, arguments)
18
+ ret.prevObject = this
19
+ return ret
20
+ }
21
+ })
22
+ })(Zepto)
@@ -0,0 +1,85 @@
1
+ // Zepto.js
2
+ // (c) 2010-2012 Thomas Fuchs
3
+ // Zepto.js may be freely distributed under the MIT license.
4
+
5
+ ;(function($){
6
+ var touch = {}, touchTimeout
7
+
8
+ function parentIfText(node){
9
+ return 'tagName' in node ? node : node.parentNode
10
+ }
11
+
12
+ function swipeDirection(x1, x2, y1, y2){
13
+ var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)
14
+ return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
15
+ }
16
+
17
+ var longTapDelay = 750, longTapTimeout
18
+
19
+ function longTap(){
20
+ longTapTimeout = null
21
+ if (touch.last) {
22
+ touch.el.trigger('longTap')
23
+ touch = {}
24
+ }
25
+ }
26
+
27
+ function cancelLongTap(){
28
+ if (longTapTimeout) clearTimeout(longTapTimeout)
29
+ longTapTimeout = null
30
+ }
31
+
32
+ $(document).ready(function(){
33
+ var now, delta
34
+
35
+ $(document.body).bind('touchstart', function(e){
36
+ now = Date.now()
37
+ delta = now - (touch.last || now)
38
+ touch.el = $(parentIfText(e.touches[0].target))
39
+ touchTimeout && clearTimeout(touchTimeout)
40
+ touch.x1 = e.touches[0].pageX
41
+ touch.y1 = e.touches[0].pageY
42
+ if (delta > 0 && delta <= 250) touch.isDoubleTap = true
43
+ touch.last = now
44
+ longTapTimeout = setTimeout(longTap, longTapDelay)
45
+ }).bind('touchmove', function(e){
46
+ cancelLongTap()
47
+ touch.x2 = e.touches[0].pageX
48
+ touch.y2 = e.touches[0].pageY
49
+ }).bind('touchend', function(e){
50
+ cancelLongTap()
51
+
52
+ // double tap (tapped twice within 250ms)
53
+ if (touch.isDoubleTap) {
54
+ touch.el.trigger('doubleTap')
55
+ touch = {}
56
+
57
+ // swipe
58
+ } else if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
59
+ (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)) {
60
+ touch.el.trigger('swipe') &&
61
+ touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
62
+ touch = {}
63
+
64
+ // normal tap
65
+ } else if ('last' in touch) {
66
+ touch.el.trigger('tap')
67
+
68
+ touchTimeout = setTimeout(function(){
69
+ touchTimeout = null
70
+ touch.el.trigger('singleTap')
71
+ touch = {}
72
+ }, 250)
73
+ }
74
+ }).bind('touchcancel', function(){
75
+ if (touchTimeout) clearTimeout(touchTimeout)
76
+ if (longTapTimeout) clearTimeout(longTapTimeout)
77
+ longTapTimeout = touchTimeout = null
78
+ touch = {}
79
+ })
80
+ })
81
+
82
+ ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){
83
+ $.fn[m] = function(callback){ return this.bind(m, callback) }
84
+ })
85
+ })(Zepto)