sprockets_zeptojs 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sprockets_zeptojs/version.rb +1 -1
- data/vendor/assets/javascripts/zepto/ajax.js +314 -0
- data/vendor/assets/javascripts/zepto/assets.js +21 -0
- data/vendor/assets/javascripts/zepto/data.js +67 -0
- data/vendor/assets/javascripts/zepto/detect.js +55 -0
- data/vendor/assets/javascripts/zepto/event.js +248 -0
- data/vendor/assets/javascripts/zepto/form.js +40 -0
- data/vendor/assets/javascripts/zepto/fx.js +102 -0
- data/vendor/assets/javascripts/zepto/fx_methods.js +71 -0
- data/vendor/assets/javascripts/zepto/gesture.js +35 -0
- data/vendor/assets/javascripts/zepto/index.js +6 -0
- data/vendor/assets/javascripts/zepto/polyfill.js +36 -0
- data/vendor/assets/javascripts/zepto/selector.js +81 -0
- data/vendor/assets/javascripts/zepto/stack.js +22 -0
- data/vendor/assets/javascripts/zepto/touch.js +115 -0
- data/vendor/assets/javascripts/zepto/zepto.js +790 -0
- metadata +16 -1
@@ -0,0 +1,248 @@
|
|
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
|
+
hover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }
|
8
|
+
|
9
|
+
specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'
|
10
|
+
|
11
|
+
function zid(element) {
|
12
|
+
return element._zid || (element._zid = _zid++)
|
13
|
+
}
|
14
|
+
function findHandlers(element, event, fn, selector) {
|
15
|
+
event = parse(event)
|
16
|
+
if (event.ns) var matcher = matcherFor(event.ns)
|
17
|
+
return (handlers[zid(element)] || []).filter(function(handler) {
|
18
|
+
return handler
|
19
|
+
&& (!event.e || handler.e == event.e)
|
20
|
+
&& (!event.ns || matcher.test(handler.ns))
|
21
|
+
&& (!fn || zid(handler.fn) === zid(fn))
|
22
|
+
&& (!selector || handler.sel == selector)
|
23
|
+
})
|
24
|
+
}
|
25
|
+
function parse(event) {
|
26
|
+
var parts = ('' + event).split('.')
|
27
|
+
return {e: parts[0], ns: parts.slice(1).sort().join(' ')}
|
28
|
+
}
|
29
|
+
function matcherFor(ns) {
|
30
|
+
return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)')
|
31
|
+
}
|
32
|
+
|
33
|
+
function eachEvent(events, fn, iterator){
|
34
|
+
if ($.type(events) != "string") $.each(events, iterator)
|
35
|
+
else events.split(/\s/).forEach(function(type){ iterator(type, fn) })
|
36
|
+
}
|
37
|
+
|
38
|
+
function eventCapture(handler, captureSetting) {
|
39
|
+
return handler.del &&
|
40
|
+
(handler.e == 'focus' || handler.e == 'blur') ||
|
41
|
+
!!captureSetting
|
42
|
+
}
|
43
|
+
|
44
|
+
function realEvent(type) {
|
45
|
+
return hover[type] || type
|
46
|
+
}
|
47
|
+
|
48
|
+
function add(element, events, fn, selector, getDelegate, capture){
|
49
|
+
var id = zid(element), set = (handlers[id] || (handlers[id] = []))
|
50
|
+
eachEvent(events, fn, function(event, fn){
|
51
|
+
var handler = parse(event)
|
52
|
+
handler.fn = fn
|
53
|
+
handler.sel = selector
|
54
|
+
// emulate mouseenter, mouseleave
|
55
|
+
if (handler.e in hover) fn = function(e){
|
56
|
+
var related = e.relatedTarget
|
57
|
+
if (!related || (related !== this && !$.contains(this, related)))
|
58
|
+
return handler.fn.apply(this, arguments)
|
59
|
+
}
|
60
|
+
handler.del = getDelegate && getDelegate(fn, event)
|
61
|
+
var callback = handler.del || fn
|
62
|
+
handler.proxy = function (e) {
|
63
|
+
var result = callback.apply(element, [e].concat(e.data))
|
64
|
+
if (result === false) e.preventDefault(), e.stopPropagation()
|
65
|
+
return result
|
66
|
+
}
|
67
|
+
handler.i = set.length
|
68
|
+
set.push(handler)
|
69
|
+
element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
|
70
|
+
})
|
71
|
+
}
|
72
|
+
function remove(element, events, fn, selector, capture){
|
73
|
+
var id = zid(element)
|
74
|
+
eachEvent(events || '', fn, function(event, fn){
|
75
|
+
findHandlers(element, event, fn, selector).forEach(function(handler){
|
76
|
+
delete handlers[id][handler.i]
|
77
|
+
element.removeEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
|
78
|
+
})
|
79
|
+
})
|
80
|
+
}
|
81
|
+
|
82
|
+
$.event = { add: add, remove: remove }
|
83
|
+
|
84
|
+
$.proxy = function(fn, context) {
|
85
|
+
if ($.isFunction(fn)) {
|
86
|
+
var proxyFn = function(){ return fn.apply(context, arguments) }
|
87
|
+
proxyFn._zid = zid(fn)
|
88
|
+
return proxyFn
|
89
|
+
} else if (typeof context == 'string') {
|
90
|
+
return $.proxy(fn[context], fn)
|
91
|
+
} else {
|
92
|
+
throw new TypeError("expected function")
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
$.fn.bind = function(event, callback){
|
97
|
+
return this.each(function(){
|
98
|
+
add(this, event, callback)
|
99
|
+
})
|
100
|
+
}
|
101
|
+
$.fn.unbind = function(event, callback){
|
102
|
+
return this.each(function(){
|
103
|
+
remove(this, event, callback)
|
104
|
+
})
|
105
|
+
}
|
106
|
+
$.fn.one = function(event, callback){
|
107
|
+
return this.each(function(i, element){
|
108
|
+
add(this, event, callback, null, function(fn, type){
|
109
|
+
return function(){
|
110
|
+
var result = fn.apply(element, arguments)
|
111
|
+
remove(element, type, fn)
|
112
|
+
return result
|
113
|
+
}
|
114
|
+
})
|
115
|
+
})
|
116
|
+
}
|
117
|
+
|
118
|
+
var returnTrue = function(){return true},
|
119
|
+
returnFalse = function(){return false},
|
120
|
+
ignoreProperties = /^([A-Z]|layer[XY]$)/,
|
121
|
+
eventMethods = {
|
122
|
+
preventDefault: 'isDefaultPrevented',
|
123
|
+
stopImmediatePropagation: 'isImmediatePropagationStopped',
|
124
|
+
stopPropagation: 'isPropagationStopped'
|
125
|
+
}
|
126
|
+
function createProxy(event) {
|
127
|
+
var key, proxy = { originalEvent: event }
|
128
|
+
for (key in event)
|
129
|
+
if (!ignoreProperties.test(key) && event[key] !== undefined) proxy[key] = event[key]
|
130
|
+
|
131
|
+
$.each(eventMethods, function(name, predicate) {
|
132
|
+
proxy[name] = function(){
|
133
|
+
this[predicate] = returnTrue
|
134
|
+
return event[name].apply(event, arguments)
|
135
|
+
}
|
136
|
+
proxy[predicate] = returnFalse
|
137
|
+
})
|
138
|
+
return proxy
|
139
|
+
}
|
140
|
+
|
141
|
+
// emulates the 'defaultPrevented' property for browsers that have none
|
142
|
+
function fix(event) {
|
143
|
+
if (!('defaultPrevented' in event)) {
|
144
|
+
event.defaultPrevented = false
|
145
|
+
var prevent = event.preventDefault
|
146
|
+
event.preventDefault = function() {
|
147
|
+
this.defaultPrevented = true
|
148
|
+
prevent.call(this)
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
$.fn.delegate = function(selector, event, callback){
|
154
|
+
return this.each(function(i, element){
|
155
|
+
add(element, event, callback, selector, function(fn){
|
156
|
+
return function(e){
|
157
|
+
var evt, match = $(e.target).closest(selector, element).get(0)
|
158
|
+
if (match) {
|
159
|
+
evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
|
160
|
+
return fn.apply(match, [evt].concat([].slice.call(arguments, 1)))
|
161
|
+
}
|
162
|
+
}
|
163
|
+
})
|
164
|
+
})
|
165
|
+
}
|
166
|
+
$.fn.undelegate = function(selector, event, callback){
|
167
|
+
return this.each(function(){
|
168
|
+
remove(this, event, callback, selector)
|
169
|
+
})
|
170
|
+
}
|
171
|
+
|
172
|
+
$.fn.live = function(event, callback){
|
173
|
+
$(document.body).delegate(this.selector, event, callback)
|
174
|
+
return this
|
175
|
+
}
|
176
|
+
$.fn.die = function(event, callback){
|
177
|
+
$(document.body).undelegate(this.selector, event, callback)
|
178
|
+
return this
|
179
|
+
}
|
180
|
+
|
181
|
+
$.fn.on = function(event, selector, callback){
|
182
|
+
return !selector || $.isFunction(selector) ?
|
183
|
+
this.bind(event, selector || callback) : this.delegate(selector, event, callback)
|
184
|
+
}
|
185
|
+
$.fn.off = function(event, selector, callback){
|
186
|
+
return !selector || $.isFunction(selector) ?
|
187
|
+
this.unbind(event, selector || callback) : this.undelegate(selector, event, callback)
|
188
|
+
}
|
189
|
+
|
190
|
+
$.fn.trigger = function(event, data){
|
191
|
+
if (typeof event == 'string' || $.isPlainObject(event)) event = $.Event(event)
|
192
|
+
fix(event)
|
193
|
+
event.data = data
|
194
|
+
return this.each(function(){
|
195
|
+
// items in the collection might not be DOM elements
|
196
|
+
// (todo: possibly support events on plain old objects)
|
197
|
+
if('dispatchEvent' in this) this.dispatchEvent(event)
|
198
|
+
})
|
199
|
+
}
|
200
|
+
|
201
|
+
// triggers event handlers on current element just as if an event occurred,
|
202
|
+
// doesn't trigger an actual event, doesn't bubble
|
203
|
+
$.fn.triggerHandler = function(event, data){
|
204
|
+
var e, result
|
205
|
+
this.each(function(i, element){
|
206
|
+
e = createProxy(typeof event == 'string' ? $.Event(event) : event)
|
207
|
+
e.data = data
|
208
|
+
e.target = element
|
209
|
+
$.each(findHandlers(element, event.type || event), function(i, handler){
|
210
|
+
result = handler.proxy(e)
|
211
|
+
if (e.isImmediatePropagationStopped()) return false
|
212
|
+
})
|
213
|
+
})
|
214
|
+
return result
|
215
|
+
}
|
216
|
+
|
217
|
+
// shortcut methods for `.bind(event, fn)` for each event type
|
218
|
+
;('focusin focusout load resize scroll unload click dblclick '+
|
219
|
+
'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave '+
|
220
|
+
'change select keydown keypress keyup error').split(' ').forEach(function(event) {
|
221
|
+
$.fn[event] = function(callback) {
|
222
|
+
return callback ?
|
223
|
+
this.bind(event, callback) :
|
224
|
+
this.trigger(event)
|
225
|
+
}
|
226
|
+
})
|
227
|
+
|
228
|
+
;['focus', 'blur'].forEach(function(name) {
|
229
|
+
$.fn[name] = function(callback) {
|
230
|
+
if (callback) this.bind(name, callback)
|
231
|
+
else this.each(function(){
|
232
|
+
try { this[name]() }
|
233
|
+
catch(e) {}
|
234
|
+
})
|
235
|
+
return this
|
236
|
+
}
|
237
|
+
})
|
238
|
+
|
239
|
+
$.Event = function(type, props) {
|
240
|
+
if (typeof type != 'string') props = type, type = props.type
|
241
|
+
var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true
|
242
|
+
if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])
|
243
|
+
event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null)
|
244
|
+
event.isDefaultPrevented = function(){ return this.defaultPrevented }
|
245
|
+
return event
|
246
|
+
}
|
247
|
+
|
248
|
+
})(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,102 @@
|
|
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
|
+
transform,
|
11
|
+
transitionProperty, transitionDuration, transitionTiming,
|
12
|
+
animationName, animationDuration, animationTiming,
|
13
|
+
cssReset = {}
|
14
|
+
|
15
|
+
function dasherize(str) { return downcase(str.replace(/([a-z])([A-Z])/, '$1-$2')) }
|
16
|
+
function downcase(str) { return str.toLowerCase() }
|
17
|
+
function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }
|
18
|
+
|
19
|
+
$.each(vendors, function(vendor, event){
|
20
|
+
if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
|
21
|
+
prefix = '-' + downcase(vendor) + '-'
|
22
|
+
eventPrefix = event
|
23
|
+
return false
|
24
|
+
}
|
25
|
+
})
|
26
|
+
|
27
|
+
transform = prefix + 'transform'
|
28
|
+
cssReset[transitionProperty = prefix + 'transition-property'] =
|
29
|
+
cssReset[transitionDuration = prefix + 'transition-duration'] =
|
30
|
+
cssReset[transitionTiming = prefix + 'transition-timing-function'] =
|
31
|
+
cssReset[animationName = prefix + 'animation-name'] =
|
32
|
+
cssReset[animationDuration = prefix + 'animation-duration'] =
|
33
|
+
cssReset[animationTiming = prefix + 'animation-timing-function'] = ''
|
34
|
+
|
35
|
+
$.fx = {
|
36
|
+
off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
|
37
|
+
speeds: { _default: 400, fast: 200, slow: 600 },
|
38
|
+
cssPrefix: prefix,
|
39
|
+
transitionEnd: normalizeEvent('TransitionEnd'),
|
40
|
+
animationEnd: normalizeEvent('AnimationEnd')
|
41
|
+
}
|
42
|
+
|
43
|
+
$.fn.animate = function(properties, duration, ease, callback){
|
44
|
+
if ($.isPlainObject(duration))
|
45
|
+
ease = duration.easing, callback = duration.complete, duration = duration.duration
|
46
|
+
if (duration) duration = (typeof duration == 'number' ? duration :
|
47
|
+
($.fx.speeds[duration] || $.fx.speeds._default)) / 1000
|
48
|
+
return this.anim(properties, duration, ease, callback)
|
49
|
+
}
|
50
|
+
|
51
|
+
$.fn.anim = function(properties, duration, ease, callback){
|
52
|
+
var key, cssValues = {}, cssProperties, transforms = '',
|
53
|
+
that = this, wrappedCallback, endEvent = $.fx.transitionEnd
|
54
|
+
|
55
|
+
if (duration === undefined) duration = 0.4
|
56
|
+
if ($.fx.off) duration = 0
|
57
|
+
|
58
|
+
if (typeof properties == 'string') {
|
59
|
+
// keyframe animation
|
60
|
+
cssValues[animationName] = properties
|
61
|
+
cssValues[animationDuration] = duration + 's'
|
62
|
+
cssValues[animationTiming] = (ease || 'linear')
|
63
|
+
endEvent = $.fx.animationEnd
|
64
|
+
} else {
|
65
|
+
cssProperties = []
|
66
|
+
// CSS transitions
|
67
|
+
for (key in properties)
|
68
|
+
if (supportedTransforms.test(key)) transforms += key + '(' + properties[key] + ') '
|
69
|
+
else cssValues[key] = properties[key], cssProperties.push(dasherize(key))
|
70
|
+
|
71
|
+
if (transforms) cssValues[transform] = transforms, cssProperties.push(transform)
|
72
|
+
if (duration > 0 && typeof properties === 'object') {
|
73
|
+
cssValues[transitionProperty] = cssProperties.join(', ')
|
74
|
+
cssValues[transitionDuration] = duration + 's'
|
75
|
+
cssValues[transitionTiming] = (ease || 'linear')
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
wrappedCallback = function(event){
|
80
|
+
if (typeof event !== 'undefined') {
|
81
|
+
if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
|
82
|
+
$(event.target).unbind(endEvent, wrappedCallback)
|
83
|
+
}
|
84
|
+
$(this).css(cssReset)
|
85
|
+
callback && callback.call(this)
|
86
|
+
}
|
87
|
+
if (duration > 0) this.bind(endEvent, wrappedCallback)
|
88
|
+
|
89
|
+
// trigger page reflow so new elements can animate
|
90
|
+
this.size() && this.get(0).clientLeft
|
91
|
+
|
92
|
+
this.css(cssValues)
|
93
|
+
|
94
|
+
if (duration <= 0) setTimeout(function() {
|
95
|
+
that.each(function(){ wrappedCallback.call(this) })
|
96
|
+
}, 0)
|
97
|
+
|
98
|
+
return this
|
99
|
+
}
|
100
|
+
|
101
|
+
testEl = null
|
102
|
+
})(Zepto)
|
@@ -0,0 +1,71 @@
|
|
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
|
+
|
9
|
+
function anim(el, speed, opacity, scale, callback) {
|
10
|
+
if (typeof speed == 'function' && !callback) callback = speed, speed = undefined
|
11
|
+
var props = { opacity: opacity }
|
12
|
+
if (scale) {
|
13
|
+
props.scale = scale
|
14
|
+
el.css($.fx.cssPrefix + 'transform-origin', '0 0')
|
15
|
+
}
|
16
|
+
return el.animate(props, speed, null, callback)
|
17
|
+
}
|
18
|
+
|
19
|
+
function hide(el, speed, scale, callback) {
|
20
|
+
return anim(el, speed, 0, scale, function(){
|
21
|
+
origHide.call($(this))
|
22
|
+
callback && callback.call(this)
|
23
|
+
})
|
24
|
+
}
|
25
|
+
|
26
|
+
$.fn.show = function(speed, callback) {
|
27
|
+
origShow.call(this)
|
28
|
+
if (speed === undefined) speed = 0
|
29
|
+
else this.css('opacity', 0)
|
30
|
+
return anim(this, speed, 1, '1,1', callback)
|
31
|
+
}
|
32
|
+
|
33
|
+
$.fn.hide = function(speed, callback) {
|
34
|
+
if (speed === undefined) return origHide.call(this)
|
35
|
+
else return hide(this, speed, '0,0', callback)
|
36
|
+
}
|
37
|
+
|
38
|
+
$.fn.toggle = function(speed, callback) {
|
39
|
+
if (speed === undefined || typeof speed == 'boolean')
|
40
|
+
return origToggle.call(this, speed)
|
41
|
+
else return this.each(function(){
|
42
|
+
var el = $(this)
|
43
|
+
el[el.css('display') == 'none' ? 'show' : 'hide'](speed, callback)
|
44
|
+
})
|
45
|
+
}
|
46
|
+
|
47
|
+
$.fn.fadeTo = function(speed, opacity, callback) {
|
48
|
+
return anim(this, speed, opacity, null, callback)
|
49
|
+
}
|
50
|
+
|
51
|
+
$.fn.fadeIn = function(speed, callback) {
|
52
|
+
var target = this.css('opacity')
|
53
|
+
if (target > 0) this.css('opacity', 0)
|
54
|
+
else target = 1
|
55
|
+
return origShow.call(this).fadeTo(speed, target, callback)
|
56
|
+
}
|
57
|
+
|
58
|
+
$.fn.fadeOut = function(speed, callback) {
|
59
|
+
return hide(this, speed, null, callback)
|
60
|
+
}
|
61
|
+
|
62
|
+
$.fn.fadeToggle = function(speed, callback) {
|
63
|
+
return this.each(function(){
|
64
|
+
var el = $(this)
|
65
|
+
el[
|
66
|
+
(el.css('opacity') == 0 || el.css('display') == 'none') ? 'fadeIn' : 'fadeOut'
|
67
|
+
](speed, callback)
|
68
|
+
})
|
69
|
+
}
|
70
|
+
|
71
|
+
})(Zepto)
|