|
@@ -1,7 +1,12 @@
|
|
|
-/* Zepto v1.1.6 - zepto event ajax form ie - zeptojs.com/license */
|
|
|
-
|
|
|
-var Zepto = (function() {
|
|
|
- var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
|
|
|
+/* Zepto 1.2.0 - zepto event ajax form ie touch fx fx_methods - zeptojs.com/license */
|
|
|
+(function(global, factory) {
|
|
|
+ if (typeof define === 'function' && define.amd)
|
|
|
+ define(function() { return factory(global) })
|
|
|
+ else
|
|
|
+ factory(global)
|
|
|
+}(window, function(window) {
|
|
|
+ var Zepto = (function() {
|
|
|
+ var undefined, key, $, classList, emptyArray = [], concat = emptyArray.concat, filter = emptyArray.filter, slice = emptyArray.slice,
|
|
|
document = window.document,
|
|
|
elementDisplay = {}, classCache = {},
|
|
|
cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
|
|
@@ -23,7 +28,6 @@ var Zepto = (function() {
|
|
|
'td': tableRow, 'th': tableRow,
|
|
|
'*': document.createElement('div')
|
|
|
},
|
|
|
- readyRE = /complete|loaded|interactive/,
|
|
|
simpleSelectorRE = /^[\w-]*$/,
|
|
|
class2type = {},
|
|
|
toString = class2type.toString,
|
|
@@ -49,8 +53,9 @@ var Zepto = (function() {
|
|
|
|
|
|
zepto.matches = function(element, selector) {
|
|
|
if (!selector || !element || element.nodeType !== 1) return false
|
|
|
- var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||
|
|
|
- element.oMatchesSelector || element.matchesSelector
|
|
|
+ var matchesSelector = element.matches || element.webkitMatchesSelector ||
|
|
|
+ element.mozMatchesSelector || element.oMatchesSelector ||
|
|
|
+ element.matchesSelector
|
|
|
if (matchesSelector) return matchesSelector.call(element, selector)
|
|
|
// fall back to performing a selector:
|
|
|
var match, parent = element.parentNode, temp = !parent
|
|
@@ -72,7 +77,16 @@ var Zepto = (function() {
|
|
|
function isPlainObject(obj) {
|
|
|
return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype
|
|
|
}
|
|
|
- function likeArray(obj) { return typeof obj.length == 'number' }
|
|
|
+
|
|
|
+ function likeArray(obj) {
|
|
|
+ var length = !!obj && 'length' in obj && obj.length,
|
|
|
+ type = $.type(obj)
|
|
|
+
|
|
|
+ return 'function' != type && !isWindow(obj) && (
|
|
|
+ 'array' == type || length === 0 ||
|
|
|
+ (typeof length == 'number' && length > 0 && (length - 1) in obj)
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
function compact(array) { return filter.call(array, function(item){ return item != null }) }
|
|
|
function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
|
|
@@ -114,10 +128,17 @@ var Zepto = (function() {
|
|
|
$.map(element.childNodes, function(node){ if (node.nodeType == 1) return node })
|
|
|
}
|
|
|
|
|
|
+ function Z(dom, selector) {
|
|
|
+ var i, len = dom ? dom.length : 0
|
|
|
+ for (i = 0; i < len; i++) this[i] = dom[i]
|
|
|
+ this.length = len
|
|
|
+ this.selector = selector || ''
|
|
|
+ }
|
|
|
+
|
|
|
// `$.zepto.fragment` takes a html string and an optional tag name
|
|
|
- // to generate DOM nodes nodes from the given html string.
|
|
|
+ // to generate DOM nodes from the given html string.
|
|
|
// The generated DOM nodes are returned as an array.
|
|
|
- // This function can be overriden in plugins for example to make
|
|
|
+ // This function can be overridden in plugins for example to make
|
|
|
// it compatible with browsers that don't support the DOM fully.
|
|
|
zepto.fragment = function(html, name, properties) {
|
|
|
var dom, nodes, container
|
|
@@ -150,17 +171,13 @@ var Zepto = (function() {
|
|
|
|
|
|
// `$.zepto.Z` swaps out the prototype of the given `dom` array
|
|
|
// of nodes with `$.fn` and thus supplying all the Zepto functions
|
|
|
- // to the array. Note that `__proto__` is not supported on Internet
|
|
|
- // Explorer. This method can be overriden in plugins.
|
|
|
+ // to the array. This method can be overridden in plugins.
|
|
|
zepto.Z = function(dom, selector) {
|
|
|
- dom = dom || []
|
|
|
- dom.__proto__ = $.fn
|
|
|
- dom.selector = selector || ''
|
|
|
- return dom
|
|
|
+ return new Z(dom, selector)
|
|
|
}
|
|
|
|
|
|
// `$.zepto.isZ` should return `true` if the given object is a Zepto
|
|
|
- // collection. This method can be overriden in plugins.
|
|
|
+ // collection. This method can be overridden in plugins.
|
|
|
zepto.isZ = function(object) {
|
|
|
return object instanceof zepto.Z
|
|
|
}
|
|
@@ -168,7 +185,7 @@ var Zepto = (function() {
|
|
|
// `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
|
|
|
// takes a CSS selector and an optional context (and handles various
|
|
|
// special cases).
|
|
|
- // This method can be overriden in plugins.
|
|
|
+ // This method can be overridden in plugins.
|
|
|
zepto.init = function(selector, context) {
|
|
|
var dom
|
|
|
// If nothing given, return an empty Zepto collection
|
|
@@ -244,18 +261,18 @@ var Zepto = (function() {
|
|
|
|
|
|
// `$.zepto.qsa` is Zepto's CSS selector implementation which
|
|
|
// uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
|
|
|
- // This method can be overriden in plugins.
|
|
|
+ // This method can be overridden in plugins.
|
|
|
zepto.qsa = function(element, selector){
|
|
|
var found,
|
|
|
maybeID = selector[0] == '#',
|
|
|
maybeClass = !maybeID && selector[0] == '.',
|
|
|
nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked
|
|
|
isSimple = simpleSelectorRE.test(nameOnly)
|
|
|
- return (isDocument(element) && isSimple && maybeID) ?
|
|
|
+ return (element.getElementById && isSimple && maybeID) ? // Safari DocumentFragment doesn't have getElementById
|
|
|
( (found = element.getElementById(nameOnly)) ? [found] : [] ) :
|
|
|
- (element.nodeType !== 1 && element.nodeType !== 9) ? [] :
|
|
|
+ (element.nodeType !== 1 && element.nodeType !== 9 && element.nodeType !== 11) ? [] :
|
|
|
slice.call(
|
|
|
- isSimple && !maybeID ?
|
|
|
+ isSimple && !maybeID && element.getElementsByClassName ? // DocumentFragment doesn't have getElementsByClassName/TagName
|
|
|
maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class
|
|
|
element.getElementsByTagName(selector) : // Or a tag
|
|
|
element.querySelectorAll(selector) // Or it's not simple, and we need to query all
|
|
@@ -328,6 +345,13 @@ var Zepto = (function() {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ $.isNumeric = function(val) {
|
|
|
+ var num = Number(val), type = typeof val
|
|
|
+ return val != null && type != 'boolean' &&
|
|
|
+ (type != 'string' || val.length) &&
|
|
|
+ !isNaN(num) && isFinite(num) || false
|
|
|
+ }
|
|
|
+
|
|
|
$.inArray = function(elem, array, i){
|
|
|
return emptyArray.indexOf.call(array, elem, i)
|
|
|
}
|
|
@@ -341,6 +365,7 @@ var Zepto = (function() {
|
|
|
$.uuid = 0
|
|
|
$.support = { }
|
|
|
$.expr = { }
|
|
|
+ $.noop = function() {}
|
|
|
|
|
|
$.map = function(elements, callback){
|
|
|
var value, values = [], i, key
|
|
@@ -384,14 +409,25 @@ var Zepto = (function() {
|
|
|
// Define methods that will be available on all
|
|
|
// Zepto collections
|
|
|
$.fn = {
|
|
|
+ constructor: zepto.Z,
|
|
|
+ length: 0,
|
|
|
+
|
|
|
// Because a collection acts like an array
|
|
|
// copy over these useful array functions.
|
|
|
forEach: emptyArray.forEach,
|
|
|
reduce: emptyArray.reduce,
|
|
|
push: emptyArray.push,
|
|
|
sort: emptyArray.sort,
|
|
|
+ splice: emptyArray.splice,
|
|
|
indexOf: emptyArray.indexOf,
|
|
|
- concat: emptyArray.concat,
|
|
|
+ concat: function(){
|
|
|
+ var i, value, args = []
|
|
|
+ for (i = 0; i < arguments.length; i++) {
|
|
|
+ value = arguments[i]
|
|
|
+ args[i] = zepto.isZ(value) ? value.toArray() : value
|
|
|
+ }
|
|
|
+ return concat.apply(zepto.isZ(this) ? this.toArray() : this, args)
|
|
|
+ },
|
|
|
|
|
|
// `map` and `slice` in the jQuery API work differently
|
|
|
// from their array counterparts
|
|
@@ -403,10 +439,19 @@ var Zepto = (function() {
|
|
|
},
|
|
|
|
|
|
ready: function(callback){
|
|
|
- // need to check if document.body exists for IE as that browser reports
|
|
|
- // document ready when it hasn't yet created the body element
|
|
|
- if (readyRE.test(document.readyState) && document.body) callback($)
|
|
|
- else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
|
|
|
+ // don't use "interactive" on IE <= 10 (it can fired premature)
|
|
|
+ if (document.readyState === "complete" ||
|
|
|
+ (document.readyState !== "loading" && !document.documentElement.doScroll))
|
|
|
+ setTimeout(function(){ callback($) }, 0)
|
|
|
+ else {
|
|
|
+ var handler = function() {
|
|
|
+ document.removeEventListener("DOMContentLoaded", handler, false)
|
|
|
+ window.removeEventListener("load", handler, false)
|
|
|
+ callback($)
|
|
|
+ }
|
|
|
+ document.addEventListener("DOMContentLoaded", handler, false)
|
|
|
+ window.addEventListener("load", handler, false)
|
|
|
+ }
|
|
|
return this
|
|
|
},
|
|
|
get: function(idx){
|
|
@@ -438,7 +483,8 @@ var Zepto = (function() {
|
|
|
return $(uniq(this.concat($(selector,context))))
|
|
|
},
|
|
|
is: function(selector){
|
|
|
- return this.length > 0 && zepto.matches(this[0], selector)
|
|
|
+ return typeof selector == 'string' ? this.length > 0 && zepto.matches(this[0], selector) :
|
|
|
+ selector && this.selector == selector.selector
|
|
|
},
|
|
|
not: function(selector){
|
|
|
var nodes=[]
|
|
@@ -488,11 +534,13 @@ var Zepto = (function() {
|
|
|
return result
|
|
|
},
|
|
|
closest: function(selector, context){
|
|
|
- var node = this[0], collection = false
|
|
|
- if (typeof selector == 'object') collection = $(selector)
|
|
|
- while (node && !(collection ? collection.indexOf(node) >= 0 : zepto.matches(node, selector)))
|
|
|
- node = node !== context && !isDocument(node) && node.parentNode
|
|
|
- return $(node)
|
|
|
+ var nodes = [], collection = typeof selector == 'object' && $(selector)
|
|
|
+ this.each(function(_, node){
|
|
|
+ while (node && !(collection ? collection.indexOf(node) >= 0 : zepto.matches(node, selector)))
|
|
|
+ node = node !== context && !isDocument(node) && node.parentNode
|
|
|
+ if (node && nodes.indexOf(node) < 0) nodes.push(node)
|
|
|
+ })
|
|
|
+ return $(nodes)
|
|
|
},
|
|
|
parents: function(selector){
|
|
|
var ancestors = [], nodes = this
|
|
@@ -512,7 +560,7 @@ var Zepto = (function() {
|
|
|
return filtered(this.map(function(){ return children(this) }), selector)
|
|
|
},
|
|
|
contents: function() {
|
|
|
- return this.map(function() { return slice.call(this.childNodes) })
|
|
|
+ return this.map(function() { return this.contentDocument || slice.call(this.childNodes) })
|
|
|
},
|
|
|
siblings: function(selector){
|
|
|
return filtered(this.map(function(i, el){
|
|
@@ -601,14 +649,12 @@ var Zepto = (function() {
|
|
|
var newText = funcArg(this, text, idx, this.textContent)
|
|
|
this.textContent = newText == null ? '' : ''+newText
|
|
|
}) :
|
|
|
- (0 in this ? this[0].textContent : null)
|
|
|
+ (0 in this ? this.pluck('textContent').join("") : null)
|
|
|
},
|
|
|
attr: function(name, value){
|
|
|
var result
|
|
|
return (typeof name == 'string' && !(1 in arguments)) ?
|
|
|
- (!this.length || this[0].nodeType !== 1 ? undefined :
|
|
|
- (!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
|
|
|
- ) :
|
|
|
+ (0 in this && this[0].nodeType == 1 && (result = this[0].getAttribute(name)) != null ? result : undefined) :
|
|
|
this.each(function(idx){
|
|
|
if (this.nodeType !== 1) return
|
|
|
if (isObject(name)) for (key in name) setAttribute(this, key, name[key])
|
|
@@ -622,11 +668,16 @@ var Zepto = (function() {
|
|
|
},
|
|
|
prop: function(name, value){
|
|
|
name = propMap[name] || name
|
|
|
- return (1 in arguments) ?
|
|
|
+ return (typeof name == 'string' && !(1 in arguments)) ?
|
|
|
+ (this[0] && this[0][name]) :
|
|
|
this.each(function(idx){
|
|
|
- this[name] = funcArg(this, value, idx, this[name])
|
|
|
- }) :
|
|
|
- (this[0] && this[0][name])
|
|
|
+ if (isObject(name)) for (key in name) this[propMap[key] || key] = name[key]
|
|
|
+ else this[name] = funcArg(this, value, idx, this[name])
|
|
|
+ })
|
|
|
+ },
|
|
|
+ removeProp: function(name){
|
|
|
+ name = propMap[name] || name
|
|
|
+ return this.each(function(){ delete this[name] })
|
|
|
},
|
|
|
data: function(name, value){
|
|
|
var attrName = 'data-' + name.replace(capitalRE, '-$1').toLowerCase()
|
|
@@ -638,14 +689,16 @@ var Zepto = (function() {
|
|
|
return data !== null ? deserializeValue(data) : undefined
|
|
|
},
|
|
|
val: function(value){
|
|
|
- return 0 in arguments ?
|
|
|
- this.each(function(idx){
|
|
|
+ if (0 in arguments) {
|
|
|
+ if (value == null) value = ""
|
|
|
+ return this.each(function(idx){
|
|
|
this.value = funcArg(this, value, idx, this.value)
|
|
|
- }) :
|
|
|
- (this[0] && (this[0].multiple ?
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return this[0] && (this[0].multiple ?
|
|
|
$(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') :
|
|
|
this[0].value)
|
|
|
- )
|
|
|
+ }
|
|
|
},
|
|
|
offset: function(coordinates){
|
|
|
if (coordinates) return this.each(function(index){
|
|
@@ -661,6 +714,8 @@ var Zepto = (function() {
|
|
|
$this.css(props)
|
|
|
})
|
|
|
if (!this.length) return null
|
|
|
+ if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0]))
|
|
|
+ return {top: 0, left: 0}
|
|
|
var obj = this[0].getBoundingClientRect()
|
|
|
return {
|
|
|
left: obj.left + window.pageXOffset,
|
|
@@ -671,13 +726,14 @@ var Zepto = (function() {
|
|
|
},
|
|
|
css: function(property, value){
|
|
|
if (arguments.length < 2) {
|
|
|
- var computedStyle, element = this[0]
|
|
|
- if(!element) return
|
|
|
- computedStyle = getComputedStyle(element, '')
|
|
|
- if (typeof property == 'string')
|
|
|
- return element.style[camelize(property)] || computedStyle.getPropertyValue(property)
|
|
|
- else if (isArray(property)) {
|
|
|
+ var element = this[0]
|
|
|
+ if (typeof property == 'string') {
|
|
|
+ if (!element) return
|
|
|
+ return element.style[camelize(property)] || getComputedStyle(element, '').getPropertyValue(property)
|
|
|
+ } else if (isArray(property)) {
|
|
|
+ if (!element) return
|
|
|
var props = {}
|
|
|
+ var computedStyle = getComputedStyle(element, '')
|
|
|
$.each(property, function(_, prop){
|
|
|
props[prop] = (element.style[camelize(prop)] || computedStyle.getPropertyValue(prop))
|
|
|
})
|
|
@@ -829,8 +885,17 @@ var Zepto = (function() {
|
|
|
$.fn[operator] = function(){
|
|
|
// arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
|
|
|
var argType, nodes = $.map(arguments, function(arg) {
|
|
|
+ var arr = []
|
|
|
argType = type(arg)
|
|
|
- return argType == "object" || argType == "array" || arg == null ?
|
|
|
+ if (argType == "array") {
|
|
|
+ arg.forEach(function(el) {
|
|
|
+ if (el.nodeType !== undefined) return arr.push(el)
|
|
|
+ else if ($.zepto.isZ(el)) return arr = arr.concat(el.get())
|
|
|
+ arr = arr.concat(zepto.fragment(el))
|
|
|
+ })
|
|
|
+ return arr
|
|
|
+ }
|
|
|
+ return argType == "object" || arg == null ?
|
|
|
arg : zepto.fragment(arg)
|
|
|
}),
|
|
|
parent, copyByClone = this.length > 1
|
|
@@ -854,8 +919,10 @@ var Zepto = (function() {
|
|
|
parent.insertBefore(node, target)
|
|
|
if (parentInDocument) traverseNode(node, function(el){
|
|
|
if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
|
|
|
- (!el.type || el.type === 'text/javascript') && !el.src)
|
|
|
- window['eval'].call(window, el.innerHTML)
|
|
|
+ (!el.type || el.type === 'text/javascript') && !el.src){
|
|
|
+ var target = el.ownerDocument ? el.ownerDocument.defaultView : window
|
|
|
+ target['eval'].call(target, el.innerHTML)
|
|
|
+ }
|
|
|
})
|
|
|
})
|
|
|
})
|
|
@@ -871,7 +938,7 @@ var Zepto = (function() {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- zepto.Z.prototype = $.fn
|
|
|
+ zepto.Z.prototype = Z.prototype = $.fn
|
|
|
|
|
|
// Export internal API functions in the `$.zepto` namespace
|
|
|
zepto.uniq = uniq
|
|
@@ -881,9 +948,14 @@ var Zepto = (function() {
|
|
|
return $
|
|
|
})()
|
|
|
|
|
|
+
|
|
|
window.Zepto = Zepto
|
|
|
window.$ === undefined && (window.$ = Zepto)
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
;(function($){
|
|
|
var _zid = 1, undefined,
|
|
|
slice = Array.prototype.slice,
|
|
@@ -1001,7 +1073,7 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
|
|
|
var returnTrue = function(){return true},
|
|
|
returnFalse = function(){return false},
|
|
|
- ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$)/,
|
|
|
+ ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,
|
|
|
eventMethods = {
|
|
|
preventDefault: 'isDefaultPrevented',
|
|
|
stopImmediatePropagation: 'isImmediatePropagationStopped',
|
|
@@ -1021,6 +1093,10 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
event[predicate] = returnFalse
|
|
|
})
|
|
|
|
|
|
+ try {
|
|
|
+ event.timeStamp || (event.timeStamp = Date.now())
|
|
|
+ } catch (ignored) { }
|
|
|
+
|
|
|
if (source.defaultPrevented !== undefined ? source.defaultPrevented :
|
|
|
'returnValue' in source ? source.returnValue === false :
|
|
|
source.getPreventDefault && source.getPreventDefault())
|
|
@@ -1064,7 +1140,7 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
|
|
|
if (!isString(selector) && !isFunction(callback) && callback !== false)
|
|
|
callback = data, data = selector, selector = undefined
|
|
|
- if (isFunction(data) || data === false)
|
|
|
+ if (callback === undefined || data === false)
|
|
|
callback = data, data = undefined
|
|
|
|
|
|
if (callback === false) callback = returnFalse
|
|
@@ -1154,8 +1230,12 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
|
|
|
})(Zepto)
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
;(function($){
|
|
|
- var jsonpID = 0,
|
|
|
+ var jsonpID = +new Date(),
|
|
|
document = window.document,
|
|
|
key,
|
|
|
name,
|
|
@@ -1223,6 +1303,12 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
ajaxStop(settings)
|
|
|
}
|
|
|
|
|
|
+ function ajaxDataFilter(data, type, settings) {
|
|
|
+ if (settings.dataFilter == empty) return data
|
|
|
+ var context = settings.context
|
|
|
+ return settings.dataFilter.call(context, data, type)
|
|
|
+ }
|
|
|
+
|
|
|
// Empty function, used as default callback
|
|
|
function empty() {}
|
|
|
|
|
@@ -1231,7 +1317,7 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
|
|
|
var _callbackName = options.jsonpCallback,
|
|
|
callbackName = ($.isFunction(_callbackName) ?
|
|
|
- _callbackName() : _callbackName) || ('jsonp' + (++jsonpID)),
|
|
|
+ _callbackName() : _callbackName) || ('Zepto' + (jsonpID++)),
|
|
|
script = document.createElement('script'),
|
|
|
originalCallback = window[callbackName],
|
|
|
responseData,
|
|
@@ -1313,7 +1399,11 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
// Whether data should be serialized to string
|
|
|
processData: true,
|
|
|
// Whether the browser should be allowed to cache GET responses
|
|
|
- cache: true
|
|
|
+ cache: true,
|
|
|
+ //Used to handle the raw response data of XMLHttpRequest.
|
|
|
+ //This is a pre-filtering function to sanitize the response.
|
|
|
+ //The sanitized response should be returned
|
|
|
+ dataFilter: empty
|
|
|
}
|
|
|
|
|
|
function mimeToDataType(mime) {
|
|
@@ -1333,14 +1423,14 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
function serializeData(options) {
|
|
|
if (options.processData && options.data && $.type(options.data) != "string")
|
|
|
options.data = $.param(options.data, options.traditional)
|
|
|
- if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
|
|
|
+ if (options.data && (!options.type || options.type.toUpperCase() == 'GET' || 'jsonp' == options.dataType))
|
|
|
options.url = appendQuery(options.url, options.data), options.data = undefined
|
|
|
}
|
|
|
|
|
|
$.ajax = function(options){
|
|
|
var settings = $.extend({}, options || {}),
|
|
|
deferred = $.Deferred && $.Deferred(),
|
|
|
- urlAnchor
|
|
|
+ urlAnchor, hashIndex
|
|
|
for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]
|
|
|
|
|
|
ajaxStart(settings)
|
|
@@ -1348,11 +1438,13 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
if (!settings.crossDomain) {
|
|
|
urlAnchor = document.createElement('a')
|
|
|
urlAnchor.href = settings.url
|
|
|
+ // cleans up URL for .href (IE only), see https://github.com/madrobby/zepto/pull/1049
|
|
|
urlAnchor.href = urlAnchor.href
|
|
|
settings.crossDomain = (originAnchor.protocol + '//' + originAnchor.host) !== (urlAnchor.protocol + '//' + urlAnchor.host)
|
|
|
}
|
|
|
|
|
|
if (!settings.url) settings.url = window.location.toString()
|
|
|
+ if ((hashIndex = settings.url.indexOf('#')) > -1) settings.url = settings.url.slice(0, hashIndex)
|
|
|
serializeData(settings)
|
|
|
|
|
|
var dataType = settings.dataType, hasPlaceholder = /\?.+=\?/.test(settings.url)
|
|
@@ -1400,17 +1492,25 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
var result, error = false
|
|
|
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
|
|
|
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'))
|
|
|
- result = xhr.responseText
|
|
|
|
|
|
- try {
|
|
|
- // http://perfectionkills.com/global-eval-what-are-the-options/
|
|
|
- if (dataType == 'script') (1,eval)(result)
|
|
|
- else if (dataType == 'xml') result = xhr.responseXML
|
|
|
- else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
|
|
|
- } catch (e) { error = e }
|
|
|
+ if (xhr.responseType == 'arraybuffer' || xhr.responseType == 'blob')
|
|
|
+ result = xhr.response
|
|
|
+ else {
|
|
|
+ result = xhr.responseText
|
|
|
+
|
|
|
+ try {
|
|
|
+ // http://perfectionkills.com/global-eval-what-are-the-options/
|
|
|
+ // sanitize response accordingly if data filter callback provided
|
|
|
+ result = ajaxDataFilter(result, dataType, settings)
|
|
|
+ if (dataType == 'script') (1,eval)(result)
|
|
|
+ else if (dataType == 'xml') result = xhr.responseXML
|
|
|
+ else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
|
|
|
+ } catch (e) { error = e }
|
|
|
+
|
|
|
+ if (error) return ajaxError(error, 'parsererror', xhr, settings, deferred)
|
|
|
+ }
|
|
|
|
|
|
- if (error) ajaxError(error, 'parsererror', xhr, settings, deferred)
|
|
|
- else ajaxSuccess(result, xhr, settings, deferred)
|
|
|
+ ajaxSuccess(result, xhr, settings, deferred)
|
|
|
} else {
|
|
|
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred)
|
|
|
}
|
|
@@ -1423,11 +1523,11 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
return xhr
|
|
|
}
|
|
|
|
|
|
- if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name]
|
|
|
-
|
|
|
var async = 'async' in settings ? settings.async : true
|
|
|
xhr.open(settings.type, settings.url, async, settings.username, settings.password)
|
|
|
|
|
|
+ if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name]
|
|
|
+
|
|
|
for (name in headers) nativeSetHeader.apply(xhr, headers[name])
|
|
|
|
|
|
if (settings.timeout > 0) abortTimeout = setTimeout(function(){
|
|
@@ -1514,6 +1614,10 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
}
|
|
|
})(Zepto)
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
;(function($){
|
|
|
$.fn.serializeArray = function() {
|
|
|
var name, type, result = [],
|
|
@@ -1551,37 +1655,434 @@ window.$ === undefined && (window.$ = Zepto)
|
|
|
|
|
|
})(Zepto)
|
|
|
|
|
|
-;(function($){
|
|
|
- // __proto__ doesn't exist on IE<11, so redefine
|
|
|
- // the Z function to use object extension instead
|
|
|
- if (!('__proto__' in {})) {
|
|
|
- $.extend($.zepto, {
|
|
|
- Z: function(dom, selector){
|
|
|
- dom = dom || []
|
|
|
- $.extend(dom, $.fn)
|
|
|
- dom.selector = selector || ''
|
|
|
- dom.__Z = true
|
|
|
- return dom
|
|
|
- },
|
|
|
- // this is a kludge but works
|
|
|
- isZ: function(object){
|
|
|
- return $.type(object) === 'array' && '__Z' in object
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+;(function(){
|
|
|
// getComputedStyle shouldn't freak out when called
|
|
|
// without a valid element as argument
|
|
|
try {
|
|
|
getComputedStyle(undefined)
|
|
|
} catch(e) {
|
|
|
- var nativeGetComputedStyle = getComputedStyle;
|
|
|
- window.getComputedStyle = function(element){
|
|
|
+ var nativeGetComputedStyle = getComputedStyle
|
|
|
+ window.getComputedStyle = function(element, pseudoElement){
|
|
|
try {
|
|
|
- return nativeGetComputedStyle(element)
|
|
|
+ return nativeGetComputedStyle(element, pseudoElement)
|
|
|
} catch(e) {
|
|
|
return null
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+})()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+;(function($){
|
|
|
+ var touch = {},
|
|
|
+ touchTimeout, tapTimeout, swipeTimeout, longTapTimeout,
|
|
|
+ longTapDelay = 750,
|
|
|
+ gesture,
|
|
|
+ down, up, move,
|
|
|
+ eventMap,
|
|
|
+ initialized = false
|
|
|
+
|
|
|
+ function swipeDirection(x1, x2, y1, y2) {
|
|
|
+ return Math.abs(x1 - x2) >=
|
|
|
+ Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
|
|
|
+ }
|
|
|
+
|
|
|
+ function longTap() {
|
|
|
+ longTapTimeout = null
|
|
|
+ if (touch.last) {
|
|
|
+ touch.el.trigger('longTap')
|
|
|
+ touch = {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function cancelLongTap() {
|
|
|
+ if (longTapTimeout) clearTimeout(longTapTimeout)
|
|
|
+ longTapTimeout = null
|
|
|
+ }
|
|
|
+
|
|
|
+ function cancelAll() {
|
|
|
+ if (touchTimeout) clearTimeout(touchTimeout)
|
|
|
+ if (tapTimeout) clearTimeout(tapTimeout)
|
|
|
+ if (swipeTimeout) clearTimeout(swipeTimeout)
|
|
|
+ if (longTapTimeout) clearTimeout(longTapTimeout)
|
|
|
+ touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null
|
|
|
+ touch = {}
|
|
|
+ }
|
|
|
+
|
|
|
+ function isPrimaryTouch(event){
|
|
|
+ return (event.pointerType == 'touch' ||
|
|
|
+ event.pointerType == event.MSPOINTER_TYPE_TOUCH)
|
|
|
+ && event.isPrimary
|
|
|
+ }
|
|
|
+
|
|
|
+ function isPointerEventType(e, type){
|
|
|
+ return (e.type == 'pointer'+type ||
|
|
|
+ e.type.toLowerCase() == 'mspointer'+type)
|
|
|
+ }
|
|
|
+
|
|
|
+ // helper function for tests, so they check for different APIs
|
|
|
+ function unregisterTouchEvents(){
|
|
|
+ if (!initialized) return
|
|
|
+ $(document).off(eventMap.down, down)
|
|
|
+ .off(eventMap.up, up)
|
|
|
+ .off(eventMap.move, move)
|
|
|
+ .off(eventMap.cancel, cancelAll)
|
|
|
+ $(window).off('scroll', cancelAll)
|
|
|
+ cancelAll()
|
|
|
+ initialized = false
|
|
|
+ }
|
|
|
+
|
|
|
+ function setup(__eventMap){
|
|
|
+ var now, delta, deltaX = 0, deltaY = 0, firstTouch, _isPointerType
|
|
|
+
|
|
|
+ unregisterTouchEvents()
|
|
|
+
|
|
|
+ eventMap = (__eventMap && ('down' in __eventMap)) ? __eventMap :
|
|
|
+ ('ontouchstart' in document ?
|
|
|
+ { 'down': 'touchstart', 'up': 'touchend',
|
|
|
+ 'move': 'touchmove', 'cancel': 'touchcancel' } :
|
|
|
+ 'onpointerdown' in document ?
|
|
|
+ { 'down': 'pointerdown', 'up': 'pointerup',
|
|
|
+ 'move': 'pointermove', 'cancel': 'pointercancel' } :
|
|
|
+ 'onmspointerdown' in document ?
|
|
|
+ { 'down': 'MSPointerDown', 'up': 'MSPointerUp',
|
|
|
+ 'move': 'MSPointerMove', 'cancel': 'MSPointerCancel' } : false)
|
|
|
+
|
|
|
+ // No API availables for touch events
|
|
|
+ if (!eventMap) return
|
|
|
+
|
|
|
+ if ('MSGesture' in window) {
|
|
|
+ gesture = new MSGesture()
|
|
|
+ gesture.target = document.body
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .bind('MSGestureEnd', function(e){
|
|
|
+ var swipeDirectionFromVelocity =
|
|
|
+ e.velocityX > 1 ? 'Right' : e.velocityX < -1 ? 'Left' : e.velocityY > 1 ? 'Down' : e.velocityY < -1 ? 'Up' : null
|
|
|
+ if (swipeDirectionFromVelocity) {
|
|
|
+ touch.el.trigger('swipe')
|
|
|
+ touch.el.trigger('swipe'+ swipeDirectionFromVelocity)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ down = function(e){
|
|
|
+ if((_isPointerType = isPointerEventType(e, 'down')) &&
|
|
|
+ !isPrimaryTouch(e)) return
|
|
|
+ firstTouch = _isPointerType ? e : e.touches[0]
|
|
|
+ if (e.touches && e.touches.length === 1 && touch.x2) {
|
|
|
+ // Clear out touch movement data if we have it sticking around
|
|
|
+ // This can occur if touchcancel doesn't fire due to preventDefault, etc.
|
|
|
+ touch.x2 = undefined
|
|
|
+ touch.y2 = undefined
|
|
|
+ }
|
|
|
+ now = Date.now()
|
|
|
+ delta = now - (touch.last || now)
|
|
|
+ touch.el = $('tagName' in firstTouch.target ?
|
|
|
+ firstTouch.target : firstTouch.target.parentNode)
|
|
|
+ touchTimeout && clearTimeout(touchTimeout)
|
|
|
+ touch.x1 = firstTouch.pageX
|
|
|
+ touch.y1 = firstTouch.pageY
|
|
|
+ if (delta > 0 && delta <= 250) touch.isDoubleTap = true
|
|
|
+ touch.last = now
|
|
|
+ longTapTimeout = setTimeout(longTap, longTapDelay)
|
|
|
+ // adds the current touch contact for IE gesture recognition
|
|
|
+ if (gesture && _isPointerType) gesture.addPointer(e.pointerId)
|
|
|
+ }
|
|
|
+
|
|
|
+ move = function(e){
|
|
|
+ if((_isPointerType = isPointerEventType(e, 'move')) &&
|
|
|
+ !isPrimaryTouch(e)) return
|
|
|
+ firstTouch = _isPointerType ? e : e.touches[0]
|
|
|
+ cancelLongTap()
|
|
|
+ touch.x2 = firstTouch.pageX
|
|
|
+ touch.y2 = firstTouch.pageY
|
|
|
+
|
|
|
+ deltaX += Math.abs(touch.x1 - touch.x2)
|
|
|
+ deltaY += Math.abs(touch.y1 - touch.y2)
|
|
|
+ }
|
|
|
+
|
|
|
+ up = function(e){
|
|
|
+ if((_isPointerType = isPointerEventType(e, 'up')) &&
|
|
|
+ !isPrimaryTouch(e)) return
|
|
|
+ cancelLongTap()
|
|
|
+
|
|
|
+ // swipe
|
|
|
+ if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
|
|
|
+ (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
|
|
|
+
|
|
|
+ swipeTimeout = setTimeout(function() {
|
|
|
+ if (touch.el){
|
|
|
+ touch.el.trigger('swipe')
|
|
|
+ touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
|
|
|
+ }
|
|
|
+ touch = {}
|
|
|
+ }, 0)
|
|
|
+
|
|
|
+ // normal tap
|
|
|
+ else if ('last' in touch)
|
|
|
+ // don't fire tap when delta position changed by more than 30 pixels,
|
|
|
+ // for instance when moving to a point and back to origin
|
|
|
+ if (deltaX < 30 && deltaY < 30) {
|
|
|
+ // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
|
|
|
+ // ('tap' fires before 'scroll')
|
|
|
+ tapTimeout = setTimeout(function() {
|
|
|
+
|
|
|
+ // trigger universal 'tap' with the option to cancelTouch()
|
|
|
+ // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
|
|
|
+ var event = $.Event('tap')
|
|
|
+ event.cancelTouch = cancelAll
|
|
|
+ // [by paper] fix -> "TypeError: 'undefined' is not an object (evaluating 'touch.el.trigger'), when double tap
|
|
|
+ if (touch.el) touch.el.trigger(event)
|
|
|
+
|
|
|
+ // trigger double tap immediately
|
|
|
+ if (touch.isDoubleTap) {
|
|
|
+ if (touch.el) touch.el.trigger('doubleTap')
|
|
|
+ touch = {}
|
|
|
+ }
|
|
|
+
|
|
|
+ // trigger single tap after 250ms of inactivity
|
|
|
+ else {
|
|
|
+ touchTimeout = setTimeout(function(){
|
|
|
+ touchTimeout = null
|
|
|
+ if (touch.el) touch.el.trigger('singleTap')
|
|
|
+ touch = {}
|
|
|
+ }, 250)
|
|
|
+ }
|
|
|
+ }, 0)
|
|
|
+ } else {
|
|
|
+ touch = {}
|
|
|
+ }
|
|
|
+ deltaX = deltaY = 0
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).on(eventMap.up, up)
|
|
|
+ .on(eventMap.down, down)
|
|
|
+ .on(eventMap.move, move)
|
|
|
+
|
|
|
+ // when the browser window loses focus,
|
|
|
+ // for example when a modal dialog is shown,
|
|
|
+ // cancel all ongoing events
|
|
|
+ $(document).on(eventMap.cancel, cancelAll)
|
|
|
+
|
|
|
+ // scrolling the window indicates intention of the user
|
|
|
+ // to scroll, not tap or swipe, so cancel all ongoing events
|
|
|
+ $(window).on('scroll', cancelAll)
|
|
|
+
|
|
|
+ initialized = true
|
|
|
+ }
|
|
|
+
|
|
|
+ ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown',
|
|
|
+ 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
|
|
|
+ $.fn[eventName] = function(callback){ return this.on(eventName, callback) }
|
|
|
+ })
|
|
|
+
|
|
|
+ $.touch = { setup: setup }
|
|
|
+
|
|
|
+ $(document).ready(setup)
|
|
|
+})(Zepto)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+;(function($, undefined){
|
|
|
+ var prefix = '', eventPrefix,
|
|
|
+ vendors = { Webkit: 'webkit', Moz: '', O: 'o' },
|
|
|
+ testEl = document.createElement('div'),
|
|
|
+ supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,
|
|
|
+ transform,
|
|
|
+ transitionProperty, transitionDuration, transitionTiming, transitionDelay,
|
|
|
+ animationName, animationDuration, animationTiming, animationDelay,
|
|
|
+ cssReset = {}
|
|
|
+
|
|
|
+ function dasherize(str) { return str.replace(/([A-Z])/g, '-$1').toLowerCase() }
|
|
|
+ function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : name.toLowerCase() }
|
|
|
+
|
|
|
+ if (testEl.style.transform === undefined) $.each(vendors, function(vendor, event){
|
|
|
+ if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
|
|
|
+ prefix = '-' + vendor.toLowerCase() + '-'
|
|
|
+ eventPrefix = event
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ transform = prefix + 'transform'
|
|
|
+ cssReset[transitionProperty = prefix + 'transition-property'] =
|
|
|
+ cssReset[transitionDuration = prefix + 'transition-duration'] =
|
|
|
+ cssReset[transitionDelay = prefix + 'transition-delay'] =
|
|
|
+ cssReset[transitionTiming = prefix + 'transition-timing-function'] =
|
|
|
+ cssReset[animationName = prefix + 'animation-name'] =
|
|
|
+ cssReset[animationDuration = prefix + 'animation-duration'] =
|
|
|
+ cssReset[animationDelay = prefix + 'animation-delay'] =
|
|
|
+ cssReset[animationTiming = prefix + 'animation-timing-function'] = ''
|
|
|
+
|
|
|
+ $.fx = {
|
|
|
+ off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
|
|
|
+ speeds: { _default: 400, fast: 200, slow: 600 },
|
|
|
+ cssPrefix: prefix,
|
|
|
+ transitionEnd: normalizeEvent('TransitionEnd'),
|
|
|
+ animationEnd: normalizeEvent('AnimationEnd')
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.animate = function(properties, duration, ease, callback, delay){
|
|
|
+ if ($.isFunction(duration))
|
|
|
+ callback = duration, ease = undefined, duration = undefined
|
|
|
+ if ($.isFunction(ease))
|
|
|
+ callback = ease, ease = undefined
|
|
|
+ if ($.isPlainObject(duration))
|
|
|
+ ease = duration.easing, callback = duration.complete, delay = duration.delay, duration = duration.duration
|
|
|
+ if (duration) duration = (typeof duration == 'number' ? duration :
|
|
|
+ ($.fx.speeds[duration] || $.fx.speeds._default)) / 1000
|
|
|
+ if (delay) delay = parseFloat(delay) / 1000
|
|
|
+ return this.anim(properties, duration, ease, callback, delay)
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.anim = function(properties, duration, ease, callback, delay){
|
|
|
+ var key, cssValues = {}, cssProperties, transforms = '',
|
|
|
+ that = this, wrappedCallback, endEvent = $.fx.transitionEnd,
|
|
|
+ fired = false
|
|
|
+
|
|
|
+ if (duration === undefined) duration = $.fx.speeds._default / 1000
|
|
|
+ if (delay === undefined) delay = 0
|
|
|
+ if ($.fx.off) duration = 0
|
|
|
+
|
|
|
+ if (typeof properties == 'string') {
|
|
|
+ // keyframe animation
|
|
|
+ cssValues[animationName] = properties
|
|
|
+ cssValues[animationDuration] = duration + 's'
|
|
|
+ cssValues[animationDelay] = delay + 's'
|
|
|
+ cssValues[animationTiming] = (ease || 'linear')
|
|
|
+ endEvent = $.fx.animationEnd
|
|
|
+ } else {
|
|
|
+ cssProperties = []
|
|
|
+ // CSS transitions
|
|
|
+ for (key in properties)
|
|
|
+ if (supportedTransforms.test(key)) transforms += key + '(' + properties[key] + ') '
|
|
|
+ else cssValues[key] = properties[key], cssProperties.push(dasherize(key))
|
|
|
+
|
|
|
+ if (transforms) cssValues[transform] = transforms, cssProperties.push(transform)
|
|
|
+ if (duration > 0 && typeof properties === 'object') {
|
|
|
+ cssValues[transitionProperty] = cssProperties.join(', ')
|
|
|
+ cssValues[transitionDuration] = duration + 's'
|
|
|
+ cssValues[transitionDelay] = delay + 's'
|
|
|
+ cssValues[transitionTiming] = (ease || 'linear')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ wrappedCallback = function(event){
|
|
|
+ if (typeof event !== 'undefined') {
|
|
|
+ if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
|
|
|
+ $(event.target).unbind(endEvent, wrappedCallback)
|
|
|
+ } else
|
|
|
+ $(this).unbind(endEvent, wrappedCallback) // triggered by setTimeout
|
|
|
+
|
|
|
+ fired = true
|
|
|
+ $(this).css(cssReset)
|
|
|
+ callback && callback.call(this)
|
|
|
+ }
|
|
|
+ if (duration > 0){
|
|
|
+ this.bind(endEvent, wrappedCallback)
|
|
|
+ // transitionEnd is not always firing on older Android phones
|
|
|
+ // so make sure it gets fired
|
|
|
+ setTimeout(function(){
|
|
|
+ if (fired) return
|
|
|
+ wrappedCallback.call(that)
|
|
|
+ }, ((duration + delay) * 1000) + 25)
|
|
|
+ }
|
|
|
+
|
|
|
+ // trigger page reflow so new elements can animate
|
|
|
+ this.size() && this.get(0).clientLeft
|
|
|
+
|
|
|
+ this.css(cssValues)
|
|
|
+
|
|
|
+ if (duration <= 0) setTimeout(function() {
|
|
|
+ that.each(function(){ wrappedCallback.call(this) })
|
|
|
+ }, 0)
|
|
|
+
|
|
|
+ return this
|
|
|
+ }
|
|
|
+
|
|
|
+ testEl = null
|
|
|
+})(Zepto)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+;(function($, undefined){
|
|
|
+ var document = window.document,
|
|
|
+ origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle
|
|
|
+
|
|
|
+ function anim(el, speed, opacity, scale, callback) {
|
|
|
+ if (typeof speed == 'function' && !callback) callback = speed, speed = undefined
|
|
|
+ var props = { opacity: opacity }
|
|
|
+ if (scale) {
|
|
|
+ props.scale = scale
|
|
|
+ el.css($.fx.cssPrefix + 'transform-origin', '0 0')
|
|
|
+ }
|
|
|
+ return el.animate(props, speed, null, callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ function hide(el, speed, scale, callback) {
|
|
|
+ return anim(el, speed, 0, scale, function(){
|
|
|
+ origHide.call($(this))
|
|
|
+ callback && callback.call(this)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.show = function(speed, callback) {
|
|
|
+ origShow.call(this)
|
|
|
+ if (speed === undefined) speed = 0
|
|
|
+ else this.css('opacity', 0)
|
|
|
+ return anim(this, speed, 1, '1,1', callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.hide = function(speed, callback) {
|
|
|
+ if (speed === undefined) return origHide.call(this)
|
|
|
+ else return hide(this, speed, '0,0', callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.toggle = function(speed, callback) {
|
|
|
+ if (speed === undefined || typeof speed == 'boolean')
|
|
|
+ return origToggle.call(this, speed)
|
|
|
+ else return this.each(function(){
|
|
|
+ var el = $(this)
|
|
|
+ el[el.css('display') == 'none' ? 'show' : 'hide'](speed, callback)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.fadeTo = function(speed, opacity, callback) {
|
|
|
+ return anim(this, speed, opacity, null, callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.fadeIn = function(speed, callback) {
|
|
|
+ var target = this.css('opacity')
|
|
|
+ if (target > 0) this.css('opacity', 0)
|
|
|
+ else target = 1
|
|
|
+ return origShow.call(this).fadeTo(speed, target, callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.fadeOut = function(speed, callback) {
|
|
|
+ return hide(this, speed, null, callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ $.fn.fadeToggle = function(speed, callback) {
|
|
|
+ return this.each(function(){
|
|
|
+ var el = $(this)
|
|
|
+ el[
|
|
|
+ (el.css('opacity') == 0 || el.css('display') == 'none') ? 'fadeIn' : 'fadeOut'
|
|
|
+ ](speed, callback)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
})(Zepto)
|
|
|
+ return Zepto
|
|
|
+}))
|