summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Zepto
Unidiff
Diffstat (limited to 'frontend/gamma/js/Zepto') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Zepto/ajax.js285
-rw-r--r--frontend/gamma/js/Zepto/assets.js21
-rw-r--r--frontend/gamma/js/Zepto/data.js67
-rw-r--r--frontend/gamma/js/Zepto/detect.js42
-rw-r--r--frontend/gamma/js/Zepto/event.js248
-rw-r--r--frontend/gamma/js/Zepto/form.js40
-rw-r--r--frontend/gamma/js/Zepto/fx.js102
-rw-r--r--frontend/gamma/js/Zepto/fx_methods.js71
-rw-r--r--frontend/gamma/js/Zepto/gesture.js35
-rw-r--r--frontend/gamma/js/Zepto/polyfill.js36
-rw-r--r--frontend/gamma/js/Zepto/selector.js81
-rw-r--r--frontend/gamma/js/Zepto/stack.js22
-rw-r--r--frontend/gamma/js/Zepto/touch.js113
-rw-r--r--frontend/gamma/js/Zepto/zepto.js751
14 files changed, 0 insertions, 1914 deletions
diff --git a/frontend/gamma/js/Zepto/ajax.js b/frontend/gamma/js/Zepto/ajax.js
deleted file mode 100644
index f4da150..0000000
--- a/frontend/gamma/js/Zepto/ajax.js
+++ b/dev/null
@@ -1,285 +0,0 @@
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 jsonpID = 0,
7 isObject = $.isObject,
8 document = window.document,
9 key,
10 name,
11 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
12 scriptTypeRE = /^(?:text|application)\/javascript/i,
13 xmlTypeRE = /^(?:text|application)\/xml/i,
14 jsonType = 'application/json',
15 htmlType = 'text/html',
16 blankRE = /^\s*$/
17
18 // trigger a custom event and return false if it was cancelled
19 function triggerAndReturn(context, eventName, data) {
20 var event = $.Event(eventName)
21 $(context).trigger(event, data)
22 return !event.defaultPrevented
23 }
24
25 // trigger an Ajax "global" event
26 function triggerGlobal(settings, context, eventName, data) {
27 if (settings.global) return triggerAndReturn(context || document, eventName, data)
28 }
29
30 // Number of active Ajax requests
31 $.active = 0
32
33 function ajaxStart(settings) {
34 if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart')
35 }
36 function ajaxStop(settings) {
37 if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop')
38 }
39
40 // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable
41 function ajaxBeforeSend(xhr, settings) {
42 var context = settings.context
43 if (settings.beforeSend.call(context, xhr, settings) === false ||
44 triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false)
45 return false
46
47 triggerGlobal(settings, context, 'ajaxSend', [xhr, settings])
48 }
49 function ajaxSuccess(data, xhr, settings) {
50 var context = settings.context, status = 'success'
51 settings.success.call(context, data, status, xhr)
52 triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])
53 ajaxComplete(status, xhr, settings)
54 }
55 // type: "timeout", "error", "abort", "parsererror"
56 function ajaxError(error, type, xhr, settings) {
57 var context = settings.context
58 settings.error.call(context, xhr, type, error)
59 triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error])
60 ajaxComplete(type, xhr, settings)
61 }
62 // status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
63 function ajaxComplete(status, xhr, settings) {
64 var context = settings.context
65 settings.complete.call(context, xhr, status)
66 triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings])
67 ajaxStop(settings)
68 }
69
70 // Empty function, used as default callback
71 function empty() {}
72
73 $.ajaxJSONP = function(options){
74 if (!('type' in options)) return $.ajax(options)
75
76 var callbackName = 'jsonp' + (++jsonpID),
77 script = document.createElement('script'),
78 abort = function(){
79 $(script).remove()
80 if (callbackName in window) window[callbackName] = empty
81 ajaxComplete('abort', xhr, options)
82 },
83 xhr = { abort: abort }, abortTimeout
84
85 if (options.error) script.onerror = function() {
86 xhr.abort()
87 options.error()
88 }
89
90 window[callbackName] = function(data){
91 clearTimeout(abortTimeout)
92 $(script).remove()
93 delete window[callbackName]
94 ajaxSuccess(data, xhr, options)
95 }
96
97 serializeData(options)
98 script.src = options.url.replace(/=\?/, '=' + callbackName)
99 $('head').append(script)
100
101 if (options.timeout > 0) abortTimeout = setTimeout(function(){
102 xhr.abort()
103 ajaxComplete('timeout', xhr, options)
104 }, options.timeout)
105
106 return xhr
107 }
108
109 $.ajaxSettings = {
110 // Default type of request
111 type: 'GET',
112 // Callback that is executed before request
113 beforeSend: empty,
114 // Callback that is executed if the request succeeds
115 success: empty,
116 // Callback that is executed the the server drops error
117 error: empty,
118 // Callback that is executed on request complete (both: error and success)
119 complete: empty,
120 // The context for the callbacks
121 context: null,
122 // Whether to trigger "global" Ajax events
123 global: true,
124 // Transport
125 xhr: function () {
126 return new window.XMLHttpRequest()
127 },
128 // MIME types mapping
129 accepts: {
130 script: 'text/javascript, application/javascript',
131 json: jsonType,
132 xml: 'application/xml, text/xml',
133 html: htmlType,
134 text: 'text/plain'
135 },
136 // Whether the request is to another domain
137 crossDomain: false,
138 // Default timeout
139 timeout: 0,
140 // Whether data should be serialized to string
141 processData: true
142 }
143
144 function mimeToDataType(mime) {
145 return mime && ( mime == htmlType ? 'html' :
146 mime == jsonType ? 'json' :
147 scriptTypeRE.test(mime) ? 'script' :
148 xmlTypeRE.test(mime) && 'xml' ) || 'text'
149 }
150
151 function appendQuery(url, query) {
152 return (url + '&' + query).replace(/[&?]{1,2}/, '?')
153 }
154
155 // serialize payload and append it to the URL for GET requests
156 function serializeData(options) {
157 if (options.processData && isObject(options.data))
158 options.data = $.param(options.data, options.traditional)
159 if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
160 options.url = appendQuery(options.url, options.data)
161 }
162
163 $.ajax = function(options){
164 var settings = $.extend({}, options || {})
165 for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]
166
167 ajaxStart(settings)
168
169 if (!settings.crossDomain) settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) &&
170 RegExp.$2 != window.location.host
171
172 var dataType = settings.dataType, hasPlaceholder = /=\?/.test(settings.url)
173 if (dataType == 'jsonp' || hasPlaceholder) {
174 if (!hasPlaceholder) settings.url = appendQuery(settings.url, 'callback=?')
175 return $.ajaxJSONP(settings)
176 }
177
178 if (!settings.url) settings.url = window.location.toString()
179 serializeData(settings)
180
181 var mime = settings.accepts[dataType],
182 baseHeaders = { },
183 protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
184 xhr = $.ajaxSettings.xhr(), abortTimeout
185
186 if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest'
187 if (mime) {
188 baseHeaders['Accept'] = mime
189 if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0]
190 xhr.overrideMimeType && xhr.overrideMimeType(mime)
191 }
192 if (settings.contentType || (settings.contentType !== false && settings.data && settings.type.toUpperCase() != 'GET'))
193 baseHeaders['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded')
194 settings.headers = $.extend(baseHeaders, settings.headers || {})
195
196 xhr.onreadystatechange = function(){
197 if (xhr.readyState == 4) {
198 xhr.onreadystatechange = empty;
199 clearTimeout(abortTimeout)
200 var result, error = false
201 if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
202 dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
203 result = xhr.responseText
204
205 try {
206 if (dataType == 'script') (1,eval)(result)
207 else if (dataType == 'xml') result = xhr.responseXML
208 else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
209 } catch (e) { error = e }
210
211 if (error) ajaxError(error, 'parsererror', xhr, settings)
212 else ajaxSuccess(result, xhr, settings)
213 } else {
214 ajaxError(null, xhr.status ? 'error' : 'abort', xhr, settings)
215 }
216 }
217 }
218
219 var async = 'async' in settings ? settings.async : true
220 xhr.open(settings.type, settings.url, async)
221
222 for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name])
223
224 if (ajaxBeforeSend(xhr, settings) === false) {
225 xhr.abort()
226 return false
227 }
228
229 if (settings.timeout > 0) abortTimeout = setTimeout(function(){
230 xhr.onreadystatechange = empty
231 xhr.abort()
232 ajaxError(null, 'timeout', xhr, settings)
233 }, settings.timeout)
234
235 // avoid sending empty string (#319)
236 xhr.send(settings.data ? settings.data : null)
237 return xhr
238 }
239
240 $.get = function(url, success){ return $.ajax({ url: url, success: success }) }
241
242 $.post = function(url, data, success, dataType){
243 if ($.isFunction(data)) dataType = dataType || success, success = data, data = null
244 return $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType })
245 }
246
247 $.getJSON = function(url, success){
248 return $.ajax({ url: url, success: success, dataType: 'json' })
249 }
250
251 $.fn.load = function(url, success){
252 if (!this.length) return this
253 var self = this, parts = url.split(/\s/), selector
254 if (parts.length > 1) url = parts[0], selector = parts[1]
255 $.get(url, function(response){
256 self.html(selector ?
257 $('<div>').html(response.replace(rscript, "")).find(selector)
258 : response)
259 success && success.apply(self, arguments)
260 })
261 return this
262 }
263
264 var escape = encodeURIComponent
265
266 function serialize(params, obj, traditional, scope){
267 var array = $.isArray(obj)
268 $.each(obj, function(key, value) {
269 if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'
270 // handle data in serializeArray() format
271 if (!scope && array) params.add(value.name, value.value)
272 // recurse into nested objects
273 else if (traditional ? $.isArray(value) : isObject(value))
274 serialize(params, value, traditional, key)
275 else params.add(key, value)
276 })
277 }
278
279 $.param = function(obj, traditional){
280 var params = []
281 params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }
282 serialize(params, obj, traditional)
283 return params.join('&').replace(/%20/g, '+')
284 }
285})(Zepto)
diff --git a/frontend/gamma/js/Zepto/assets.js b/frontend/gamma/js/Zepto/assets.js
deleted file mode 100644
index b5a5712..0000000
--- a/frontend/gamma/js/Zepto/assets.js
+++ b/dev/null
@@ -1,21 +0,0 @@
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 cache = [], timeout
7
8 $.fn.remove = function(){
9 return this.each(function(){
10 if(this.parentNode){
11 if(this.tagName === 'IMG'){
12 cache.push(this)
13 this.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
14 if (timeout) clearTimeout(timeout)
15 timeout = setTimeout(function(){ cache = [] }, 60000)
16 }
17 this.parentNode.removeChild(this)
18 }
19 })
20 }
21})(Zepto)
diff --git a/frontend/gamma/js/Zepto/data.js b/frontend/gamma/js/Zepto/data.js
deleted file mode 100644
index b4c289f..0000000
--- a/frontend/gamma/js/Zepto/data.js
+++ b/dev/null
@@ -1,67 +0,0 @@
1// Zepto.js
2// (c) 2010-2012 Thomas Fuchs
3// Zepto.js may be freely distributed under the MIT license.
4
5// The following code is heavily inspired by jQuery's $.fn.data()
6
7;(function($) {
8 var data = {}, dataAttr = $.fn.data, camelize = $.camelCase,
9 exp = $.expando = 'Zepto' + (+new Date())
10
11 // Get value from node:
12 // 1. first try key as given,
13 // 2. then try camelized key,
14 // 3. fall back to reading "data-*" attribute.
15 function getData(node, name) {
16 var id = node[exp], store = id && data[id]
17 if (name === undefined) return store || setData(node)
18 else {
19 if (store) {
20 if (name in store) return store[name]
21 var camelName = camelize(name)
22 if (camelName in store) return store[camelName]
23 }
24 return dataAttr.call($(node), name)
25 }
26 }
27
28 // Store value under camelized key on node
29 function setData(node, name, value) {
30 var id = node[exp] || (node[exp] = ++$.uuid),
31 store = data[id] || (data[id] = attributeData(node))
32 if (name !== undefined) store[camelize(name)] = value
33 return store
34 }
35
36 // Read all "data-*" attributes from a node
37 function attributeData(node) {
38 var store = {}
39 $.each(node.attributes, function(i, attr){
40 if (attr.name.indexOf('data-') == 0)
41 store[camelize(attr.name.replace('data-', ''))] =
42 $.zepto.deserializeValue(attr.value)
43 })
44 return store
45 }
46
47 $.fn.data = function(name, value) {
48 return value === undefined ?
49 // set multiple values via object
50 $.isPlainObject(name) ?
51 this.each(function(i, node){
52 $.each(name, function(key, value){ setData(node, key, value) })
53 }) :
54 // get value from first element
55 this.length == 0 ? undefined : getData(this[0], name) :
56 // set value on all elements
57 this.each(function(){ setData(this, name, value) })
58 }
59
60 $.fn.removeData = function(names) {
61 if (typeof names == 'string') names = names.split(/\s+/)
62 return this.each(function(){
63 var id = this[exp], store = id && data[id]
64 if (store) $.each(names, function(){ delete store[camelize(this)] })
65 })
66 }
67})(Zepto)
diff --git a/frontend/gamma/js/Zepto/detect.js b/frontend/gamma/js/Zepto/detect.js
deleted file mode 100644
index 22c0386..0000000
--- a/frontend/gamma/js/Zepto/detect.js
+++ b/dev/null
@@ -1,42 +0,0 @@
1// Zepto.js
2// (c) 2010-2012 Thomas Fuchs
3// Zepto.js may be freely distributed under the MIT license.
4
5;(function($){
6 function detect(ua){
7 var os = this.os = {}, browser = this.browser = {},
8 webkit = ua.match(/WebKit\/([\d.]+)/),
9 android = ua.match(/(Android)\s+([\d.]+)/),
10 ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
11 iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
12 webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
13 touchpad = webos && ua.match(/TouchPad/),
14 kindle = ua.match(/Kindle\/([\d.]+)/),
15 silk = ua.match(/Silk\/([\d._]+)/),
16 blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/),
17 chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/)
18
19 // todo clean this up with a better OS/browser
20 // separation. we need to discern between multiple
21 // browsers on android, and decide if kindle fire in
22 // silk mode is android or not
23
24 if (browser.webkit = !!webkit) browser.version = webkit[1]
25
26 if (android) os.android = true, os.version = android[2]
27 if (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')
28 if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')
29 if (webos) os.webos = true, os.version = webos[2]
30 if (touchpad) os.touchpad = true
31 if (blackberry) os.blackberry = true, os.version = blackberry[2]
32 if (kindle) os.kindle = true, os.version = kindle[1]
33 if (silk) browser.silk = true, browser.version = silk[1]
34 if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true
35 if (chrome) browser.chrome = true, browser.version = chrome[1]
36 }
37
38 detect.call($, navigator.userAgent)
39 // make available to unit tests
40 $.__detect = detect
41
42})(Zepto)
diff --git a/frontend/gamma/js/Zepto/event.js b/frontend/gamma/js/Zepto/event.js
deleted file mode 100644
index b40af22..0000000
--- a/frontend/gamma/js/Zepto/event.js
+++ b/dev/null
@@ -1,248 +0,0 @@
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 ($.isObject(events)) $.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)
diff --git a/frontend/gamma/js/Zepto/form.js b/frontend/gamma/js/Zepto/form.js
deleted file mode 100644
index 4d562a6..0000000
--- a/frontend/gamma/js/Zepto/form.js
+++ b/dev/null
@@ -1,40 +0,0 @@
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)
diff --git a/frontend/gamma/js/Zepto/fx.js b/frontend/gamma/js/Zepto/fx.js
deleted file mode 100644
index 575449a..0000000
--- a/frontend/gamma/js/Zepto/fx.js
+++ b/dev/null
@@ -1,102 +0,0 @@
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 ($.isObject(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, arguments.callee)
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)
diff --git a/frontend/gamma/js/Zepto/fx_methods.js b/frontend/gamma/js/Zepto/fx_methods.js
deleted file mode 100644
index 23daf6e..0000000
--- a/frontend/gamma/js/Zepto/fx_methods.js
+++ b/dev/null
@@ -1,71 +0,0 @@
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)
diff --git a/frontend/gamma/js/Zepto/gesture.js b/frontend/gamma/js/Zepto/gesture.js
deleted file mode 100644
index 035455b..0000000
--- a/frontend/gamma/js/Zepto/gesture.js
+++ b/dev/null
@@ -1,35 +0,0 @@
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)
diff --git a/frontend/gamma/js/Zepto/polyfill.js b/frontend/gamma/js/Zepto/polyfill.js
deleted file mode 100644
index 933d1f8..0000000
--- a/frontend/gamma/js/Zepto/polyfill.js
+++ b/dev/null
@@ -1,36 +0,0 @@
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})()
diff --git a/frontend/gamma/js/Zepto/selector.js b/frontend/gamma/js/Zepto/selector.js
deleted file mode 100644
index c0b035a..0000000
--- a/frontend/gamma/js/Zepto/selector.js
+++ b/dev/null
@@ -1,81 +0,0 @@
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 // ul.inner:first > li
20 var filters = $.expr[':'] = {
21 visible: function(){ if (visible(this)) return this },
22 hidden: function(){ if (!visible(this)) return this },
23 selected: function(){ if (this.selected) return this },
24 checked: function(){ if (this.checked) return this },
25 parent: function(){ return this.parentNode },
26 first: function(idx){ if (idx === 0) return this },
27 last: function(idx, nodes){ if (idx === nodes.length - 1) return this },
28 eq: function(idx, _, value){ if (idx === value) return this },
29 contains: function(idx, _, text){ if ($(this).text().indexOf(text) > -1) return this },
30 has: function(idx, _, sel){ if (zepto.qsa(this, sel).length) return this }
31 }
32
33 var filterRe = new RegExp('(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*'),
34 childRe = /^\s*>/,
35 classTag = 'Zepto' + (+new Date())
36
37 function process(sel, fn) {
38 // quote the hash in `a[href^=#]` expression
39 sel = sel.replace(/=#\]/g, '="#"]')
40 var filter, arg, match = filterRe.exec(sel)
41 if (match && match[2] in filters) {
42 var filter = filters[match[2]], arg = match[3]
43 sel = match[1]
44 if (arg) {
45 var num = Number(arg)
46 if (isNaN(num)) arg = arg.replace(/^["']|["']$/g, '')
47 else arg = num
48 }
49 }
50 return fn(sel, filter, arg)
51 }
52
53 zepto.qsa = function(node, selector) {
54 return process(selector, function(sel, filter, arg){
55 try {
56 var taggedParent
57 if (!sel && filter) sel = '*'
58 else if (childRe.test(sel))
59 // support "> *" child queries by tagging the parent node with a
60 // unique class and prepending that classname onto the selector
61 taggedParent = $(node).addClass(classTag), sel = '.'+classTag+' '+sel
62
63 var nodes = oldQsa(node, sel)
64 } catch(e) {
65 console.error('error performing selector: %o', selector)
66 throw e
67 } finally {
68 if (taggedParent) taggedParent.removeClass(classTag)
69 }
70 return !filter ? nodes :
71 zepto.uniq($.map(nodes, function(n, i){ return filter.call(n, i, nodes, arg) }))
72 })
73 }
74
75 zepto.matches = function(node, selector){
76 return process(selector, function(sel, filter, arg){
77 return (!sel || oldMatches(node, sel)) &&
78 (!filter || filter.call(node, null, arg) === node)
79 })
80 }
81})(Zepto)
diff --git a/frontend/gamma/js/Zepto/stack.js b/frontend/gamma/js/Zepto/stack.js
deleted file mode 100644
index c995285..0000000
--- a/frontend/gamma/js/Zepto/stack.js
+++ b/dev/null
@@ -1,22 +0,0 @@
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)
diff --git a/frontend/gamma/js/Zepto/touch.js b/frontend/gamma/js/Zepto/touch.js
deleted file mode 100644
index af109b9..0000000
--- a/frontend/gamma/js/Zepto/touch.js
+++ b/dev/null
@@ -1,113 +0,0 @@
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 = {},
7 touchTimeout, tapTimeout, swipeTimeout,
8 longTapDelay = 750, longTapTimeout
9
10 function parentIfText(node) {
11 return 'tagName' in node ? node : node.parentNode
12 }
13
14 function swipeDirection(x1, x2, y1, y2) {
15 var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)
16 return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
17 }
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 function cancelAll() {
33 if (touchTimeout) clearTimeout(touchTimeout)
34 if (tapTimeout) clearTimeout(tapTimeout)
35 if (swipeTimeout) clearTimeout(swipeTimeout)
36 if (longTapTimeout) clearTimeout(longTapTimeout)
37 touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null
38 touch = {}
39 }
40
41 $(document).ready(function(){
42 var now, delta
43
44 $(document.body)
45 .bind('touchstart', function(e){
46 now = Date.now()
47 delta = now - (touch.last || now)
48 touch.el = $(parentIfText(e.touches[0].target))
49 touchTimeout && clearTimeout(touchTimeout)
50 touch.x1 = e.touches[0].pageX
51 touch.y1 = e.touches[0].pageY
52 if (delta > 0 && delta <= 250) touch.isDoubleTap = true
53 touch.last = now
54 longTapTimeout = setTimeout(longTap, longTapDelay)
55 })
56 .bind('touchmove', function(e){
57 cancelLongTap()
58 touch.x2 = e.touches[0].pageX
59 touch.y2 = e.touches[0].pageY
60 })
61 .bind('touchend', function(e){
62 cancelLongTap()
63
64 // swipe
65 if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
66 (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
67
68 swipeTimeout = setTimeout(function() {
69 touch.el.trigger('swipe')
70 touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
71 touch = {}
72 }, 0)
73
74 // normal tap
75 else if ('last' in touch)
76
77 // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
78 // ('tap' fires before 'scroll')
79 tapTimeout = setTimeout(function() {
80
81 // trigger universal 'tap' with the option to cancelTouch()
82 // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
83 var event = $.Event('tap')
84 event.cancelTouch = cancelAll
85 touch.el.trigger(event)
86
87 // trigger double tap immediately
88 if (touch.isDoubleTap) {
89 touch.el.trigger('doubleTap')
90 touch = {}
91 }
92
93 // trigger single tap after 250ms of inactivity
94 else {
95 touchTimeout = setTimeout(function(){
96 touchTimeout = null
97 touch.el.trigger('singleTap')
98 touch = {}
99 }, 250)
100 }
101
102 }, 0)
103
104 })
105 .bind('touchcancel', cancelAll)
106
107 $(window).bind('scroll', cancelAll)
108 })
109
110 ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){
111 $.fn[m] = function(callback){ return this.bind(m, callback) }
112 })
113})(Zepto)
diff --git a/frontend/gamma/js/Zepto/zepto.js b/frontend/gamma/js/Zepto/zepto.js
deleted file mode 100644
index e67b3a2..0000000
--- a/frontend/gamma/js/Zepto/zepto.js
+++ b/dev/null
@@ -1,751 +0,0 @@
1// Zepto.js
2// (c) 2010-2012 Thomas Fuchs
3// Zepto.js may be freely distributed under the MIT license.
4
5var Zepto = (function() {
6 var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
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 tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
13 rootNodeRE = /^(?:body|html)$/i,
14
15 // special attributes that should be get/set via method calls
16 methodAttributes = ['val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset'],
17
18 adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
19 table = document.createElement('table'),
20 tableRow = document.createElement('tr'),
21 containers = {
22 'tr': document.createElement('tbody'),
23 'tbody': table, 'thead': table, 'tfoot': table,
24 'td': tableRow, 'th': tableRow,
25 '*': document.createElement('div')
26 },
27 readyRE = /complete|loaded|interactive/,
28 classSelectorRE = /^\.([\w-]+)$/,
29 idSelectorRE = /^#([\w-]*)$/,
30 tagSelectorRE = /^[\w-]+$/,
31 toString = {}.toString,
32 zepto = {},
33 camelize, uniq,
34 tempParent = document.createElement('div')
35
36 zepto.matches = function(element, selector) {
37 if (!element || element.nodeType !== 1) return false
38 var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||
39 element.oMatchesSelector || element.matchesSelector
40 if (matchesSelector) return matchesSelector.call(element, selector)
41 // fall back to performing a selector:
42 var match, parent = element.parentNode, temp = !parent
43 if (temp) (parent = tempParent).appendChild(element)
44 match = ~zepto.qsa(parent, selector).indexOf(element)
45 temp && tempParent.removeChild(element)
46 return match
47 }
48
49 function isFunction(value) { return toString.call(value) == "[object Function]" }
50 function isObject(value) { return value instanceof Object }
51 function isPlainObject(value) {
52 return isObject(value) && value != window && value.__proto__ == Object.prototype
53 }
54 function isArray(value) { return value instanceof Array }
55 function likeArray(obj) { return typeof obj.length == 'number' }
56
57 function compact(array) { return filter.call(array, function(item){ return item != null }) }
58 function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
59 camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
60 function dasherize(str) {
61 return str.replace(/::/g, '/')
62 .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
63 .replace(/([a-z\d])([A-Z])/g, '$1_$2')
64 .replace(/_/g, '-')
65 .toLowerCase()
66 }
67 uniq = function(array){ return filter.call(array, function(item, idx){ return array.indexOf(item) == idx }) }
68
69 function classRE(name) {
70 return name in classCache ?
71 classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'))
72 }
73
74 function maybeAddPx(name, value) {
75 return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value
76 }
77
78 function defaultDisplay(nodeName) {
79 var element, display
80 if (!elementDisplay[nodeName]) {
81 element = document.createElement(nodeName)
82 document.body.appendChild(element)
83 display = getComputedStyle(element, '').getPropertyValue("display")
84 element.parentNode.removeChild(element)
85 display == "none" && (display = "block")
86 elementDisplay[nodeName] = display
87 }
88 return elementDisplay[nodeName]
89 }
90
91 function children(element) {
92 return 'children' in element ?
93 slice.call(element.children) :
94 $.map(element.childNodes, function(node){ if (node.nodeType == 1) return node })
95 }
96
97 // `$.zepto.fragment` takes a html string and an optional tag name
98 // to generate DOM nodes nodes from the given html string.
99 // The generated DOM nodes are returned as an array.
100 // This function can be overriden in plugins for example to make
101 // it compatible with browsers that don't support the DOM fully.
102 zepto.fragment = function(html, name, properties) {
103 if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
104 if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
105 if (!(name in containers)) name = '*'
106
107 var nodes, dom, container = containers[name]
108 container.innerHTML = '' + html
109 dom = $.each(slice.call(container.childNodes), function(){
110 container.removeChild(this)
111 })
112 if (isPlainObject(properties)) {
113 nodes = $(dom)
114 $.each(properties, function(key, value) {
115 if (methodAttributes.indexOf(key) > -1) nodes[key](value)
116 else nodes.attr(key, value)
117 })
118 }
119 return dom
120 }
121
122 // `$.zepto.Z` swaps out the prototype of the given `dom` array
123 // of nodes with `$.fn` and thus supplying all the Zepto functions
124 // to the array. Note that `__proto__` is not supported on Internet
125 // Explorer. This method can be overriden in plugins.
126 zepto.Z = function(dom, selector) {
127 dom = dom || []
128 dom.__proto__ = arguments.callee.prototype
129 dom.selector = selector || ''
130 return dom
131 }
132
133 // `$.zepto.isZ` should return `true` if the given object is a Zepto
134 // collection. This method can be overriden in plugins.
135 zepto.isZ = function(object) {
136 return object instanceof zepto.Z
137 }
138
139 // `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
140 // takes a CSS selector and an optional context (and handles various
141 // special cases).
142 // This method can be overriden in plugins.
143 zepto.init = function(selector, context) {
144 // If nothing given, return an empty Zepto collection
145 if (!selector) return zepto.Z()
146 // If a function is given, call it when the DOM is ready
147 else if (isFunction(selector)) return $(document).ready(selector)
148 // If a Zepto collection is given, juts return it
149 else if (zepto.isZ(selector)) return selector
150 else {
151 var dom
152 // normalize array if an array of nodes is given
153 if (isArray(selector)) dom = compact(selector)
154 // Wrap DOM nodes. If a plain object is given, duplicate it.
155 else if (isObject(selector))
156 dom = [isPlainObject(selector) ? $.extend({}, selector) : selector], selector = null
157 // If it's a html fragment, create nodes from it
158 else if (fragmentRE.test(selector))
159 dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null
160 // If there's a context, create a collection on that context first, and select
161 // nodes from there
162 else if (context !== undefined) return $(context).find(selector)
163 // And last but no least, if it's a CSS selector, use it to select nodes.
164 else dom = zepto.qsa(document, selector)
165 // create a new Zepto collection from the nodes found
166 return zepto.Z(dom, selector)
167 }
168 }
169
170 // `$` will be the base `Zepto` object. When calling this
171 // function just call `$.zepto.init, which makes the implementation
172 // details of selecting nodes and creating Zepto collections
173 // patchable in plugins.
174 $ = function(selector, context){
175 return zepto.init(selector, context)
176 }
177
178 function extend(target, source, deep) {
179 for (key in source)
180 if (deep && isPlainObject(source[key])) {
181 if (!isPlainObject(target[key])) target[key] = {}
182 extend(target[key], source[key], deep)
183 }
184 else if (source[key] !== undefined) target[key] = source[key]
185 }
186
187 // Copy all but undefined properties from one or more
188 // objects to the `target` object.
189 $.extend = function(target){
190 var deep, args = slice.call(arguments, 1)
191 if (typeof target == 'boolean') {
192 deep = target
193 target = args.shift()
194 }
195 args.forEach(function(arg){ extend(target, arg, deep) })
196 return target
197 }
198
199 // `$.zepto.qsa` is Zepto's CSS selector implementation which
200 // uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
201 // This method can be overriden in plugins.
202 zepto.qsa = function(element, selector){
203 var found
204 return (element === document && idSelectorRE.test(selector)) ?
205 ( (found = element.getElementById(RegExp.$1)) ? [found] : [] ) :
206 (element.nodeType !== 1 && element.nodeType !== 9) ? [] :
207 slice.call(
208 classSelectorRE.test(selector) ? element.getElementsByClassName(RegExp.$1) :
209 tagSelectorRE.test(selector) ? element.getElementsByTagName(selector) :
210 element.querySelectorAll(selector)
211 )
212 }
213
214 function filtered(nodes, selector) {
215 return selector === undefined ? $(nodes) : $(nodes).filter(selector)
216 }
217
218 $.contains = function(parent, node) {
219 return parent !== node && parent.contains(node)
220 }
221
222 function funcArg(context, arg, idx, payload) {
223 return isFunction(arg) ? arg.call(context, idx, payload) : arg
224 }
225
226 function setAttribute(node, name, value) {
227 value == null ? node.removeAttribute(name) : node.setAttribute(name, value)
228 }
229
230 // access className property while respecting SVGAnimatedString
231 function className(node, value){
232 var klass = node.className,
233 svg = klass && klass.baseVal !== undefined
234
235 if (value === undefined) return svg ? klass.baseVal : klass
236 svg ? (klass.baseVal = value) : (node.className = value)
237 }
238
239 // "true" => true
240 // "false" => false
241 // "null" => null
242 // "42" => 42
243 // "42.5" => 42.5
244 // JSON => parse if valid
245 // String => self
246 function deserializeValue(value) {
247 var num
248 try {
249 return value ?
250 value == "true" ||
251 ( value == "false" ? false :
252 value == "null" ? null :
253 !isNaN(num = Number(value)) ? num :
254 /^[\[\{]/.test(value) ? $.parseJSON(value) :
255 value )
256 : value
257 } catch(e) {
258 return value
259 }
260 }
261
262 $.isFunction = isFunction
263 $.isObject = isObject
264 $.isArray = isArray
265 $.isPlainObject = isPlainObject
266
267 $.inArray = function(elem, array, i){
268 return emptyArray.indexOf.call(array, elem, i)
269 }
270
271 $.camelCase = camelize
272 $.trim = function(str) { return str.trim() }
273
274 // plugin compatibility
275 $.uuid = 0
276 $.support = { }
277 $.expr = { }
278
279 $.map = function(elements, callback){
280 var value, values = [], i, key
281 if (likeArray(elements))
282 for (i = 0; i < elements.length; i++) {
283 value = callback(elements[i], i)
284 if (value != null) values.push(value)
285 }
286 else
287 for (key in elements) {
288 value = callback(elements[key], key)
289 if (value != null) values.push(value)
290 }
291 return flatten(values)
292 }
293
294 $.each = function(elements, callback){
295 var i, key
296 if (likeArray(elements)) {
297 for (i = 0; i < elements.length; i++)
298 if (callback.call(elements[i], i, elements[i]) === false) return elements
299 } else {
300 for (key in elements)
301 if (callback.call(elements[key], key, elements[key]) === false) return elements
302 }
303
304 return elements
305 }
306
307 $.grep = function(elements, callback){
308 return filter.call(elements, callback)
309 }
310
311 if (window.JSON) $.parseJSON = JSON.parse
312
313 // Define methods that will be available on all
314 // Zepto collections
315 $.fn = {
316 // Because a collection acts like an array
317 // copy over these useful array functions.
318 forEach: emptyArray.forEach,
319 reduce: emptyArray.reduce,
320 push: emptyArray.push,
321 sort: emptyArray.sort,
322 indexOf: emptyArray.indexOf,
323 concat: emptyArray.concat,
324
325 // `map` and `slice` in the jQuery API work differently
326 // from their array counterparts
327 map: function(fn){
328 return $($.map(this, function(el, i){ return fn.call(el, i, el) }))
329 },
330 slice: function(){
331 return $(slice.apply(this, arguments))
332 },
333
334 ready: function(callback){
335 if (readyRE.test(document.readyState)) callback($)
336 else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
337 return this
338 },
339 get: function(idx){
340 return idx === undefined ? slice.call(this) : this[idx]
341 },
342 toArray: function(){ return this.get() },
343 size: function(){
344 return this.length
345 },
346 remove: function(){
347 return this.each(function(){
348 if (this.parentNode != null)
349 this.parentNode.removeChild(this)
350 })
351 },
352 each: function(callback){
353 emptyArray.every.call(this, function(el, idx){
354 return callback.call(el, idx, el) !== false
355 })
356 return this
357 },
358 filter: function(selector){
359 if (isFunction(selector)) return this.not(this.not(selector))
360 return $(filter.call(this, function(element){
361 return zepto.matches(element, selector)
362 }))
363 },
364 add: function(selector,context){
365 return $(uniq(this.concat($(selector,context))))
366 },
367 is: function(selector){
368 return this.length > 0 && zepto.matches(this[0], selector)
369 },
370 not: function(selector){
371 var nodes=[]
372 if (isFunction(selector) && selector.call !== undefined)
373 this.each(function(idx){
374 if (!selector.call(this,idx)) nodes.push(this)
375 })
376 else {
377 var excludes = typeof selector == 'string' ? this.filter(selector) :
378 (likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)
379 this.forEach(function(el){
380 if (excludes.indexOf(el) < 0) nodes.push(el)
381 })
382 }
383 return $(nodes)
384 },
385 has: function(selector){
386 return this.filter(function(){
387 return isObject(selector) ?
388 $.contains(this, selector) :
389 $(this).find(selector).size()
390 })
391 },
392 eq: function(idx){
393 return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)
394 },
395 first: function(){
396 var el = this[0]
397 return el && !isObject(el) ? el : $(el)
398 },
399 last: function(){
400 var el = this[this.length - 1]
401 return el && !isObject(el) ? el : $(el)
402 },
403 find: function(selector){
404 var result
405 if (this.length == 1) result = $(zepto.qsa(this[0], selector))
406 else result = this.map(function(){ return zepto.qsa(this, selector) })
407 return result
408 },
409 closest: function(selector, context){
410 var node = this[0]
411 while (node && !zepto.matches(node, selector))
412 node = node !== context && node !== document && node.parentNode
413 return $(node)
414 },
415 parents: function(selector){
416 var ancestors = [], nodes = this
417 while (nodes.length > 0)
418 nodes = $.map(nodes, function(node){
419 if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {
420 ancestors.push(node)
421 return node
422 }
423 })
424 return filtered(ancestors, selector)
425 },
426 parent: function(selector){
427 return filtered(uniq(this.pluck('parentNode')), selector)
428 },
429 children: function(selector){
430 return filtered(this.map(function(){ return children(this) }), selector)
431 },
432 contents: function() {
433 return this.map(function() { return slice.call(this.childNodes) })
434 },
435 siblings: function(selector){
436 return filtered(this.map(function(i, el){
437 return filter.call(children(el.parentNode), function(child){ return child!==el })
438 }), selector)
439 },
440 empty: function(){
441 return this.each(function(){ this.innerHTML = '' })
442 },
443 // `pluck` is borrowed from Prototype.js
444 pluck: function(property){
445 return $.map(this, function(el){ return el[property] })
446 },
447 show: function(){
448 return this.each(function(){
449 this.style.display == "none" && (this.style.display = null)
450 if (getComputedStyle(this, '').getPropertyValue("display") == "none")
451 this.style.display = defaultDisplay(this.nodeName)
452 })
453 },
454 replaceWith: function(newContent){
455 return this.before(newContent).remove()
456 },
457 wrap: function(structure){
458 var func = isFunction(structure)
459 if (this[0] && !func)
460 var dom = $(structure).get(0),
461 clone = dom.parentNode || this.length > 1
462
463 return this.each(function(index){
464 $(this).wrapAll(
465 func ? structure.call(this, index) :
466 clone ? dom.cloneNode(true) : dom
467 )
468 })
469 },
470 wrapAll: function(structure){
471 if (this[0]) {
472 $(this[0]).before(structure = $(structure))
473 var children
474 // drill down to the inmost element
475 while ((children = structure.children()).length) structure = children.first()
476 $(structure).append(this)
477 }
478 return this
479 },
480 wrapInner: function(structure){
481 var func = isFunction(structure)
482 return this.each(function(index){
483 var self = $(this), contents = self.contents(),
484 dom = func ? structure.call(this, index) : structure
485 contents.length ? contents.wrapAll(dom) : self.append(dom)
486 })
487 },
488 unwrap: function(){
489 this.parent().each(function(){
490 $(this).replaceWith($(this).children())
491 })
492 return this
493 },
494 clone: function(){
495 return this.map(function(){ return this.cloneNode(true) })
496 },
497 hide: function(){
498 return this.css("display", "none")
499 },
500 toggle: function(setting){
501 return this.each(function(){
502 var el = $(this)
503 ;(setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide()
504 })
505 },
506 prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') },
507 next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') },
508 html: function(html){
509 return html === undefined ?
510 (this.length > 0 ? this[0].innerHTML : null) :
511 this.each(function(idx){
512 var originHtml = this.innerHTML
513 $(this).empty().append( funcArg(this, html, idx, originHtml) )
514 })
515 },
516 text: function(text){
517 return text === undefined ?
518 (this.length > 0 ? this[0].textContent : null) :
519 this.each(function(){ this.textContent = text })
520 },
521 attr: function(name, value){
522 var result
523 return (typeof name == 'string' && value === undefined) ?
524 (this.length == 0 || this[0].nodeType !== 1 ? undefined :
525 (name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :
526 (!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
527 ) :
528 this.each(function(idx){
529 if (this.nodeType !== 1) return
530 if (isObject(name)) for (key in name) setAttribute(this, key, name[key])
531 else setAttribute(this, name, funcArg(this, value, idx, this.getAttribute(name)))
532 })
533 },
534 removeAttr: function(name){
535 return this.each(function(){ this.nodeType === 1 && setAttribute(this, name) })
536 },
537 prop: function(name, value){
538 return (value === undefined) ?
539 (this[0] && this[0][name]) :
540 this.each(function(idx){
541 this[name] = funcArg(this, value, idx, this[name])
542 })
543 },
544 data: function(name, value){
545 var data = this.attr('data-' + dasherize(name), value)
546 return data !== null ? deserializeValue(data) : undefined
547 },
548 val: function(value){
549 return (value === undefined) ?
550 (this[0] && (this[0].multiple ?
551 $(this[0]).find('option').filter(function(o){ return this.selected }).pluck('value') :
552 this[0].value)
553 ) :
554 this.each(function(idx){
555 this.value = funcArg(this, value, idx, this.value)
556 })
557 },
558 offset: function(coordinates){
559 if (coordinates) return this.each(function(index){
560 var $this = $(this),
561 coords = funcArg(this, coordinates, index, $this.offset()),
562 parentOffset = $this.offsetParent().offset(),
563 props = {
564 top: coords.top - parentOffset.top,
565 left: coords.left - parentOffset.left
566 }
567
568 if ($this.css('position') == 'static') props['position'] = 'relative'
569 $this.css(props)
570 })
571 if (this.length==0) return null
572 var obj = this[0].getBoundingClientRect()
573 return {
574 left: obj.left + window.pageXOffset,
575 top: obj.top + window.pageYOffset,
576 width: obj.width,
577 height: obj.height
578 }
579 },
580 css: function(property, value){
581 if (arguments.length < 2 && typeof property == 'string')
582 return this[0] && (this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
583
584 var css = ''
585 for (key in property)
586 if (!property[key] && property[key] !== 0)
587 this.each(function(){ this.style.removeProperty(dasherize(key)) })
588 else
589 css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
590
591 if (typeof property == 'string')
592 if (!value && value !== 0)
593 this.each(function(){ this.style.removeProperty(dasherize(property)) })
594 else
595 css = dasherize(property) + ":" + maybeAddPx(property, value)
596
597 return this.each(function(){ this.style.cssText += ';' + css })
598 },
599 index: function(element){
600 return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])
601 },
602 hasClass: function(name){
603 return emptyArray.some.call(this, function(el){
604 return this.test(className(el))
605 }, classRE(name))
606 },
607 addClass: function(name){
608 return this.each(function(idx){
609 classList = []
610 var cls = className(this), newName = funcArg(this, name, idx, cls)
611 newName.split(/\s+/g).forEach(function(klass){
612 if (!$(this).hasClass(klass)) classList.push(klass)
613 }, this)
614 classList.length && className(this, cls + (cls ? " " : "") + classList.join(" "))
615 })
616 },
617 removeClass: function(name){
618 return this.each(function(idx){
619 if (name === undefined) return className(this, '')
620 classList = className(this)
621 funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){
622 classList = classList.replace(classRE(klass), " ")
623 })
624 className(this, classList.trim())
625 })
626 },
627 toggleClass: function(name, when){
628 return this.each(function(idx){
629 var newName = funcArg(this, name, idx, className(this))
630 ;(when === undefined ? !$(this).hasClass(newName) : when) ?
631 $(this).addClass(newName) : $(this).removeClass(newName)
632 })
633 },
634 scrollTop: function(){
635 if (!this.length) return
636 return ('scrollTop' in this[0]) ? this[0].scrollTop : this[0].scrollY
637 },
638 position: function() {
639 if (!this.length) return
640
641 var elem = this[0],
642 // Get *real* offsetParent
643 offsetParent = this.offsetParent(),
644 // Get correct offsets
645 offset = this.offset(),
646 parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset()
647
648 // Subtract element margins
649 // note: when an element has margin: auto the offsetLeft and marginLeft
650 // are the same in Safari causing offset.left to incorrectly be 0
651 offset.top -= parseFloat( $(elem).css('margin-top') ) || 0
652 offset.left -= parseFloat( $(elem).css('margin-left') ) || 0
653
654 // Add offsetParent borders
655 parentOffset.top += parseFloat( $(offsetParent[0]).css('border-top-width') ) || 0
656 parentOffset.left += parseFloat( $(offsetParent[0]).css('border-left-width') ) || 0
657
658 // Subtract the two offsets
659 return {
660 top: offset.top - parentOffset.top,
661 left: offset.left - parentOffset.left
662 }
663 },
664 offsetParent: function() {
665 return this.map(function(){
666 var parent = this.offsetParent || document.body
667 while (parent && !rootNodeRE.test(parent.nodeName) && $(parent).css("position") == "static")
668 parent = parent.offsetParent
669 return parent
670 })
671 }
672 }
673
674 // for now
675 $.fn.detach = $.fn.remove
676
677 // Generate the `width` and `height` functions
678 ;['width', 'height'].forEach(function(dimension){
679 $.fn[dimension] = function(value){
680 var offset, Dimension = dimension.replace(/./, function(m){ return m[0].toUpperCase() })
681 if (value === undefined) return this[0] == window ? window['inner' + Dimension] :
682 this[0] == document ? document.documentElement['offset' + Dimension] :
683 (offset = this.offset()) && offset[dimension]
684 else return this.each(function(idx){
685 var el = $(this)
686 el.css(dimension, funcArg(this, value, idx, el[dimension]()))
687 })
688 }
689 })
690
691 function traverseNode(node, fun) {
692 fun(node)
693 for (var key in node.childNodes) traverseNode(node.childNodes[key], fun)
694 }
695
696 // Generate the `after`, `prepend`, `before`, `append`,
697 // `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
698 adjacencyOperators.forEach(function(operator, operatorIndex) {
699 var inside = operatorIndex % 2 //=> prepend, append
700
701 $.fn[operator] = function(){
702 // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
703 var nodes = $.map(arguments, function(n){ return isObject(n) ? n : zepto.fragment(n) }),
704 parent, copyByClone = this.length > 1
705 if (nodes.length < 1) return this
706
707 return this.each(function(_, target){
708 parent = inside ? target : target.parentNode
709
710 // convert all methods to a "before" operation
711 target = operatorIndex == 0 ? target.nextSibling :
712 operatorIndex == 1 ? target.firstChild :
713 operatorIndex == 2 ? target :
714 null
715
716 nodes.forEach(function(node){
717 if (copyByClone) node = node.cloneNode(true)
718 else if (!parent) return $(node).remove()
719
720 traverseNode(parent.insertBefore(node, target), function(el){
721 if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
722 (!el.type || el.type === 'text/javascript') && !el.src)
723 window['eval'].call(window, el.innerHTML)
724 })
725 })
726 })
727 }
728
729 // after => insertAfter
730 // prepend => prependTo
731 // before => insertBefore
732 // append => appendTo
733 $.fn[inside ? operator+'To' : 'insert'+(operatorIndex ? 'Before' : 'After')] = function(html){
734 $(html)[operator](this)
735 return this
736 }
737 })
738
739 zepto.Z.prototype = $.fn
740
741 // Export internal API functions in the `$.zepto` namespace
742 zepto.uniq = uniq
743 zepto.deserializeValue = deserializeValue
744 $.zepto = zepto
745
746 return $
747})()
748
749// If `$` is not yet defined, point it to `Zepto`
750window.Zepto = Zepto
751'$' in window || (window.$ = Zepto)