Created
August 12, 2013 18:21
-
-
Save dvliman/6213522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var n = this, | |
t = n._, | |
r = {}, e = Array.prototype, | |
u = Object.prototype, | |
i = Function.prototype, | |
a = e.push, | |
o = e.slice, | |
c = e.concat, | |
l = u.toString, | |
f = u.hasOwnProperty, | |
s = e.forEach, | |
p = e.map, | |
h = e.reduce, | |
v = e.reduceRight, | |
d = e.filter, | |
g = e.every, | |
m = e.some, | |
y = e.indexOf, | |
b = e.lastIndexOf, | |
x = Array.isArray, | |
_ = Object.keys, | |
j = i.bind, | |
w = function (n) { | |
return n instanceof w ? n : this instanceof w ? (this._wrapped = n, void 0) : new w(n) | |
}; | |
"undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = w), exports._ = w) : n._ = w, w.VERSION = "1.4.4"; | |
var A = w.each = w.forEach = function (n, t, e) { | |
if (null != n) | |
if (s && n.forEach === s) n.forEach(t, e); | |
else if (n.length === +n.length) { | |
for (var u = 0, i = n.length; i > u; u++) | |
if (t.call(e, n[u], u, n) === r) return | |
} else | |
for (var a in n) | |
if (w.has(n, a) && t.call(e, n[a], a, n) === r) return | |
}; | |
w.map = w.collect = function (n, t, r) { | |
var e = []; | |
return null == n ? e : p && n.map === p ? n.map(t, r) : (A(n, function (n, u, i) { | |
e[e.length] = t.call(r, n, u, i) | |
}), e) | |
}; | |
var O = "Reduce of empty array with no initial value"; | |
w.reduce = w.foldl = w.inject = function (n, t, r, e) { | |
var u = arguments.length > 2; | |
if (null == n && (n = []), h && n.reduce === h) return e && (t = w.bind(t, e)), u ? n.reduce(t, r) : n.reduce(t); | |
if (A(n, function (n, i, a) { | |
u ? r = t.call(e, r, n, i, a) : (r = n, u = !0) | |
}), !u) throw new TypeError(O); | |
return r | |
}, w.reduceRight = w.foldr = function (n, t, r, e) { | |
var u = arguments.length > 2; | |
if (null == n && (n = []), v && n.reduceRight === v) return e && (t = w.bind(t, e)), u ? n.reduceRight(t, r) : n.reduceRight(t); | |
var i = n.length; | |
if (i !== +i) { | |
var a = w.keys(n); | |
i = a.length | |
} | |
if (A(n, function (o, c, l) { | |
c = a ? a[--i] : --i, u ? r = t.call(e, r, n[c], c, l) : (r = n[c], u = !0) | |
}), !u) throw new TypeError(O); | |
return r | |
}, w.find = w.detect = function (n, t, r) { | |
var e; | |
return E(n, function (n, u, i) { | |
return t.call(r, n, u, i) ? (e = n, !0) : void 0 | |
}), e | |
}, w.filter = w.select = function (n, t, r) { | |
var e = []; | |
return null == n ? e : d && n.filter === d ? n.filter(t, r) : (A(n, function (n, u, i) { | |
t.call(r, n, u, i) && (e[e.length] = n) | |
}), e) | |
}, w.reject = function (n, t, r) { | |
return w.filter(n, function (n, e, u) { | |
return !t.call(r, n, e, u) | |
}, r) | |
}, w.every = w.all = function (n, t, e) { | |
t || (t = w.identity); | |
var u = !0; | |
return null == n ? u : g && n.every === g ? n.every(t, e) : (A(n, function (n, i, a) { | |
return (u = u && t.call(e, n, i, a)) ? void 0 : r | |
}), !! u) | |
}; | |
var E = w.some = w.any = function (n, t, e) { | |
t || (t = w.identity); | |
var u = !1; | |
return null == n ? u : m && n.some === m ? n.some(t, e) : (A(n, function (n, i, a) { | |
return u || (u = t.call(e, n, i, a)) ? r : void 0 | |
}), !! u) | |
}; | |
w.contains = w.include = function (n, t) { | |
return null == n ? !1 : y && n.indexOf === y ? n.indexOf(t) != -1 : E(n, function (n) { | |
return n === t | |
}) | |
}, w.invoke = function (n, t) { | |
var r = o.call(arguments, 2), | |
e = w.isFunction(t); | |
return w.map(n, function (n) { | |
return (e ? t : n[t]).apply(n, r) | |
}) | |
}, w.pluck = function (n, t) { | |
return w.map(n, function (n) { | |
return n[t] | |
}) | |
}, w.where = function (n, t, r) { | |
return w.isEmpty(t) ? r ? null : [] : w[r ? "find" : "filter"](n, function (n) { | |
for (var r in t) | |
if (t[r] !== n[r]) return !1; | |
return !0 | |
}) | |
}, w.findWhere = function (n, t) { | |
return w.where(n, t, !0) | |
}, w.max = function (n, t, r) { | |
if (!t && w.isArray(n) && n[0] === +n[0] && 65535 > n.length) return Math.max.apply(Math, n); | |
if (!t && w.isEmpty(n)) return -1 / 0; | |
var e = { | |
computed: -1 / 0, | |
value: -1 / 0 | |
}; | |
return A(n, function (n, u, i) { | |
var a = t ? t.call(r, n, u, i) : n; | |
a >= e.computed && (e = { | |
value: n, | |
computed: a | |
}) | |
}), e.value | |
}, w.min = function (n, t, r) { | |
if (!t && w.isArray(n) && n[0] === +n[0] && 65535 > n.length) return Math.min.apply(Math, n); | |
if (!t && w.isEmpty(n)) return 1 / 0; | |
var e = { | |
computed: 1 / 0, | |
value: 1 / 0 | |
}; | |
return A(n, function (n, u, i) { | |
var a = t ? t.call(r, n, u, i) : n; | |
e.computed > a && (e = { | |
value: n, | |
computed: a | |
}) | |
}), e.value | |
}, w.shuffle = function (n) { | |
var t, r = 0, | |
e = []; | |
return A(n, function (n) { | |
t = w.random(r++), e[r - 1] = e[t], e[t] = n | |
}), e | |
}; | |
var k = function (n) { | |
return w.isFunction(n) ? n : function (t) { | |
return t[n] | |
} | |
}; | |
w.sortBy = function (n, t, r) { | |
var e = k(t); | |
return w.pluck(w.map(n, function (n, t, u) { | |
return { | |
value: n, | |
index: t, | |
criteria: e.call(r, n, t, u) | |
} | |
}).sort(function (n, t) { | |
var r = n.criteria, | |
e = t.criteria; | |
if (r !== e) { | |
if (r > e || r === void 0) return 1; | |
if (e > r || e === void 0) return -1 | |
} | |
return n.index < t.index ? -1 : 1 | |
}), "value") | |
}; | |
var F = function (n, t, r, e) { | |
var u = {}, i = k(t || w.identity); | |
return A(n, function (t, a) { | |
var o = i.call(r, t, a, n); | |
e(u, o, t) | |
}), u | |
}; | |
w.groupBy = function (n, t, r) { | |
return F(n, t, r, function (n, t, r) { | |
(w.has(n, t) ? n[t] : n[t] = []).push(r) | |
}) | |
}, w.countBy = function (n, t, r) { | |
return F(n, t, r, function (n, t) { | |
w.has(n, t) || (n[t] = 0), n[t]++ | |
}) | |
}, w.sortedIndex = function (n, t, r, e) { | |
r = null == r ? w.identity : k(r); | |
for (var u = r.call(e, t), i = 0, a = n.length; a > i;) { | |
var o = i + a >>> 1; | |
u > r.call(e, n[o]) ? i = o + 1 : a = o | |
} | |
return i | |
}, w.toArray = function (n) { | |
return n ? w.isArray(n) ? o.call(n) : n.length === +n.length ? w.map(n, w.identity) : w.values(n) : [] | |
}, w.size = function (n) { | |
return null == n ? 0 : n.length === +n.length ? n.length : w.keys(n).length | |
}, w.first = w.head = w.take = function (n, t, r) { | |
return null == n ? void 0 : null == t || r ? n[0] : o.call(n, 0, t) | |
}, w.initial = function (n, t, r) { | |
return o.call(n, 0, n.length - (null == t || r ? 1 : t)) | |
}, w.last = function (n, t, r) { | |
return null == n ? void 0 : null == t || r ? n[n.length - 1] : o.call(n, Math.max(n.length - t, 0)) | |
}, w.rest = w.tail = w.drop = function (n, t, r) { | |
return o.call(n, null == t || r ? 1 : t) | |
}, w.compact = function (n) { | |
return w.filter(n, w.identity) | |
}; | |
var R = function (n, t, r) { | |
return A(n, function (n) { | |
w.isArray(n) ? t ? a.apply(r, n) : R(n, t, r) : r.push(n) | |
}), r | |
}; | |
w.flatten = function (n, t) { | |
return R(n, t, []) | |
}, w.without = function (n) { | |
return w.difference(n, o.call(arguments, 1)) | |
}, w.uniq = w.unique = function (n, t, r, e) { | |
w.isFunction(t) && (e = r, r = t, t = !1); | |
var u = r ? w.map(n, r, e) : n, | |
i = [], | |
a = []; | |
return A(u, function (r, e) { | |
(t ? e && a[a.length - 1] === r : w.contains(a, r)) || (a.push(r), i.push(n[e])) | |
}), i | |
}, w.union = function () { | |
return w.uniq(c.apply(e, arguments)) | |
}, w.intersection = function (n) { | |
var t = o.call(arguments, 1); | |
return w.filter(w.uniq(n), function (n) { | |
return w.every(t, function (t) { | |
return w.indexOf(t, n) >= 0 | |
}) | |
}) | |
}, w.difference = function (n) { | |
var t = c.apply(e, o.call(arguments, 1)); | |
return w.filter(n, function (n) { | |
return !w.contains(t, n) | |
}) | |
}, w.zip = function () { | |
for (var n = o.call(arguments), t = w.max(w.pluck(n, "length")), r = Array(t), e = 0; t > e; e++) r[e] = w.pluck(n, "" + e); | |
return r | |
}, w.object = function (n, t) { | |
if (null == n) return {}; | |
for (var r = {}, e = 0, u = n.length; u > e; e++) t ? r[n[e]] = t[e] : r[n[e][0]] = n[e][1]; | |
return r | |
}, w.indexOf = function (n, t, r) { | |
if (null == n) return -1; | |
var e = 0, | |
u = n.length; | |
if (r) { | |
if ("number" != typeof r) return e = w.sortedIndex(n, t), n[e] === t ? e : -1; | |
e = 0 > r ? Math.max(0, u + r) : r | |
} | |
if (y && n.indexOf === y) return n.indexOf(t, r); | |
for (; u > e; e++) | |
if (n[e] === t) return e; | |
return -1 | |
}, w.lastIndexOf = function (n, t, r) { | |
if (null == n) return -1; | |
var e = null != r; | |
if (b && n.lastIndexOf === b) return e ? n.lastIndexOf(t, r) : n.lastIndexOf(t); | |
for (var u = e ? r : n.length; u--;) | |
if (n[u] === t) return u; | |
return -1 | |
}, w.range = function (n, t, r) { | |
1 >= arguments.length && (t = n || 0, n = 0), r = arguments[2] || 1; | |
for (var e = Math.max(Math.ceil((t - n) / r), 0), u = 0, i = Array(e); e > u;) i[u++] = n, n += r; | |
return i | |
}, w.bind = function (n, t) { | |
if (n.bind === j && j) return j.apply(n, o.call(arguments, 1)); | |
var r = o.call(arguments, 2); | |
return function () { | |
return n.apply(t, r.concat(o.call(arguments))) | |
} | |
}, w.partial = function (n) { | |
var t = o.call(arguments, 1); | |
return function () { | |
return n.apply(this, t.concat(o.call(arguments))) | |
} | |
}, w.bindAll = function (n) { | |
var t = o.call(arguments, 1); | |
return 0 === t.length && (t = w.functions(n)), A(t, function (t) { | |
n[t] = w.bind(n[t], n) | |
}), n | |
}, w.memoize = function (n, t) { | |
var r = {}; | |
return t || (t = w.identity), | |
function () { | |
var e = t.apply(this, arguments); | |
return w.has(r, e) ? r[e] : r[e] = n.apply(this, arguments) | |
} | |
}, w.delay = function (n, t) { | |
var r = o.call(arguments, 2); | |
return setTimeout(function () { | |
return n.apply(null, r) | |
}, t) | |
}, w.defer = function (n) { | |
return w.delay.apply(w, [n, 1].concat(o.call(arguments, 1))) | |
}, w.throttle = function (n, t) { | |
var r, e, u, i, a = 0, | |
o = function () { | |
a = new Date, u = null, i = n.apply(r, e) | |
}; | |
return function () { | |
var c = new Date, | |
l = t - (c - a); | |
return r = this, e = arguments, 0 >= l ? (clearTimeout(u), u = null, a = c, i = n.apply(r, e)) : u || (u = setTimeout(o, l)), i | |
} | |
}, w.debounce = function (n, t, r) { | |
var e, u; | |
return function () { | |
var i = this, | |
a = arguments, | |
o = function () { | |
e = null, r || (u = n.apply(i, a)) | |
}, c = r && !e; | |
return clearTimeout(e), e = setTimeout(o, t), c && (u = n.apply(i, a)), u | |
} | |
}, w.once = function (n) { | |
var t, r = !1; | |
return function () { | |
return r ? t : (r = !0, t = n.apply(this, arguments), n = null, t) | |
} | |
}, w.wrap = function (n, t) { | |
return function () { | |
var r = [n]; | |
return a.apply(r, arguments), t.apply(this, r) | |
} | |
}, w.compose = function () { | |
var n = arguments; | |
return function () { | |
for (var t = arguments, r = n.length - 1; r >= 0; r--) t = [n[r].apply(this, t)]; | |
return t[0] | |
} | |
}, w.after = function (n, t) { | |
return 0 >= n ? t() : function () { | |
return 1 > --n ? t.apply(this, arguments) : void 0 | |
} | |
}, w.keys = _ || function (n) { | |
if (n !== Object(n)) throw new TypeError("Invalid object"); | |
var t = []; | |
for (var r in n) w.has(n, r) && (t[t.length] = r); | |
return t | |
}, w.values = function (n) { | |
var t = []; | |
for (var r in n) w.has(n, r) && t.push(n[r]); | |
return t | |
}, w.pairs = function (n) { | |
var t = []; | |
for (var r in n) w.has(n, r) && t.push([r, n[r]]); | |
return t | |
}, w.invert = function (n) { | |
var t = {}; | |
for (var r in n) w.has(n, r) && (t[n[r]] = r); | |
return t | |
}, w.functions = w.methods = function (n) { | |
var t = []; | |
for (var r in n) w.isFunction(n[r]) && t.push(r); | |
return t.sort() | |
}, w.extend = function (n) { | |
return A(o.call(arguments, 1), function (t) { | |
if (t) | |
for (var r in t) n[r] = t[r] | |
}), n | |
}, w.pick = function (n) { | |
var t = {}, r = c.apply(e, o.call(arguments, 1)); | |
return A(r, function (r) { | |
r in n && (t[r] = n[r]) | |
}), t | |
}, w.omit = function (n) { | |
var t = {}, r = c.apply(e, o.call(arguments, 1)); | |
for (var u in n) w.contains(r, u) || (t[u] = n[u]); | |
return t | |
}, w.defaults = function (n) { | |
return A(o.call(arguments, 1), function (t) { | |
if (t) | |
for (var r in t) null == n[r] && (n[r] = t[r]) | |
}), n | |
}, w.clone = function (n) { | |
return w.isObject(n) ? w.isArray(n) ? n.slice() : w.extend({}, n) : n | |
}, w.tap = function (n, t) { | |
return t(n), n | |
}; | |
var I = function (n, t, r, e) { | |
if (n === t) return 0 !== n || 1 / n == 1 / t; | |
if (null == n || null == t) return n === t; | |
n instanceof w && (n = n._wrapped), t instanceof w && (t = t._wrapped); | |
var u = l.call(n); | |
if (u != l.call(t)) return !1; | |
switch (u) { | |
case "[object String]": | |
return n == t + ""; | |
case "[object Number]": | |
return n != +n ? t != +t : 0 == n ? 1 / n == 1 / t : n == +t; | |
case "[object Date]": | |
case "[object Boolean]": | |
return +n == +t; | |
case "[object RegExp]": | |
return n.source == t.source && n.global == t.global && n.multiline == t.multiline && n.ignoreCase == t.ignoreCase | |
} | |
if ("object" != typeof n || "object" != typeof t) return !1; | |
for (var i = r.length; i--;) | |
if (r[i] == n) return e[i] == t; | |
r.push(n), e.push(t); | |
var a = 0, | |
o = !0; | |
if ("[object Array]" == u) { | |
if (a = n.length, o = a == t.length) | |
for (; a-- && (o = I(n[a], t[a], r, e));); | |
} else { | |
var c = n.constructor, | |
f = t.constructor; | |
if (c !== f && !(w.isFunction(c) && c instanceof c && w.isFunction(f) && f instanceof f)) return !1; | |
for (var s in n) | |
if (w.has(n, s) && (a++, !(o = w.has(t, s) && I(n[s], t[s], r, e)))) break; | |
if (o) { | |
for (s in t) | |
if (w.has(t, s) && !a--) break; | |
o = !a | |
} | |
} | |
return r.pop(), e.pop(), o | |
}; | |
w.isEqual = function (n, t) { | |
return I(n, t, [], []) | |
}, w.isEmpty = function (n) { | |
if (null == n) return !0; | |
if (w.isArray(n) || w.isString(n)) return 0 === n.length; | |
for (var t in n) | |
if (w.has(n, t)) return !1; | |
return !0 | |
}, w.isElement = function (n) { | |
return !(!n || 1 !== n.nodeType) | |
}, w.isArray = x || function (n) { | |
return "[object Array]" == l.call(n) | |
}, w.isObject = function (n) { | |
return n === Object(n) | |
}, A(["Arguments", "Function", "String", "Number", "Date", "RegExp"], function (n) { | |
w["is" + n] = function (t) { | |
return l.call(t) == "[object " + n + "]" | |
} | |
}), w.isArguments(arguments) || (w.isArguments = function (n) { | |
return !(!n || !w.has(n, "callee")) | |
}), "function" != typeof / . / && (w.isFunction = function (n) { | |
return "function" == typeof n | |
}), w.isFinite = function (n) { | |
return isFinite(n) && !isNaN(parseFloat(n)) | |
}, w.isNaN = function (n) { | |
return w.isNumber(n) && n != +n | |
}, w.isBoolean = function (n) { | |
return n === !0 || n === !1 || "[object Boolean]" == l.call(n) | |
}, w.isNull = function (n) { | |
return null === n | |
}, w.isUndefined = function (n) { | |
return n === void 0 | |
}, w.has = function (n, t) { | |
return f.call(n, t) | |
}, w.noConflict = function () { | |
return n._ = t, this | |
}, w.identity = function (n) { | |
return n | |
}, w.times = function (n, t, r) { | |
for (var e = Array(n), u = 0; n > u; u++) e[u] = t.call(r, u); | |
return e | |
}, w.random = function (n, t) { | |
return null == t && (t = n, n = 0), n + Math.floor(Math.random() * (t - n + 1)) | |
}; | |
var M = { | |
escape: { | |
"&": "&", | |
"<": "<", | |
">": ">", | |
'"': """, | |
"'": "'", | |
"/": "/" | |
} | |
}; | |
M.unescape = w.invert(M.escape); | |
var S = { | |
escape: RegExp("[" + w.keys(M.escape).join("") + "]", "g"), | |
unescape: RegExp("(" + w.keys(M.unescape).join("|") + ")", "g") | |
}; | |
w.each(["escape", "unescape"], function (n) { | |
w[n] = function (t) { | |
return null == t ? "" : ("" + t).replace(S[n], function (t) { | |
return M[n][t] | |
}) | |
} | |
}), w.result = function (n, t) { | |
if (null == n) return null; | |
var r = n[t]; | |
return w.isFunction(r) ? r.call(n) : r | |
}, w.mixin = function (n) { | |
A(w.functions(n), function (t) { | |
var r = w[t] = n[t]; | |
w.prototype[t] = function () { | |
var n = [this._wrapped]; | |
return a.apply(n, arguments), D.call(this, r.apply(w, n)) | |
} | |
}) | |
}; | |
var N = 0; | |
w.uniqueId = function (n) { | |
var t = ++N + ""; | |
return n ? n + t : t | |
}, w.templateSettings = { | |
evaluate: /<%([\s\S]+?)%>/g, | |
interpolate: /<%=([\s\S]+?)%>/g, | |
escape: /<%-([\s\S]+?)%>/g | |
}; | |
var T = /(.)^/, | |
q = { | |
"'": "'", | |
"\\": "\\", | |
"\r": "r", | |
"\n": "n", | |
" ": "t", | |
"\u2028": "u2028", | |
"\u2029": "u2029" | |
}, B = /\\|'|\r|\n|\t|\u2028|\u2029/g; | |
w.template = function (n, t, r) { | |
var e; | |
r = w.defaults({}, r, w.templateSettings); | |
var u = RegExp([(r.escape || T).source, (r.interpolate || T).source, (r.evaluate || T).source].join("|") + "|$", "g"), | |
i = 0, | |
a = "__p+='"; | |
n.replace(u, function (t, r, e, u, o) { | |
return a += n.slice(i, o).replace(B, function (n) { | |
return "\\" + q[n] | |
}), r && (a += "'+\n((__t=(" + r + "))==null?'':_.escape(__t))+\n'"), e && (a += "'+\n((__t=(" + e + "))==null?'':__t)+\n'"), u && (a += "';\n" + u + "\n__p+='"), i = o + t.length, t | |
}), a += "';\n", r.variable || (a = "with(obj||{}){\n" + a + "}\n"), a = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + a + "return __p;\n"; | |
try { | |
e = Function(r.variable || "obj", "_", a) | |
} catch (o) { | |
throw o.source = a, o | |
} | |
if (t) return e(t, w); | |
var c = function (n) { | |
return e.call(this, n, w) | |
}; | |
return c.source = "function(" + (r.variable || "obj") + "){\n" + a + "}", c | |
}, w.chain = function (n) { | |
return w(n).chain() | |
}; | |
var D = function (n) { | |
return this._chain ? w(n).chain() : n | |
}; | |
w.mixin(w), A(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function (n) { | |
var t = e[n]; | |
w.prototype[n] = function () { | |
var r = this._wrapped; | |
return t.apply(r, arguments), "shift" != n && "splice" != n || 0 !== r.length || delete r[0], D.call(this, r) | |
} | |
}), A(["concat", "join", "slice"], function (n) { | |
var t = e[n]; | |
w.prototype[n] = function () { | |
return D.call(this, t.apply(this._wrapped, arguments)) | |
} | |
}), w.extend(w.prototype, { | |
chain: function () { | |
return this._chain = !0, this | |
}, | |
value: function () { | |
return this._wrapped | |
} | |
}) | |
}).call(this); | |
(function (window, undefined) { | |
var | |
rootjQuery, readyList, core_strundefined = typeof undefined, | |
location = window.location, | |
document = window.document, | |
docElem = document.documentElement, | |
_jQuery = window.jQuery, | |
_$ = window.$, | |
class2type = {}, core_deletedIds = [], | |
core_version = "2.0.0", | |
core_concat = core_deletedIds.concat, | |
core_push = core_deletedIds.push, | |
core_slice = core_deletedIds.slice, | |
core_indexOf = core_deletedIds.indexOf, | |
core_toString = class2type.toString, | |
core_hasOwn = class2type.hasOwnProperty, | |
core_trim = core_version.trim, | |
jQuery = function (selector, context) { | |
return new jQuery.fn.init(selector, context, rootjQuery); | |
}, core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, | |
core_rnotwhite = /\S+/g, | |
rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, | |
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, | |
rmsPrefix = /^-ms-/, | |
rdashAlpha = /-([\da-z])/gi, | |
fcamelCase = function (all, letter) { | |
return letter.toUpperCase(); | |
}, completed = function () { | |
document.removeEventListener("DOMContentLoaded", completed, false); | |
window.removeEventListener("load", completed, false); | |
jQuery.ready(); | |
}; | |
jQuery.fn = jQuery.prototype = { | |
jquery: core_version, | |
constructor: jQuery, | |
init: function (selector, context, rootjQuery) { | |
var match, elem; | |
if (!selector) { | |
return this; | |
} | |
if (typeof selector === "string") { | |
if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) { | |
match = [null, selector, null]; | |
} else { | |
match = rquickExpr.exec(selector); | |
} | |
if (match && (match[1] || !context)) { | |
if (match[1]) { | |
context = context instanceof jQuery ? context[0] : context; | |
jQuery.merge(this, jQuery.parseHTML(match[1], context && context.nodeType ? context.ownerDocument || context : document, true)); | |
if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) { | |
for (match in context) { | |
if (jQuery.isFunction(this[match])) { | |
this[match](context[match]); | |
} else { | |
this.attr(match, context[match]); | |
} | |
} | |
} | |
return this; | |
} else { | |
elem = document.getElementById(match[2]); | |
if (elem && elem.parentNode) { | |
this.length = 1; | |
this[0] = elem; | |
} | |
this.context = document; | |
this.selector = selector; | |
return this; | |
} | |
} else if (!context || context.jquery) { | |
return (context || rootjQuery).find(selector); | |
} else { | |
return this.constructor(context).find(selector); | |
} | |
} else if (selector.nodeType) { | |
this.context = this[0] = selector; | |
this.length = 1; | |
return this; | |
} else if (jQuery.isFunction(selector)) { | |
return rootjQuery.ready(selector); | |
} | |
if (selector.selector !== undefined) { | |
this.selector = selector.selector; | |
this.context = selector.context; | |
} | |
return jQuery.makeArray(selector, this); | |
}, | |
selector: "", | |
length: 0, | |
toArray: function () { | |
return core_slice.call(this); | |
}, | |
get: function (num) { | |
return num == null ? this.toArray() : (num < 0 ? this[this.length + num] : this[num]); | |
}, | |
pushStack: function (elems) { | |
var ret = jQuery.merge(this.constructor(), elems); | |
ret.prevObject = this; | |
ret.context = this.context; | |
return ret; | |
}, | |
each: function (callback, args) { | |
return jQuery.each(this, callback, args); | |
}, | |
ready: function (fn) { | |
jQuery.ready.promise().done(fn); | |
return this; | |
}, | |
slice: function () { | |
return this.pushStack(core_slice.apply(this, arguments)); | |
}, | |
first: function () { | |
return this.eq(0); | |
}, | |
last: function () { | |
return this.eq(-1); | |
}, | |
eq: function (i) { | |
var len = this.length, | |
j = +i + (i < 0 ? len : 0); | |
return this.pushStack(j >= 0 && j < len ? [this[j]] : []); | |
}, | |
map: function (callback) { | |
return this.pushStack(jQuery.map(this, function (elem, i) { | |
return callback.call(elem, i, elem); | |
})); | |
}, | |
end: function () { | |
return this.prevObject || this.constructor(null); | |
}, | |
push: core_push, | |
sort: [].sort, | |
splice: [].splice | |
}; | |
jQuery.fn.init.prototype = jQuery.fn; | |
jQuery.extend = jQuery.fn.extend = function () { | |
var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, | |
length = arguments.length, | |
deep = false; | |
if (typeof target === "boolean") { | |
deep = target; | |
target = arguments[1] || {}; | |
i = 2; | |
} | |
if (typeof target !== "object" && !jQuery.isFunction(target)) { | |
target = {}; | |
} | |
if (length === i) { | |
target = this; | |
--i; | |
} | |
for (; i < length; i++) { | |
if ((options = arguments[i]) != null) { | |
for (name in options) { | |
src = target[name]; | |
copy = options[name]; | |
if (target === copy) { | |
continue; | |
} | |
if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) { | |
if (copyIsArray) { | |
copyIsArray = false; | |
clone = src && jQuery.isArray(src) ? src : []; | |
} else { | |
clone = src && jQuery.isPlainObject(src) ? src : {}; | |
} | |
target[name] = jQuery.extend(deep, clone, copy); | |
} else if (copy !== undefined) { | |
target[name] = copy; | |
} | |
} | |
} | |
} | |
return target; | |
}; | |
jQuery.extend({ | |
expando: "jQuery" + (core_version + Math.random()).replace(/\D/g, ""), | |
noConflict: function (deep) { | |
if (window.$ === jQuery) { | |
window.$ = _$; | |
} | |
if (deep && window.jQuery === jQuery) { | |
window.jQuery = _jQuery; | |
} | |
return jQuery; | |
}, | |
isReady: false, | |
readyWait: 1, | |
holdReady: function (hold) { | |
if (hold) { | |
jQuery.readyWait++; | |
} else { | |
jQuery.ready(true); | |
} | |
}, | |
ready: function (wait) { | |
if (wait === true ? --jQuery.readyWait : jQuery.isReady) { | |
return; | |
} | |
jQuery.isReady = true; | |
if (wait !== true && --jQuery.readyWait > 0) { | |
return; | |
} | |
readyList.resolveWith(document, [jQuery]); | |
if (jQuery.fn.trigger) { | |
jQuery(document).trigger("ready").off("ready"); | |
} | |
}, | |
isFunction: function (obj) { | |
return jQuery.type(obj) === "function"; | |
}, | |
isArray: Array.isArray, | |
isWindow: function (obj) { | |
return obj != null && obj === obj.window; | |
}, | |
isNumeric: function (obj) { | |
return !isNaN(parseFloat(obj)) && isFinite(obj); | |
}, | |
type: function (obj) { | |
if (obj == null) { | |
return String(obj); | |
} | |
return typeof obj === "object" || typeof obj === "function" ? class2type[core_toString.call(obj)] || "object" : typeof obj; | |
}, | |
isPlainObject: function (obj) { | |
if (jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) { | |
return false; | |
} | |
try { | |
if (obj.constructor && !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { | |
return false; | |
} | |
} catch (e) { | |
return false; | |
} | |
return true; | |
}, | |
isEmptyObject: function (obj) { | |
var name; | |
for (name in obj) { | |
return false; | |
} | |
return true; | |
}, | |
error: function (msg) { | |
throw new Error(msg); | |
}, | |
parseHTML: function (data, context, keepScripts) { | |
if (!data || typeof data !== "string") { | |
return null; | |
} | |
if (typeof context === "boolean") { | |
keepScripts = context; | |
context = false; | |
} | |
context = context || document; | |
var parsed = rsingleTag.exec(data), | |
scripts = !keepScripts && []; | |
if (parsed) { | |
return [context.createElement(parsed[1])]; | |
} | |
parsed = jQuery.buildFragment([data], context, scripts); | |
if (scripts) { | |
jQuery(scripts).remove(); | |
} | |
return jQuery.merge([], parsed.childNodes); | |
}, | |
parseJSON: JSON.parse, | |
parseXML: function (data) { | |
var xml, tmp; | |
if (!data || typeof data !== "string") { | |
return null; | |
} | |
try { | |
tmp = new DOMParser(); | |
xml = tmp.parseFromString(data, "text/xml"); | |
} catch (e) { | |
xml = undefined; | |
} | |
if (!xml || xml.getElementsByTagName("parsererror").length) { | |
jQuery.error("Invalid XML: " + data); | |
} | |
return xml; | |
}, | |
noop: function () {}, | |
globalEval: function (code) { | |
var script, indirect = eval; | |
code = jQuery.trim(code); | |
if (code) { | |
if (code.indexOf("use strict") === 1) { | |
script = document.createElement("script"); | |
script.text = code; | |
document.head.appendChild(script).parentNode.removeChild(script); | |
} else { | |
indirect(code); | |
} | |
} | |
}, | |
camelCase: function (string) { | |
return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase); | |
}, | |
nodeName: function (elem, name) { | |
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); | |
}, | |
each: function (obj, callback, args) { | |
var value, i = 0, | |
length = obj.length, | |
isArray = isArraylike(obj); | |
if (args) { | |
if (isArray) { | |
for (; i < length; i++) { | |
value = callback.apply(obj[i], args); | |
if (value === false) { | |
break; | |
} | |
} | |
} else { | |
for (i in obj) { | |
value = callback.apply(obj[i], args); | |
if (value === false) { | |
break; | |
} | |
} | |
} | |
} else { | |
if (isArray) { | |
for (; i < length; i++) { | |
value = callback.call(obj[i], i, obj[i]); | |
if (value === false) { | |
break; | |
} | |
} | |
} else { | |
for (i in obj) { | |
value = callback.call(obj[i], i, obj[i]); | |
if (value === false) { | |
break; | |
} | |
} | |
} | |
} | |
return obj; | |
}, | |
trim: function (text) { | |
return text == null ? "" : core_trim.call(text); | |
}, | |
makeArray: function (arr, results) { | |
var ret = results || []; | |
if (arr != null) { | |
if (isArraylike(Object(arr))) { | |
jQuery.merge(ret, typeof arr === "string" ? [arr] : arr); | |
} else { | |
core_push.call(ret, arr); | |
} | |
} | |
return ret; | |
}, | |
inArray: function (elem, arr, i) { | |
return arr == null ? -1 : core_indexOf.call(arr, elem, i); | |
}, | |
merge: function (first, second) { | |
var l = second.length, | |
i = first.length, | |
j = 0; | |
if (typeof l === "number") { | |
for (; j < l; j++) { | |
first[i++] = second[j]; | |
} | |
} else { | |
while (second[j] !== undefined) { | |
first[i++] = second[j++]; | |
} | |
} | |
first.length = i; | |
return first; | |
}, | |
grep: function (elems, callback, inv) { | |
var retVal, ret = [], | |
i = 0, | |
length = elems.length; | |
inv = !! inv; | |
for (; i < length; i++) { | |
retVal = !! callback(elems[i], i); | |
if (inv !== retVal) { | |
ret.push(elems[i]); | |
} | |
} | |
return ret; | |
}, | |
map: function (elems, callback, arg) { | |
var value, i = 0, | |
length = elems.length, | |
isArray = isArraylike(elems), | |
ret = []; | |
if (isArray) { | |
for (; i < length; i++) { | |
value = callback(elems[i], i, arg); | |
if (value != null) { | |
ret[ret.length] = value; | |
} | |
} | |
} else { | |
for (i in elems) { | |
value = callback(elems[i], i, arg); | |
if (value != null) { | |
ret[ret.length] = value; | |
} | |
} | |
} | |
return core_concat.apply([], ret); | |
}, | |
guid: 1, | |
proxy: function (fn, context) { | |
var tmp, args, proxy; | |
if (typeof context === "string") { | |
tmp = fn[context]; | |
context = fn; | |
fn = tmp; | |
} | |
if (!jQuery.isFunction(fn)) { | |
return undefined; | |
} | |
args = core_slice.call(arguments, 2); | |
proxy = function () { | |
return fn.apply(context || this, args.concat(core_slice.call(arguments))); | |
}; | |
proxy.guid = fn.guid = fn.guid || jQuery.guid++; | |
return proxy; | |
}, | |
access: function (elems, fn, key, value, chainable, emptyGet, raw) { | |
var i = 0, | |
length = elems.length, | |
bulk = key == null; | |
if (jQuery.type(key) === "object") { | |
chainable = true; | |
for (i in key) { | |
jQuery.access(elems, fn, i, key[i], true, emptyGet, raw); | |
} | |
} else if (value !== undefined) { | |
chainable = true; | |
if (!jQuery.isFunction(value)) { | |
raw = true; | |
} | |
if (bulk) { | |
if (raw) { | |
fn.call(elems, value); | |
fn = null; | |
} else { | |
bulk = fn; | |
fn = function (elem, key, value) { | |
return bulk.call(jQuery(elem), value); | |
}; | |
} | |
} | |
if (fn) { | |
for (; i < length; i++) { | |
fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key))); | |
} | |
} | |
} | |
return chainable ? elems : bulk ? fn.call(elems) : length ? fn(elems[0], key) : emptyGet; | |
}, | |
now: Date.now, | |
swap: function (elem, options, callback, args) { | |
var ret, name, old = {}; | |
for (name in options) { | |
old[name] = elem.style[name]; | |
elem.style[name] = options[name]; | |
} | |
ret = callback.apply(elem, args || []); | |
for (name in options) { | |
elem.style[name] = old[name]; | |
} | |
return ret; | |
} | |
}); | |
jQuery.ready.promise = function (obj) { | |
if (!readyList) { | |
readyList = jQuery.Deferred(); | |
if (document.readyState === "complete") { | |
setTimeout(jQuery.ready); | |
} else { | |
document.addEventListener("DOMContentLoaded", completed, false); | |
window.addEventListener("load", completed, false); | |
} | |
} | |
return readyList.promise(obj); | |
}; | |
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function (i, name) { | |
class2type["[object " + name + "]"] = name.toLowerCase(); | |
}); | |
function isArraylike(obj) { | |
var length = obj.length, | |
type = jQuery.type(obj); | |
if (jQuery.isWindow(obj)) { | |
return false; | |
} | |
if (obj.nodeType === 1 && length) { | |
return true; | |
} | |
return type === "array" || type !== "function" && (length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj); | |
} | |
rootjQuery = jQuery(document); | |
(function (window, undefined) { | |
var i, cachedruns, Expr, getText, isXML, compile, outermostContext, sortInput, setDocument, document, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, expando = "sizzle" + -(new Date()), | |
preferredDoc = window.document, | |
support = {}, dirruns = 0, | |
done = 0, | |
classCache = createCache(), | |
tokenCache = createCache(), | |
compilerCache = createCache(), | |
hasDuplicate = false, | |
sortOrder = function () { | |
return 0; | |
}, strundefined = typeof undefined, | |
MAX_NEGATIVE = 1 << 31, | |
arr = [], | |
pop = arr.pop, | |
push_native = arr.push, | |
push = arr.push, | |
slice = arr.slice, | |
indexOf = arr.indexOf || function (elem) { | |
var i = 0, | |
len = this.length; | |
for (; i < len; i++) { | |
if (this[i] === elem) { | |
return i; | |
} | |
} | |
return -1; | |
}, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", | |
whitespace = "[\\x20\\t\\r\\n\\f]", | |
characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", | |
identifier = characterEncoding.replace("w", "w#"), | |
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", | |
pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace(3, 8) + ")*)|.*)\\)|)", | |
rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), | |
rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"), | |
rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"), | |
rsibling = new RegExp(whitespace + "*[+~]"), | |
rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g"), | |
rpseudo = new RegExp(pseudos), | |
ridentifier = new RegExp("^" + identifier + "$"), | |
matchExpr = { | |
"ID": new RegExp("^#(" + characterEncoding + ")"), | |
"CLASS": new RegExp("^\\.(" + characterEncoding + ")"), | |
"TAG": new RegExp("^(" + characterEncoding.replace("w", "w*") + ")"), | |
"ATTR": new RegExp("^" + attributes), | |
"PSEUDO": new RegExp("^" + pseudos), | |
"CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"), | |
"boolean": new RegExp("^(?:" + booleans + ")$", "i"), | |
"needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + | |
whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i") | |
}, rnative = /^[^{]+\{\s*\[native \w/, | |
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, | |
rinputs = /^(?:input|select|textarea|button)$/i, | |
rheader = /^h\d$/i, | |
rescape = /'|\\/g, | |
runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g, | |
funescape = function (_, escaped) { | |
var high = "0x" + escaped - 0x10000; | |
return high !== high ? escaped : high < 0 ? String.fromCharCode(high + 0x10000) : String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00); | |
}; | |
try { | |
push.apply((arr = slice.call(preferredDoc.childNodes)), preferredDoc.childNodes); | |
arr[preferredDoc.childNodes.length].nodeType; | |
} catch (e) { | |
push = { | |
apply: arr.length ? function (target, els) { | |
push_native.apply(target, slice.call(els)); | |
} : function (target, els) { | |
var j = target.length, | |
i = 0; | |
while ((target[j++] = els[i++])) {} | |
target.length = j - 1; | |
} | |
}; | |
} | |
function isNative(fn) { | |
return rnative.test(fn + ""); | |
} | |
function createCache() { | |
var cache, keys = []; | |
return (cache = function (key, value) { | |
if (keys.push(key += " ") > Expr.cacheLength) { | |
delete cache[keys.shift()]; | |
} | |
return (cache[key] = value); | |
}); | |
} | |
function markFunction(fn) { | |
fn[expando] = true; | |
return fn; | |
} | |
function assert(fn) { | |
var div = document.createElement("div"); | |
try { | |
return !!fn(div); | |
} catch (e) { | |
return false; | |
} finally { | |
if (div.parentNode) { | |
div.parentNode.removeChild(div); | |
} | |
div = null; | |
} | |
} | |
function Sizzle(selector, context, results, seed) { | |
var match, elem, m, nodeType, i, groups, old, nid, newContext, newSelector; | |
if ((context ? context.ownerDocument || context : preferredDoc) !== document) { | |
setDocument(context); | |
} | |
context = context || document; | |
results = results || []; | |
if (!selector || typeof selector !== "string") { | |
return results; | |
} | |
if ((nodeType = context.nodeType) !== 1 && nodeType !== 9) { | |
return []; | |
} | |
if (documentIsHTML && !seed) { | |
if ((match = rquickExpr.exec(selector))) { | |
if ((m = match[1])) { | |
if (nodeType === 9) { | |
elem = context.getElementById(m); | |
if (elem && elem.parentNode) { | |
if (elem.id === m) { | |
results.push(elem); | |
return results; | |
} | |
} else { | |
return results; | |
} | |
} else { | |
if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) && contains(context, elem) && elem.id === m) { | |
results.push(elem); | |
return results; | |
} | |
} | |
} else if (match[2]) { | |
push.apply(results, context.getElementsByTagName(selector)); | |
return results; | |
} else if ((m = match[3]) && support.getElementsByClassName && context.getElementsByClassName) { | |
push.apply(results, context.getElementsByClassName(m)); | |
return results; | |
} | |
} | |
if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) { | |
nid = old = expando; | |
newContext = context; | |
newSelector = nodeType === 9 && selector; | |
if (nodeType === 1 && context.nodeName.toLowerCase() !== "object") { | |
groups = tokenize(selector); | |
if ((old = context.getAttribute("id"))) { | |
nid = old.replace(rescape, "\\$&"); | |
} else { | |
context.setAttribute("id", nid); | |
} | |
nid = "[id='" + nid + "'] "; | |
i = groups.length; | |
while (i--) { | |
groups[i] = nid + toSelector(groups[i]); | |
} | |
newContext = rsibling.test(selector) && context.parentNode || context; | |
newSelector = groups.join(","); | |
} | |
if (newSelector) { | |
try { | |
push.apply(results, newContext.querySelectorAll(newSelector)); | |
return results; | |
} catch (qsaError) {} finally { | |
if (!old) { | |
context.removeAttribute("id"); | |
} | |
} | |
} | |
} | |
} | |
return select(selector.replace(rtrim, "$1"), context, results, seed); | |
} | |
isXML = Sizzle.isXML = function (elem) { | |
var documentElement = elem && (elem.ownerDocument || elem).documentElement; | |
return documentElement ? documentElement.nodeName !== "HTML" : false; | |
}; | |
setDocument = Sizzle.setDocument = function (node) { | |
var doc = node ? node.ownerDocument || node : preferredDoc; | |
if (doc === document || doc.nodeType !== 9 || !doc.documentElement) { | |
return document; | |
} | |
document = doc; | |
docElem = doc.documentElement; | |
documentIsHTML = !isXML(doc); | |
support.getElementsByTagName = assert(function (div) { | |
div.appendChild(doc.createComment("")); | |
return !div.getElementsByTagName("*").length; | |
}); | |
support.attributes = assert(function (div) { | |
div.className = "i"; | |
return !div.getAttribute("className"); | |
}); | |
support.getElementsByClassName = assert(function (div) { | |
div.innerHTML = "<div class='a'></div><div class='a i'></div>"; | |
div.firstChild.className = "i"; | |
return div.getElementsByClassName("i").length === 2; | |
}); | |
support.sortDetached = assert(function (div1) { | |
return div1.compareDocumentPosition(document.createElement("div")) & 1; | |
}); | |
support.getById = assert(function (div) { | |
docElem.appendChild(div).id = expando; | |
return !doc.getElementsByName || !doc.getElementsByName(expando).length; | |
}); | |
if (support.getById) { | |
Expr.find["ID"] = function (id, context) { | |
if (typeof context.getElementById !== strundefined && documentIsHTML) { | |
var m = context.getElementById(id); | |
return m && m.parentNode ? [m] : []; | |
} | |
}; | |
Expr.filter["ID"] = function (id) { | |
var attrId = id.replace(runescape, funescape); | |
return function (elem) { | |
return elem.getAttribute("id") === attrId; | |
}; | |
}; | |
} else { | |
Expr.find["ID"] = function (id, context) { | |
if (typeof context.getElementById !== strundefined && documentIsHTML) { | |
var m = context.getElementById(id); | |
return m ? m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? [m] : undefined : []; | |
} | |
}; | |
Expr.filter["ID"] = function (id) { | |
var attrId = id.replace(runescape, funescape); | |
return function (elem) { | |
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); | |
return node && node.value === attrId; | |
}; | |
}; | |
} | |
Expr.find["TAG"] = support.getElementsByTagName ? function (tag, context) { | |
if (typeof context.getElementsByTagName !== strundefined) { | |
return context.getElementsByTagName(tag); | |
} | |
} : function (tag, context) { | |
var elem, tmp = [], | |
i = 0, | |
results = context.getElementsByTagName(tag); | |
if (tag === "*") { | |
while ((elem = results[i++])) { | |
if (elem.nodeType === 1) { | |
tmp.push(elem); | |
} | |
} | |
return tmp; | |
} | |
return results; | |
}; | |
Expr.find["CLASS"] = support.getElementsByClassName && function (className, context) { | |
if (typeof context.getElementsByClassName !== strundefined && documentIsHTML) { | |
return context.getElementsByClassName(className); | |
} | |
}; | |
rbuggyMatches = []; | |
rbuggyQSA = []; | |
if ((support.qsa = isNative(doc.querySelectorAll))) { | |
assert(function (div) { | |
div.innerHTML = "<select><option selected=''></option></select>"; | |
if (!div.querySelectorAll("[selected]").length) { | |
rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")"); | |
} | |
if (!div.querySelectorAll(":checked").length) { | |
rbuggyQSA.push(":checked"); | |
} | |
}); | |
assert(function (div) { | |
var input = document.createElement("input"); | |
input.setAttribute("type", "hidden"); | |
div.appendChild(input).setAttribute("t", ""); | |
if (div.querySelectorAll("[t^='']").length) { | |
rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")"); | |
} | |
if (!div.querySelectorAll(":enabled").length) { | |
rbuggyQSA.push(":enabled", ":disabled"); | |
} | |
div.querySelectorAll("*,:x"); | |
rbuggyQSA.push(",.*:"); | |
}); | |
} | |
if ((support.matchesSelector = isNative((matches = docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)))) { | |
assert(function (div) { | |
support.disconnectedMatch = matches.call(div, "div"); | |
matches.call(div, "[s!='']:x"); | |
rbuggyMatches.push("!=", pseudos); | |
}); | |
} | |
rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|")); | |
rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|")); | |
contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? function (a, b) { | |
var adown = a.nodeType === 9 ? a.documentElement : a, | |
bup = b && b.parentNode; | |
return a === bup || !! (bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)); | |
} : function (a, b) { | |
if (b) { | |
while ((b = b.parentNode)) { | |
if (b === a) { | |
return true; | |
} | |
} | |
} | |
return false; | |
}; | |
sortOrder = docElem.compareDocumentPosition ? function (a, b) { | |
if (a === b) { | |
hasDuplicate = true; | |
return 0; | |
} | |
var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition(b); | |
if (compare) { | |
if (compare & 1 || (!support.sortDetached && b.compareDocumentPosition(a) === compare)) { | |
if (a === doc || contains(preferredDoc, a)) { | |
return -1; | |
} | |
if (b === doc || contains(preferredDoc, b)) { | |
return 1; | |
} | |
return sortInput ? (indexOf.call(sortInput, a) - indexOf.call(sortInput, b)) : 0; | |
} | |
return compare & 4 ? -1 : 1; | |
} | |
return a.compareDocumentPosition ? -1 : 1; | |
} : function (a, b) { | |
var cur, i = 0, | |
aup = a.parentNode, | |
bup = b.parentNode, | |
ap = [a], | |
bp = [b]; | |
if (a === b) { | |
hasDuplicate = true; | |
return 0; | |
} else if (!aup || !bup) { | |
return a === doc ? -1 : b === doc ? 1 : aup ? -1 : bup ? 1 : sortInput ? (indexOf.call(sortInput, a) - indexOf.call(sortInput, b)) : 0; | |
} else if (aup === bup) { | |
return siblingCheck(a, b); | |
} | |
cur = a; | |
while ((cur = cur.parentNode)) { | |
ap.unshift(cur); | |
} | |
cur = b; | |
while ((cur = cur.parentNode)) { | |
bp.unshift(cur); | |
} | |
while (ap[i] === bp[i]) { | |
i++; | |
} | |
return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0; | |
}; | |
return document; | |
}; | |
Sizzle.matches = function (expr, elements) { | |
return Sizzle(expr, null, null, elements); | |
}; | |
Sizzle.matchesSelector = function (elem, expr) { | |
if ((elem.ownerDocument || elem) !== document) { | |
setDocument(elem); | |
} | |
expr = expr.replace(rattributeQuotes, "='$1']"); | |
if (support.matchesSelector && documentIsHTML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) { | |
try { | |
var ret = matches.call(elem, expr); | |
if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) { | |
return ret; | |
} | |
} catch (e) {} | |
} | |
return Sizzle(expr, document, null, [elem]).length > 0; | |
}; | |
Sizzle.contains = function (context, elem) { | |
if ((context.ownerDocument || context) !== document) { | |
setDocument(context); | |
} | |
return contains(context, elem); | |
}; | |
Sizzle.attr = function (elem, name) { | |
if ((elem.ownerDocument || elem) !== document) { | |
setDocument(elem); | |
} | |
var fn = Expr.attrHandle[name.toLowerCase()], | |
val = fn && fn(elem, name, !documentIsHTML); | |
return val === undefined ? support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null : val; | |
}; | |
Sizzle.error = function (msg) { | |
throw new Error("Syntax error, unrecognized expression: " + msg); | |
}; | |
Sizzle.uniqueSort = function (results) { | |
var elem, duplicates = [], | |
j = 0, | |
i = 0; | |
hasDuplicate = !support.detectDuplicates; | |
sortInput = !support.sortStable && results.slice(0); | |
results.sort(sortOrder); | |
if (hasDuplicate) { | |
while ((elem = results[i++])) { | |
if (elem === results[i]) { | |
j = duplicates.push(i); | |
} | |
} | |
while (j--) { | |
results.splice(duplicates[j], 1); | |
} | |
} | |
return results; | |
}; | |
function siblingCheck(a, b) { | |
var cur = b && a, | |
diff = cur && (~b.sourceIndex || MAX_NEGATIVE) - (~a.sourceIndex || MAX_NEGATIVE); | |
if (diff) { | |
return diff; | |
} | |
if (cur) { | |
while ((cur = cur.nextSibling)) { | |
if (cur === b) { | |
return -1; | |
} | |
} | |
} | |
return a ? 1 : -1; | |
} | |
function boolHandler(elem, name, isXML) { | |
var val; | |
return isXML ? undefined : (val = elem.getAttributeNode(name)) && val.specified ? val.value : elem[name] === true ? name.toLowerCase() : null; | |
} | |
function interpolationHandler(elem, name, isXML) { | |
var val; | |
return isXML ? undefined : (val = elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2)); | |
} | |
function createInputPseudo(type) { | |
return function (elem) { | |
var name = elem.nodeName.toLowerCase(); | |
return name === "input" && elem.type === type; | |
}; | |
} | |
function createButtonPseudo(type) { | |
return function (elem) { | |
var name = elem.nodeName.toLowerCase(); | |
return (name === "input" || name === "button") && elem.type === type; | |
}; | |
} | |
function createPositionalPseudo(fn) { | |
return markFunction(function (argument) { | |
argument = +argument; | |
return markFunction(function (seed, matches) { | |
var j, matchIndexes = fn([], seed.length, argument), | |
i = matchIndexes.length; | |
while (i--) { | |
if (seed[(j = matchIndexes[i])]) { | |
seed[j] = !(matches[j] = seed[j]); | |
} | |
} | |
}); | |
}); | |
} | |
getText = Sizzle.getText = function (elem) { | |
var node, ret = "", | |
i = 0, | |
nodeType = elem.nodeType; | |
if (!nodeType) { | |
for (; | |
(node = elem[i]); i++) { | |
ret += getText(node); | |
} | |
} else if (nodeType === 1 || nodeType === 9 || nodeType === 11) { | |
if (typeof elem.textContent === "string") { | |
return elem.textContent; | |
} else { | |
for (elem = elem.firstChild; elem; elem = elem.nextSibling) { | |
ret += getText(elem); | |
} | |
} | |
} else if (nodeType === 3 || nodeType === 4) { | |
return elem.nodeValue; | |
} | |
return ret; | |
}; | |
Expr = Sizzle.selectors = { | |
cacheLength: 50, | |
createPseudo: markFunction, | |
match: matchExpr, | |
attrHandle: {}, | |
find: {}, | |
relative: { | |
">": { | |
dir: "parentNode", | |
first: true | |
}, | |
" ": { | |
dir: "parentNode" | |
}, | |
"+": { | |
dir: "previousSibling", | |
first: true | |
}, | |
"~": { | |
dir: "previousSibling" | |
} | |
}, | |
preFilter: { | |
"ATTR": function (match) { | |
match[1] = match[1].replace(runescape, funescape); | |
match[3] = (match[4] || match[5] || "").replace(runescape, funescape); | |
if (match[2] === "~=") { | |
match[3] = " " + match[3] + " "; | |
} | |
return match.slice(0, 4); | |
}, | |
"CHILD": function (match) { | |
match[1] = match[1].toLowerCase(); | |
if (match[1].slice(0, 3) === "nth") { | |
if (!match[3]) { | |
Sizzle.error(match[0]); | |
} | |
match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd")); | |
match[5] = +((match[7] + match[8]) || match[3] === "odd"); | |
} else if (match[3]) { | |
Sizzle.error(match[0]); | |
} | |
return match; | |
}, | |
"PSEUDO": function (match) { | |
var excess, unquoted = !match[5] && match[2]; | |
if (matchExpr["CHILD"].test(match[0])) { | |
return null; | |
} | |
if (match[4]) { | |
match[2] = match[4]; | |
} else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) { | |
match[0] = match[0].slice(0, excess); | |
match[2] = unquoted.slice(0, excess); | |
} | |
return match.slice(0, 3); | |
} | |
}, | |
filter: { | |
"TAG": function (nodeNameSelector) { | |
var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase(); | |
return nodeNameSelector === "*" ? function () { | |
return true; | |
} : function (elem) { | |
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; | |
}; | |
}, | |
"CLASS": function (className) { | |
var pattern = classCache[className + " "]; | |
return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function (elem) { | |
return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || ""); | |
}); | |
}, | |
"ATTR": function (name, operator, check) { | |
return function (elem) { | |
var result = Sizzle.attr(elem, name); | |
if (result == null) { | |
return operator === "!="; | |
} | |
if (!operator) { | |
return true; | |
} | |
result += ""; | |
return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf(check) === 0 : operator === "*=" ? check && result.indexOf(check) > -1 : operator === "$=" ? check && result.slice(-check.length) === check : operator === "~=" ? (" " + result + " ").indexOf(check) > -1 : operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" : false; | |
}; | |
}, | |
"CHILD": function (type, what, argument, first, last) { | |
var simple = type.slice(0, 3) !== "nth", | |
forward = type.slice(-4) !== "last", | |
ofType = what === "of-type"; | |
return first === 1 && last === 0 ? function (elem) { | |
return !!elem.parentNode; | |
} : function (elem, context, xml) { | |
var cache, outerCache, node, diff, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", | |
parent = elem.parentNode, | |
name = ofType && elem.nodeName.toLowerCase(), | |
useCache = !xml && !ofType; | |
if (parent) { | |
if (simple) { | |
while (dir) { | |
node = elem; | |
while ((node = node[dir])) { | |
if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) { | |
return false; | |
} | |
} | |
start = dir = type === "only" && !start && "nextSibling"; | |
} | |
return true; | |
} | |
start = [forward ? parent.firstChild : parent.lastChild]; | |
if (forward && useCache) { | |
outerCache = parent[expando] || (parent[expando] = {}); | |
cache = outerCache[type] || []; | |
nodeIndex = cache[0] === dirruns && cache[1]; | |
diff = cache[0] === dirruns && cache[2]; | |
node = nodeIndex && parent.childNodes[nodeIndex]; | |
while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) { | |
if (node.nodeType === 1 && ++diff && node === elem) { | |
outerCache[type] = [dirruns, nodeIndex, diff]; | |
break; | |
} | |
} | |
} else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) { | |
diff = cache[1]; | |
} else { | |
while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) { | |
if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) { | |
if (useCache) { | |
(node[expando] || (node[expando] = {}))[type] = [dirruns, diff]; | |
} | |
if (node === elem) { | |
break; | |
} | |
} | |
} | |
} | |
diff -= last; | |
return diff === first || (diff % first === 0 && diff / first >= 0); | |
} | |
}; | |
}, | |
"PSEUDO": function (pseudo, argument) { | |
var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error("unsupported pseudo: " + pseudo); | |
if (fn[expando]) { | |
return fn(argument); | |
} | |
if (fn.length > 1) { | |
args = [pseudo, pseudo, "", argument]; | |
return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function (seed, matches) { | |
var idx, matched = fn(seed, argument), | |
i = matched.length; | |
while (i--) { | |
idx = indexOf.call(seed, matched[i]); | |
seed[idx] = !(matches[idx] = matched[i]); | |
} | |
}) : function (elem) { | |
return fn(elem, 0, args); | |
}; | |
} | |
return fn; | |
} | |
}, | |
pseudos: { | |
"not": markFunction(function (selector) { | |
var input = [], | |
results = [], | |
matcher = compile(selector.replace(rtrim, "$1")); | |
return matcher[expando] ? markFunction(function (seed, matches, context, xml) { | |
var elem, unmatched = matcher(seed, null, xml, []), | |
i = seed.length; | |
while (i--) { | |
if ((elem = unmatched[i])) { | |
seed[i] = !(matches[i] = elem); | |
} | |
} | |
}) : function (elem, context, xml) { | |
input[0] = elem; | |
matcher(input, null, xml, results); | |
return !results.pop(); | |
}; | |
}), | |
"has": markFunction(function (selector) { | |
return function (elem) { | |
return Sizzle(selector, elem).length > 0; | |
}; | |
}), | |
"contains": markFunction(function (text) { | |
return function (elem) { | |
return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1; | |
}; | |
}), | |
"lang": markFunction(function (lang) { | |
if (!ridentifier.test(lang || "")) { | |
Sizzle.error("unsupported lang: " + lang); | |
} | |
lang = lang.replace(runescape, funescape).toLowerCase(); | |
return function (elem) { | |
var elemLang; | |
do { | |
if ((elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang"))) { | |
elemLang = elemLang.toLowerCase(); | |
return elemLang === lang || elemLang.indexOf(lang + "-") === 0; | |
} | |
} while ((elem = elem.parentNode) && elem.nodeType === 1); | |
return false; | |
}; | |
}), | |
"target": function (elem) { | |
var hash = window.location && window.location.hash; | |
return hash && hash.slice(1) === elem.id; | |
}, | |
"root": function (elem) { | |
return elem === docElem; | |
}, | |
"focus": function (elem) { | |
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !! (elem.type || elem.href || ~elem.tabIndex); | |
}, | |
"enabled": function (elem) { | |
return elem.disabled === false; | |
}, | |
"disabled": function (elem) { | |
return elem.disabled === true; | |
}, | |
"checked": function (elem) { | |
var nodeName = elem.nodeName.toLowerCase(); | |
return (nodeName === "input" && !! elem.checked) || (nodeName === "option" && !! elem.selected); | |
}, | |
"selected": function (elem) { | |
if (elem.parentNode) { | |
elem.parentNode.selectedIndex; | |
} | |
return elem.selected === true; | |
}, | |
"empty": function (elem) { | |
for (elem = elem.firstChild; elem; elem = elem.nextSibling) { | |
if (elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4) { | |
return false; | |
} | |
} | |
return true; | |
}, | |
"parent": function (elem) { | |
return !Expr.pseudos["empty"](elem); | |
}, | |
"header": function (elem) { | |
return rheader.test(elem.nodeName); | |
}, | |
"input": function (elem) { | |
return rinputs.test(elem.nodeName); | |
}, | |
"button": function (elem) { | |
var name = elem.nodeName.toLowerCase(); | |
return name === "input" && elem.type === "button" || name === "button"; | |
}, | |
"text": function (elem) { | |
var attr; | |
return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && ((attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type); | |
}, | |
"first": createPositionalPseudo(function () { | |
return [0]; | |
}), | |
"last": createPositionalPseudo(function (matchIndexes, length) { | |
return [length - 1]; | |
}), | |
"eq": createPositionalPseudo(function (matchIndexes, length, argument) { | |
return [argument < 0 ? argument + length : argument]; | |
}), | |
"even": createPositionalPseudo(function (matchIndexes, length) { | |
var i = 0; | |
for (; i < length; i += 2) { | |
matchIndexes.push(i); | |
} | |
return matchIndexes; | |
}), | |
"odd": createPositionalPseudo(function (matchIndexes, length) { | |
var i = 1; | |
for (; i < length; i += 2) { | |
matchIndexes.push(i); | |
} | |
return matchIndexes; | |
}), | |
"lt": createPositionalPseudo(function (matchIndexes, length, argument) { | |
var i = argument < 0 ? argument + length : argument; | |
for (; --i >= 0;) { | |
matchIndexes.push(i); | |
} | |
return matchIndexes; | |
}), | |
"gt": createPositionalPseudo(function (matchIndexes, length, argument) { | |
var i = argument < 0 ? argument + length : argument; | |
for (; ++i < length;) { | |
matchIndexes.push(i); | |
} | |
return matchIndexes; | |
}) | |
} | |
}; | |
for (i in { | |
radio: true, | |
checkbox: true, | |
file: true, | |
password: true, | |
image: true | |
}) { | |
Expr.pseudos[i] = createInputPseudo(i); | |
} | |
for (i in { | |
submit: true, | |
reset: true | |
}) { | |
Expr.pseudos[i] = createButtonPseudo(i); | |
} | |
function tokenize(selector, parseOnly) { | |
var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "]; | |
if (cached) { | |
return parseOnly ? 0 : cached.slice(0); | |
} | |
soFar = selector; | |
groups = []; | |
preFilters = Expr.preFilter; | |
while (soFar) { | |
if (!matched || (match = rcomma.exec(soFar))) { | |
if (match) { | |
soFar = soFar.slice(match[0].length) || soFar; | |
} | |
groups.push(tokens = []); | |
} | |
matched = false; | |
if ((match = rcombinators.exec(soFar))) { | |
matched = match.shift(); | |
tokens.push({ | |
value: matched, | |
type: match[0].replace(rtrim, " ") | |
}); | |
soFar = soFar.slice(matched.length); | |
} | |
for (type in Expr.filter) { | |
if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) { | |
matched = match.shift(); | |
tokens.push({ | |
value: matched, | |
type: type, | |
matches: match | |
}); | |
soFar = soFar.slice(matched.length); | |
} | |
} | |
if (!matched) { | |
break; | |
} | |
} | |
return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) : tokenCache(selector, groups).slice(0); | |
} | |
function toSelector(tokens) { | |
var i = 0, | |
len = tokens.length, | |
selector = ""; | |
for (; i < len; i++) { | |
selector += tokens[i].value; | |
} | |
return selector; | |
} | |
function addCombinator(matcher, combinator, base) { | |
var dir = combinator.dir, | |
checkNonElements = base && dir === "parentNode", | |
doneName = done++; | |
return combinator.first ? function (elem, context, xml) { | |
while ((elem = elem[dir])) { | |
if (elem.nodeType === 1 || checkNonElements) { | |
return matcher(elem, context, xml); | |
} | |
} | |
} : function (elem, context, xml) { | |
var data, cache, outerCache, dirkey = dirruns + " " + doneName; | |
if (xml) { | |
while ((elem = elem[dir])) { | |
if (elem.nodeType === 1 || checkNonElements) { | |
if (matcher(elem, context, xml)) { | |
return true; | |
} | |
} | |
} | |
} else { | |
while ((elem = elem[dir])) { | |
if (elem.nodeType === 1 || checkNonElements) { | |
outerCache = elem[expando] || (elem[expando] = {}); | |
if ((cache = outerCache[dir]) && cache[0] === dirkey) { | |
if ((data = cache[1]) === true || data === cachedruns) { | |
return data === true; | |
} | |
} else { | |
cache = outerCache[dir] = [dirkey]; | |
cache[1] = matcher(elem, context, xml) || cachedruns; | |
if (cache[1] === true) { | |
return true; | |
} | |
} | |
} | |
} | |
} | |
}; | |
} | |
function elementMatcher(matchers) { | |
return matchers.length > 1 ? function (elem, context, xml) { | |
var i = matchers.length; | |
while (i--) { | |
if (!matchers[i](elem, context, xml)) { | |
return false; | |
} | |
} | |
return true; | |
} : matchers[0]; | |
} | |
function condense(unmatched, map, filter, context, xml) { | |
var elem, newUnmatched = [], | |
i = 0, | |
len = unmatched.length, | |
mapped = map != null; | |
for (; i < len; i++) { | |
if ((elem = unmatched[i])) { | |
if (!filter || filter(elem, context, xml)) { | |
newUnmatched.push(elem); | |
if (mapped) { | |
map.push(i); | |
} | |
} | |
} | |
} | |
return newUnmatched; | |
} | |
function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) { | |
if (postFilter && !postFilter[expando]) { | |
postFilter = setMatcher(postFilter); | |
} | |
if (postFinder && !postFinder[expando]) { | |
postFinder = setMatcher(postFinder, postSelector); | |
} | |
return markFunction(function (seed, results, context, xml) { | |
var temp, i, elem, preMap = [], | |
postMap = [], | |
preexisting = results.length, | |
elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []), | |
matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems, | |
matcherOut = matcher ? postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results : matcherIn; | |
if (matcher) { | |
matcher(matcherIn, matcherOut, context, xml); | |
} | |
if (postFilter) { | |
temp = condense(matcherOut, postMap); | |
postFilter(temp, [], context, xml); | |
i = temp.length; | |
while (i--) { | |
if ((elem = temp[i])) { | |
matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem); | |
} | |
} | |
} | |
if (seed) { | |
if (postFinder || preFilter) { | |
if (postFinder) { | |
temp = []; | |
i = matcherOut.length; | |
while (i--) { | |
if ((elem = matcherOut[i])) { | |
temp.push((matcherIn[i] = elem)); | |
} | |
} | |
postFinder(null, (matcherOut = []), temp, xml); | |
} | |
i = matcherOut.length; | |
while (i--) { | |
if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf.call(seed, elem) : preMap[i]) > -1) { | |
seed[temp] = !(results[temp] = elem); | |
} | |
} | |
} | |
} else { | |
matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut); | |
if (postFinder) { | |
postFinder(null, results, matcherOut, xml); | |
} else { | |
push.apply(results, matcherOut); | |
} | |
} | |
}); | |
} | |
function matcherFromTokens(tokens) { | |
var checkContext, matcher, j, len = tokens.length, | |
leadingRelative = Expr.relative[tokens[0].type], | |
implicitRelative = leadingRelative || Expr.relative[" "], | |
i = leadingRelative ? 1 : 0, | |
matchContext = addCombinator(function (elem) { | |
return elem === checkContext; | |
}, implicitRelative, true), | |
matchAnyContext = addCombinator(function (elem) { | |
return indexOf.call(checkContext, elem) > -1; | |
}, implicitRelative, true), | |
matchers = [ | |
function (elem, context, xml) { | |
return (!leadingRelative && (xml || context !== outermostContext)) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml)); | |
} | |
]; | |
for (; i < len; i++) { | |
if ((matcher = Expr.relative[tokens[i].type])) { | |
matchers = [addCombinator(elementMatcher(matchers), matcher)]; | |
} else { | |
matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches); | |
if (matcher[expando]) { | |
j = ++i; | |
for (; j < len; j++) { | |
if (Expr.relative[tokens[j].type]) { | |
break; | |
} | |
} | |
return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1)).replace(rtrim, "$1"), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens((tokens = tokens.slice(j))), j < len && toSelector(tokens)); | |
} | |
matchers.push(matcher); | |
} | |
} | |
return elementMatcher(matchers); | |
} | |
function matcherFromGroupMatchers(elementMatchers, setMatchers) { | |
var matcherCachedRuns = 0, | |
bySet = setMatchers.length > 0, | |
byElement = elementMatchers.length > 0, | |
superMatcher = function (seed, context, xml, results, expandContext) { | |
var elem, j, matcher, setMatched = [], | |
matchedCount = 0, | |
i = "0", | |
unmatched = seed && [], | |
outermost = expandContext != null, | |
contextBackup = outermostContext, | |
elems = seed || byElement && Expr.find["TAG"]("*", expandContext && context.parentNode || context), | |
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); | |
if (outermost) { | |
outermostContext = context !== document && context; | |
cachedruns = matcherCachedRuns; | |
} | |
for (; | |
(elem = elems[i]) != null; i++) { | |
if (byElement && elem) { | |
j = 0; | |
while ((matcher = elementMatchers[j++])) { | |
if (matcher(elem, context, xml)) { | |
results.push(elem); | |
break; | |
} | |
} | |
if (outermost) { | |
dirruns = dirrunsUnique; | |
cachedruns = ++matcherCachedRuns; | |
} | |
} | |
if (bySet) { | |
if ((elem = !matcher && elem)) { | |
matchedCount--; | |
} | |
if (seed) { | |
unmatched.push(elem); | |
} | |
} | |
} | |
matchedCount += i; | |
if (bySet && i !== matchedCount) { | |
j = 0; | |
while ((matcher = setMatchers[j++])) { | |
matcher(unmatched, setMatched, context, xml); | |
} | |
if (seed) { | |
if (matchedCount > 0) { | |
while (i--) { | |
if (!(unmatched[i] || setMatched[i])) { | |
setMatched[i] = pop.call(results); | |
} | |
} | |
} | |
setMatched = condense(setMatched); | |
} | |
push.apply(results, setMatched); | |
if (outermost && !seed && setMatched.length > 0 && (matchedCount + setMatchers.length) > 1) { | |
Sizzle.uniqueSort(results); | |
} | |
} | |
if (outermost) { | |
dirruns = dirrunsUnique; | |
outermostContext = contextBackup; | |
} | |
return unmatched; | |
}; | |
return bySet ? markFunction(superMatcher) : superMatcher; | |
} | |
compile = Sizzle.compile = function (selector, group) { | |
var i, setMatchers = [], | |
elementMatchers = [], | |
cached = compilerCache[selector + " "]; | |
if (!cached) { | |
if (!group) { | |
group = tokenize(selector); | |
} | |
i = group.length; | |
while (i--) { | |
cached = matcherFromTokens(group[i]); | |
if (cached[expando]) { | |
setMatchers.push(cached); | |
} else { | |
elementMatchers.push(cached); | |
} | |
} | |
cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers)); | |
} | |
return cached; | |
}; | |
function multipleContexts(selector, contexts, results) { | |
var i = 0, | |
len = contexts.length; | |
for (; i < len; i++) { | |
Sizzle(selector, contexts[i], results); | |
} | |
return results; | |
} | |
function select(selector, context, results, seed) { | |
var i, tokens, token, type, find, match = tokenize(selector); | |
if (!seed) { | |
if (match.length === 1) { | |
tokens = match[0] = match[0].slice(0); | |
if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) { | |
context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0]; | |
if (!context) { | |
return results; | |
} | |
selector = selector.slice(tokens.shift().value.length); | |
} | |
i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length; | |
while (i--) { | |
token = tokens[i]; | |
if (Expr.relative[(type = token.type)]) { | |
break; | |
} | |
if ((find = Expr.find[type])) { | |
if ((seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && context.parentNode || context))) { | |
tokens.splice(i, 1); | |
selector = seed.length && toSelector(tokens); | |
if (!selector) { | |
push.apply(results, seed); | |
return results; | |
} | |
break; | |
} | |
} | |
} | |
} | |
} | |
compile(selector, match)(seed, context, !documentIsHTML, results, rsibling.test(selector)); | |
return results; | |
} | |
Expr.pseudos["nth"] = Expr.pseudos["eq"]; | |
function setFilters() {} | |
setFilters.prototype = Expr.filters = Expr.pseudos; | |
Expr.setFilters = new setFilters(); | |
support.sortStable = expando.split("").sort(sortOrder).join("") === expando; | |
setDocument(); | |
[0, 0].sort(sortOrder); | |
support.detectDuplicates = hasDuplicate; | |
assert(function (div) { | |
div.innerHTML = "<a href='#'></a>"; | |
if (div.firstChild.getAttribute("href") !== "#") { | |
var attrs = "type|href|height|width".split("|"), | |
i = attrs.length; | |
while (i--) { | |
Expr.attrHandle[attrs[i]] = interpolationHandler; | |
} | |
} | |
}); | |
assert(function (div) { | |
if (div.getAttribute("disabled") != null) { | |
var attrs = booleans.split("|"), | |
i = attrs.length; | |
while (i--) { | |
Expr.attrHandle[attrs[i]] = boolHandler; | |
} | |
} | |
}); | |
jQuery.find = Sizzle; | |
jQuery.expr = Sizzle.selectors; | |
jQuery.expr[":"] = jQuery.expr.pseudos; | |
jQuery.unique = Sizzle.uniqueSort; | |
jQuery.text = Sizzle.getText; | |
jQuery.isXMLDoc = Sizzle.isXML; | |
jQuery.contains = Sizzle.contains; | |
})(window); | |
var optionsCache = {}; | |
function createOptions(options) { | |
var object = optionsCache[options] = {}; | |
jQuery.each(options.match(core_rnotwhite) || [], function (_, flag) { | |
object[flag] = true; | |
}); | |
return object; | |
} | |
jQuery.Callbacks = function (options) { | |
options = typeof options === "string" ? (optionsCache[options] || createOptions(options)) : jQuery.extend({}, options); | |
var | |
memory, fired, firing, firingStart, firingLength, firingIndex, list = [], | |
stack = !options.once && [], | |
fire = function (data) { | |
memory = options.memory && data; | |
fired = true; | |
firingIndex = firingStart || 0; | |
firingStart = 0; | |
firingLength = list.length; | |
firing = true; | |
for (; list && firingIndex < firingLength; firingIndex++) { | |
if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) { | |
memory = false; | |
break; | |
} | |
} | |
firing = false; | |
if (list) { | |
if (stack) { | |
if (stack.length) { | |
fire(stack.shift()); | |
} | |
} else if (memory) { | |
list = []; | |
} else { | |
self.disable(); | |
} | |
} | |
}, self = { | |
add: function () { | |
if (list) { | |
var start = list.length; | |
(function add(args) { | |
jQuery.each(args, function (_, arg) { | |
var type = jQuery.type(arg); | |
if (type === "function") { | |
if (!options.unique || !self.has(arg)) { | |
list.push(arg); | |
} | |
} else if (arg && arg.length && type !== "string") { | |
add(arg); | |
} | |
}); | |
})(arguments); | |
if (firing) { | |
firingLength = list.length; | |
} else if (memory) { | |
firingStart = start; | |
fire(memory); | |
} | |
} | |
return this; | |
}, | |
remove: function () { | |
if (list) { | |
jQuery.each(arguments, function (_, arg) { | |
var index; | |
while ((index = jQuery.inArray(arg, list, index)) > -1) { | |
list.splice(index, 1); | |
if (firing) { | |
if (index <= firingLength) { | |
firingLength--; | |
} | |
if (index <= firingIndex) { | |
firingIndex--; | |
} | |
} | |
} | |
}); | |
} | |
return this; | |
}, | |
has: function (fn) { | |
return fn ? jQuery.inArray(fn, list) > -1 : !! (list && list.length); | |
}, | |
empty: function () { | |
list = []; | |
firingLength = 0; | |
return this; | |
}, | |
disable: function () { | |
list = stack = memory = undefined; | |
return this; | |
}, | |
disabled: function () { | |
return !list; | |
}, | |
lock: function () { | |
stack = undefined; | |
if (!memory) { | |
self.disable(); | |
} | |
return this; | |
}, | |
locked: function () { | |
return !stack; | |
}, | |
fireWith: function (context, args) { | |
args = args || []; | |
args = [context, args.slice ? args.slice() : args]; | |
if (list && (!fired || stack)) { | |
if (firing) { | |
stack.push(args); | |
} else { | |
fire(args); | |
} | |
} | |
return this; | |
}, | |
fire: function () { | |
self.fireWith(this, arguments); | |
return this; | |
}, | |
fired: function () { | |
return !!fired; | |
} | |
}; | |
return self; | |
}; | |
jQuery.extend({ | |
Deferred: function (func) { | |
var tuples = [ | |
["resolve", "done", jQuery.Callbacks("once memory"), "resolved"], | |
["reject", "fail", jQuery.Callbacks("once memory"), "rejected"], | |
["notify", "progress", jQuery.Callbacks("memory")] | |
], | |
state = "pending", | |
promise = { | |
state: function () { | |
return state; | |
}, | |
always: function () { | |
deferred.done(arguments).fail(arguments); | |
return this; | |
}, | |
then: function () { | |
var fns = arguments; | |
return jQuery.Deferred(function (newDefer) { | |
jQuery.each(tuples, function (i, tuple) { | |
var action = tuple[0], | |
fn = jQuery.isFunction(fns[i]) && fns[i]; | |
deferred[tuple[1]](function () { | |
var returned = fn && fn.apply(this, arguments); | |
if (returned && jQuery.isFunction(returned.promise)) { | |
returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify); | |
} else { | |
newDefer[action + "With"](this === promise ? newDefer.promise() : this, fn ? [returned] : arguments); | |
} | |
}); | |
}); | |
fns = null; | |
}).promise(); | |
}, | |
promise: function (obj) { | |
return obj != null ? jQuery.extend(obj, promise) : promise; | |
} | |
}, deferred = {}; | |
promise.pipe = promise.then; | |
jQuery.each(tuples, function (i, tuple) { | |
var list = tuple[2], | |
stateString = tuple[3]; | |
promise[tuple[1]] = list.add; | |
if (stateString) { | |
list.add(function () { | |
state = stateString; | |
}, tuples[i ^ 1][2].disable, tuples[2][2].lock); | |
} | |
deferred[tuple[0]] = function () { | |
deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments); | |
return this; | |
}; | |
deferred[tuple[0] + "With"] = list.fireWith; | |
}); | |
promise.promise(deferred); | |
if (func) { | |
func.call(deferred, deferred); | |
} | |
return deferred; | |
}, | |
when: function (subordinate) { | |
var i = 0, | |
resolveValues = core_slice.call(arguments), | |
length = resolveValues.length, | |
remaining = length !== 1 || (subordinate && jQuery.isFunction(subordinate.promise)) ? length : 0, | |
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), | |
updateFunc = function (i, contexts, values) { | |
return function (value) { | |
contexts[i] = this; | |
values[i] = arguments.length > 1 ? core_slice.call(arguments) : value; | |
if (values === progressValues) { | |
deferred.notifyWith(contexts, values); | |
} else if (!(--remaining)) { | |
deferred.resolveWith(contexts, values); | |
} | |
}; | |
}, progressValues, progressContexts, resolveContexts; | |
if (length > 1) { | |
progressValues = new Array(length); | |
progressContexts = new Array(length); | |
resolveContexts = new Array(length); | |
for (; i < length; i++) { | |
if (resolveValues[i] && jQuery.isFunction(resolveValues[i].promise)) { | |
resolveValues[i].promise().done(updateFunc(i, resolveContexts, resolveValues)).fail(deferred.reject).progress(updateFunc(i, progressContexts, progressValues)); | |
} else { | |
--remaining; | |
} | |
} | |
} | |
if (!remaining) { | |
deferred.resolveWith(resolveContexts, resolveValues); | |
} | |
return deferred.promise(); | |
} | |
}); | |
jQuery.support = (function (support) { | |
var input = document.createElement("input"), | |
fragment = document.createDocumentFragment(), | |
div = document.createElement("div"), | |
select = document.createElement("select"), | |
opt = select.appendChild(document.createElement("option")); | |
if (!input.type) { | |
return support; | |
} | |
input.type = "checkbox"; | |
support.checkOn = input.value !== ""; | |
support.optSelected = opt.selected; | |
support.reliableMarginRight = true; | |
support.boxSizingReliable = true; | |
support.pixelPosition = false; | |
input.checked = true; | |
support.noCloneChecked = input.cloneNode(true).checked; | |
select.disabled = true; | |
support.optDisabled = !opt.disabled; | |
input = document.createElement("input"); | |
input.value = "t"; | |
input.type = "radio"; | |
support.radioValue = input.value === "t"; | |
input.setAttribute("checked", "t"); | |
input.setAttribute("name", "t"); | |
fragment.appendChild(input); | |
support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; | |
support.focusinBubbles = "onfocusin" in window; | |
div.style.backgroundClip = "content-box"; | |
div.cloneNode(true).style.backgroundClip = ""; | |
support.clearCloneStyle = div.style.backgroundClip === "content-box"; | |
jQuery(function () { | |
var container, marginDiv, divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box", | |
body = document.getElementsByTagName("body")[0]; | |
if (!body) { | |
return; | |
} | |
container = document.createElement("div"); | |
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; | |
body.appendChild(container).appendChild(div); | |
div.innerHTML = ""; | |
div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%"; | |
jQuery.swap(body, body.style.zoom != null ? { | |
zoom: 1 | |
} : {}, function () { | |
support.boxSizing = div.offsetWidth === 4; | |
}); | |
if (window.getComputedStyle) { | |
support.pixelPosition = (window.getComputedStyle(div, null) || {}).top !== "1%"; | |
support.boxSizingReliable = (window.getComputedStyle(div, null) || { | |
width: "4px" | |
}).width === "4px"; | |
marginDiv = div.appendChild(document.createElement("div")); | |
marginDiv.style.cssText = div.style.cssText = divReset; | |
marginDiv.style.marginRight = marginDiv.style.width = "0"; | |
div.style.width = "1px"; | |
support.reliableMarginRight = !parseFloat((window.getComputedStyle(marginDiv, null) || {}).marginRight); | |
} | |
body.removeChild(container); | |
}); | |
return support; | |
})({}); | |
var data_user, data_priv, rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, | |
rmultiDash = /([A-Z])/g; | |
function Data() { | |
Object.defineProperty(this.cache = {}, 0, { | |
get: function () { | |
return {}; | |
} | |
}); | |
this.expando = jQuery.expando + Math.random(); | |
} | |
Data.uid = 1; | |
Data.accepts = function (owner) { | |
return owner.nodeType ? owner.nodeType === 1 || owner.nodeType === 9 : true; | |
}; | |
Data.prototype = { | |
key: function (owner) { | |
if (!Data.accepts(owner)) { | |
return 0; | |
} | |
var descriptor = {}, unlock = owner[this.expando]; | |
if (!unlock) { | |
unlock = Data.uid++; | |
try { | |
descriptor[this.expando] = { | |
value: unlock | |
}; | |
Object.defineProperties(owner, descriptor); | |
} catch (e) { | |
descriptor[this.expando] = unlock; | |
jQuery.extend(owner, descriptor); | |
} | |
} | |
if (!this.cache[unlock]) { | |
this.cache[unlock] = {}; | |
} | |
return unlock; | |
}, | |
set: function (owner, data, value) { | |
var prop, unlock = this.key(owner), | |
cache = this.cache[unlock]; | |
if (typeof data === "string") { | |
cache[data] = value; | |
} else { | |
if (jQuery.isEmptyObject(cache)) { | |
this.cache[unlock] = data; | |
} else { | |
for (prop in data) { | |
cache[prop] = data[prop]; | |
} | |
} | |
} | |
}, | |
get: function (owner, key) { | |
var cache = this.cache[this.key(owner)]; | |
return key === undefined ? cache : cache[key]; | |
}, | |
access: function (owner, key, value) { | |
if (key === undefined || ((key && typeof key === "string") && value === undefined)) { | |
return this.get(owner, key); | |
} | |
this.set(owner, key, value); | |
return value !== undefined ? value : key; | |
}, | |
remove: function (owner, key) { | |
var i, name, unlock = this.key(owner), | |
cache = this.cache[unlock]; | |
if (key === undefined) { | |
this.cache[unlock] = {}; | |
} else { | |
if (jQuery.isArray(key)) { | |
name = key.concat(key.map(jQuery.camelCase)); | |
} else { | |
if (key in cache) { | |
name = [key]; | |
} else { | |
name = jQuery.camelCase(key); | |
name = name in cache ? [name] : (name.match(core_rnotwhite) || []); | |
} | |
} | |
i = name.length; | |
while (i--) { | |
delete cache[name[i]]; | |
} | |
} | |
}, | |
hasData: function (owner) { | |
return !jQuery.isEmptyObject(this.cache[owner[this.expando]] || {}); | |
}, | |
discard: function (owner) { | |
delete this.cache[this.key(owner)]; | |
} | |
}; | |
data_user = new Data(); | |
data_priv = new Data(); | |
jQuery.extend({ | |
acceptData: Data.accepts, | |
hasData: function (elem) { | |
return data_user.hasData(elem) || data_priv.hasData(elem); | |
}, | |
data: function (elem, name, data) { | |
return data_user.access(elem, name, data); | |
}, | |
removeData: function (elem, name) { | |
data_user.remove(elem, name); | |
}, | |
_data: function (elem, name, data) { | |
return data_priv.access(elem, name, data); | |
}, | |
_removeData: function (elem, name) { | |
data_priv.remove(elem, name); | |
} | |
}); | |
jQuery.fn.extend({ | |
data: function (key, value) { | |
var attrs, name, elem = this[0], | |
i = 0, | |
data = null; | |
if (key === undefined) { | |
if (this.length) { | |
data = data_user.get(elem); | |
if (elem.nodeType === 1 && !data_priv.get(elem, "hasDataAttrs")) { | |
attrs = elem.attributes; | |
for (; i < attrs.length; i++) { | |
name = attrs[i].name; | |
if (name.indexOf("data-") === 0) { | |
name = jQuery.camelCase(name.substring(5)); | |
dataAttr(elem, name, data[name]); | |
} | |
} | |
data_priv.set(elem, "hasDataAttrs", true); | |
} | |
} | |
return data; | |
} | |
if (typeof key === "object") { | |
return this.each(function () { | |
data_user.set(this, key); | |
}); | |
} | |
return jQuery.access(this, function (value) { | |
var data, camelKey = jQuery.camelCase(key); | |
if (elem && value === undefined) { | |
data = data_user.get(elem, key); | |
if (data !== undefined) { | |
return data; | |
} | |
data = data_user.get(elem, camelKey); | |
if (data !== undefined) { | |
return data; | |
} | |
data = dataAttr(elem, camelKey, undefined); | |
if (data !== undefined) { | |
return data; | |
} | |
return; | |
} | |
this.each(function () { | |
var data = data_user.get(this, camelKey); | |
data_user.set(this, camelKey, value); | |
if (key.indexOf("-") !== -1 && data !== undefined) { | |
data_user.set(this, key, value); | |
} | |
}); | |
}, null, value, arguments.length > 1, null, true); | |
}, | |
removeData: function (key) { | |
return this.each(function () { | |
data_user.remove(this, key); | |
}); | |
} | |
}); | |
function dataAttr(elem, key, data) { | |
var name; | |
if (data === undefined && elem.nodeType === 1) { | |
name = "data-" + key.replace(rmultiDash, "-$1").toLowerCase(); | |
data = elem.getAttribute(name); | |
if (typeof data === "string") { | |
try { | |
data = data === "true" ? true : data === "false" ? false : data === "null" ? null : +data + "" === data ? +data : rbrace.test(data) ? JSON.parse(data) : data; | |
} catch (e) {} | |
data_user.set(elem, key, data); | |
} else { | |
data = undefined; | |
} | |
} | |
return data; | |
} | |
jQuery.extend({ | |
queue: function (elem, type, data) { | |
var queue; | |
if (elem) { | |
type = (type || "fx") + "queue"; | |
queue = data_priv.get(elem, type); | |
if (data) { | |
if (!queue || jQuery.isArray(data)) { | |
queue = data_priv.access(elem, type, jQuery.makeArray(data)); | |
} else { | |
queue.push(data); | |
} | |
} | |
return queue || []; | |
} | |
}, | |
dequeue: function (elem, type) { | |
type = type || "fx"; | |
var queue = jQuery.queue(elem, type), | |
startLength = queue.length, | |
fn = queue.shift(), | |
hooks = jQuery._queueHooks(elem, type), | |
next = function () { | |
jQuery.dequeue(elem, type); | |
}; | |
if (fn === "inprogress") { | |
fn = queue.shift(); | |
startLength--; | |
} | |
hooks.cur = fn; | |
if (fn) { | |
if (type === "fx") { | |
queue.unshift("inprogress"); | |
} | |
delete hooks.stop; | |
fn.call(elem, next, hooks); | |
} | |
if (!startLength && hooks) { | |
hooks.empty.fire(); | |
} | |
}, | |
_queueHooks: function (elem, type) { | |
var key = type + "queueHooks"; | |
return data_priv.get(elem, key) || data_priv.access(elem, key, { | |
empty: jQuery.Callbacks("once memory").add(function () { | |
data_priv.remove(elem, [type + "queue", key]); | |
}) | |
}); | |
} | |
}); | |
jQuery.fn.extend({ | |
queue: function (type, data) { | |
var setter = 2; | |
if (typeof type !== "string") { | |
data = type; | |
type = "fx"; | |
setter--; | |
} | |
if (arguments.length < setter) { | |
return jQuery.queue(this[0], type); | |
} | |
return data === undefined ? this : this.each(function () { | |
var queue = jQuery.queue(this, type, data); | |
jQuery._queueHooks(this, type); | |
if (type === "fx" && queue[0] !== "inprogress") { | |
jQuery.dequeue(this, type); | |
} | |
}); | |
}, | |
dequeue: function (type) { | |
return this.each(function () { | |
jQuery.dequeue(this, type); | |
}); | |
}, | |
delay: function (time, type) { | |
time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; | |
type = type || "fx"; | |
return this.queue(type, function (next, hooks) { | |
var timeout = setTimeout(next, time); | |
hooks.stop = function () { | |
clearTimeout(timeout); | |
}; | |
}); | |
}, | |
clearQueue: function (type) { | |
return this.queue(type || "fx", []); | |
}, | |
promise: function (type, obj) { | |
var tmp, count = 1, | |
defer = jQuery.Deferred(), | |
elements = this, | |
i = this.length, | |
resolve = function () { | |
if (!(--count)) { | |
defer.resolveWith(elements, [elements]); | |
} | |
}; | |
if (typeof type !== "string") { | |
obj = type; | |
type = undefined; | |
} | |
type = type || "fx"; | |
while (i--) { | |
tmp = data_priv.get(elements[i], type + "queueHooks"); | |
if (tmp && tmp.empty) { | |
count++; | |
tmp.empty.add(resolve); | |
} | |
} | |
resolve(); | |
return defer.promise(obj); | |
} | |
}); | |
var nodeHook, boolHook, rclass = /[\t\r\n]/g, | |
rreturn = /\r/g, | |
rfocusable = /^(?:input|select|textarea|button)$/i; | |
jQuery.fn.extend({ | |
attr: function (name, value) { | |
return jQuery.access(this, jQuery.attr, name, value, arguments.length > 1); | |
}, | |
removeAttr: function (name) { | |
return this.each(function () { | |
jQuery.removeAttr(this, name); | |
}); | |
}, | |
prop: function (name, value) { | |
return jQuery.access(this, jQuery.prop, name, value, arguments.length > 1); | |
}, | |
removeProp: function (name) { | |
return this.each(function () { | |
delete this[jQuery.propFix[name] || name]; | |
}); | |
}, | |
addClass: function (value) { | |
var classes, elem, cur, clazz, j, i = 0, | |
len = this.length, | |
proceed = typeof value === "string" && value; | |
if (jQuery.isFunction(value)) { | |
return this.each(function (j) { | |
jQuery(this).addClass(value.call(this, j, this.className)); | |
}); | |
} | |
if (proceed) { | |
classes = (value || "").match(core_rnotwhite) || []; | |
for (; i < len; i++) { | |
elem = this[i]; | |
cur = elem.nodeType === 1 && (elem.className ? (" " + elem.className + " ").replace(rclass, " ") : " "); | |
if (cur) { | |
j = 0; | |
while ((clazz = classes[j++])) { | |
if (cur.indexOf(" " + clazz + " ") < 0) { | |
cur += clazz + " "; | |
} | |
} | |
elem.className = jQuery.trim(cur); | |
} | |
} | |
} | |
return this; | |
}, | |
removeClass: function (value) { | |
var classes, elem, cur, clazz, j, i = 0, | |
len = this.length, | |
proceed = arguments.length === 0 || typeof value === "string" && value; | |
if (jQuery.isFunction(value)) { | |
return this.each(function (j) { | |
jQuery(this).removeClass(value.call(this, j, this.className)); | |
}); | |
} | |
if (proceed) { | |
classes = (value || "").match(core_rnotwhite) || []; | |
for (; i < len; i++) { | |
elem = this[i]; | |
cur = elem.nodeType === 1 && (elem.className ? (" " + elem.className + " ").replace(rclass, " ") : ""); | |
if (cur) { | |
j = 0; | |
while ((clazz = classes[j++])) { | |
while (cur.indexOf(" " + clazz + " ") >= 0) { | |
cur = cur.replace(" " + clazz + " ", " "); | |
} | |
} | |
elem.className = value ? jQuery.trim(cur) : ""; | |
} | |
} | |
} | |
return this; | |
}, | |
toggleClass: function (value, stateVal) { | |
var type = typeof value, | |
isBool = typeof stateVal === "boolean"; | |
if (jQuery.isFunction(value)) { | |
return this.each(function (i) { | |
jQuery(this).toggleClass(value.call(this, i, this.className, stateVal), stateVal); | |
}); | |
} | |
return this.each(function () { | |
if (type === "string") { | |
var className, i = 0, | |
self = jQuery(this), | |
state = stateVal, | |
classNames = value.match(core_rnotwhite) || []; | |
while ((className = classNames[i++])) { | |
state = isBool ? state : !self.hasClass(className); | |
self[state ? "addClass" : "removeClass"](className); | |
} | |
} else if (type === core_strundefined || type === "boolean") { | |
if (this.className) { | |
data_priv.set(this, "__className__", this.className); | |
} | |
this.className = this.className || value === false ? "" : data_priv.get(this, "__className__") || ""; | |
} | |
}); | |
}, | |
hasClass: function (selector) { | |
var className = " " + selector + " ", | |
i = 0, | |
l = this.length; | |
for (; i < l; i++) { | |
if (this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf(className) >= 0) { | |
return true; | |
} | |
} | |
return false; | |
}, | |
val: function (value) { | |
var hooks, ret, isFunction, elem = this[0]; | |
if (!arguments.length) { | |
if (elem) { | |
hooks = jQuery.valHooks[elem.type] || jQuery.valHooks[elem.nodeName.toLowerCase()]; | |
if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) { | |
return ret; | |
} | |
ret = elem.value; | |
return typeof ret === "string" ? ret.replace(rreturn, "") : ret == null ? "" : ret; | |
} | |
return; | |
} | |
isFunction = jQuery.isFunction(value); | |
return this.each(function (i) { | |
var val, self = jQuery(this); | |
if (this.nodeType !== 1) { | |
return; | |
} | |
if (isFunction) { | |
val = value.call(this, i, self.val()); | |
} else { | |
val = value; | |
} | |
if (val == null) { | |
val = ""; | |
} else if (typeof val === "number") { | |
val += ""; | |
} else if (jQuery.isArray(val)) { | |
val = jQuery.map(val, function (value) { | |
return value == null ? "" : value + ""; | |
}); | |
} | |
hooks = jQuery.valHooks[this.type] || jQuery.valHooks[this.nodeName.toLowerCase()]; | |
if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) { | |
this.value = val; | |
} | |
}); | |
} | |
}); | |
jQuery.extend({ | |
valHooks: { | |
option: { | |
get: function (elem) { | |
var val = elem.attributes.value; | |
return !val || val.specified ? elem.value : elem.text; | |
} | |
}, | |
select: { | |
get: function (elem) { | |
var value, option, options = elem.options, | |
index = elem.selectedIndex, | |
one = elem.type === "select-one" || index < 0, | |
values = one ? null : [], | |
max = one ? index + 1 : options.length, | |
i = index < 0 ? max : one ? index : 0; | |
for (; i < max; i++) { | |
option = options[i]; | |
if ((option.selected || i === index) && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && (!option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup"))) { | |
value = jQuery(option).val(); | |
if (one) { | |
return value; | |
} | |
values.push(value); | |
} | |
} | |
return values; | |
}, | |
set: function (elem, value) { | |
var optionSet, option, options = elem.options, | |
values = jQuery.makeArray(value), | |
i = options.length; | |
while (i--) { | |
option = options[i]; | |
if ((option.selected = jQuery.inArray(jQuery(option).val(), values) >= 0)) { | |
optionSet = true; | |
} | |
} | |
if (!optionSet) { | |
elem.selectedIndex = -1; | |
} | |
return values; | |
} | |
} | |
}, | |
attr: function (elem, name, value) { | |
var hooks, ret, nType = elem.nodeType; | |
if (!elem || nType === 3 || nType === 8 || nType === 2) { | |
return; | |
} | |
if (typeof elem.getAttribute === core_strundefined) { | |
return jQuery.prop(elem, name, value); | |
} | |
if (nType !== 1 || !jQuery.isXMLDoc(elem)) { | |
name = name.toLowerCase(); | |
hooks = jQuery.attrHooks[name] || (jQuery.expr.match.boolean.test(name) ? boolHook : nodeHook); | |
} | |
if (value !== undefined) { | |
if (value === null) { | |
jQuery.removeAttr(elem, name); | |
} else if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) { | |
return ret; | |
} else { | |
elem.setAttribute(name, value + ""); | |
return value; | |
} | |
} else if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) { | |
return ret; | |
} else { | |
ret = jQuery.find.attr(elem, name); | |
return ret == null ? undefined : ret; | |
} | |
}, | |
removeAttr: function (elem, value) { | |
var name, propName, i = 0, | |
attrNames = value && value.match(core_rnotwhite); | |
if (attrNames && elem.nodeType === 1) { | |
while ((name = attrNames[i++])) { | |
propName = jQuery.propFix[name] || name; | |
if (jQuery.expr.match.boolean.test(name)) { | |
elem[propName] = false; | |
} | |
elem.removeAttribute(name); | |
} | |
} | |
}, | |
attrHooks: { | |
type: { | |
set: function (elem, value) { | |
if (!jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input")) { | |
var val = elem.value; | |
elem.setAttribute("type", value); | |
if (val) { | |
elem.value = val; | |
} | |
return value; | |
} | |
} | |
} | |
}, | |
propFix: { | |
"for": "htmlFor", | |
"class": "className" | |
}, | |
prop: function (elem, name, value) { | |
var ret, hooks, notxml, nType = elem.nodeType; | |
if (!elem || nType === 3 || nType === 8 || nType === 2) { | |
return; | |
} | |
notxml = nType !== 1 || !jQuery.isXMLDoc(elem); | |
if (notxml) { | |
name = jQuery.propFix[name] || name; | |
hooks = jQuery.propHooks[name]; | |
} | |
if (value !== undefined) { | |
return hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined ? ret : (elem[name] = value); | |
} else { | |
return hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null ? ret : elem[name]; | |
} | |
}, | |
propHooks: { | |
tabIndex: { | |
get: function (elem) { | |
return elem.hasAttribute("tabindex") || rfocusable.test(elem.nodeName) || elem.href ? elem.tabIndex : -1; | |
} | |
} | |
} | |
}); | |
boolHook = { | |
set: function (elem, value, name) { | |
if (value === false) { | |
jQuery.removeAttr(elem, name); | |
} else { | |
elem.setAttribute(name, name); | |
} | |
return name; | |
} | |
}; | |
jQuery.each(jQuery.expr.match.boolean.source.match(/\w+/g), function (i, name) { | |
var getter = jQuery.expr.attrHandle[name] || jQuery.find.attr; | |
jQuery.expr.attrHandle[name] = function (elem, name, isXML) { | |
var fn = jQuery.expr.attrHandle[name], | |
ret = isXML ? undefined : (jQuery.expr.attrHandle[name] = undefined) != getter(elem, name, isXML) ? name.toLowerCase() : null; | |
jQuery.expr.attrHandle[name] = fn; | |
return ret; | |
}; | |
}); | |
if (!jQuery.support.optSelected) { | |
jQuery.propHooks.selected = { | |
get: function (elem) { | |
var parent = elem.parentNode; | |
if (parent && parent.parentNode) { | |
parent.parentNode.selectedIndex; | |
} | |
return null; | |
} | |
}; | |
} | |
jQuery.each(["tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable"], function () { | |
jQuery.propFix[this.toLowerCase()] = this; | |
}); | |
jQuery.each(["radio", "checkbox"], function () { | |
jQuery.valHooks[this] = { | |
set: function (elem, value) { | |
if (jQuery.isArray(value)) { | |
return (elem.checked = jQuery.inArray(jQuery(elem).val(), value) >= 0); | |
} | |
} | |
}; | |
if (!jQuery.support.checkOn) { | |
jQuery.valHooks[this].get = function (elem) { | |
return elem.getAttribute("value") === null ? "on" : elem.value; | |
}; | |
} | |
}); | |
var rkeyEvent = /^key/, | |
rmouseEvent = /^(?:mouse|contextmenu)|click/, | |
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | |
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; | |
function returnTrue() { | |
return true; | |
} | |
function returnFalse() { | |
return false; | |
} | |
function safeActiveElement() { | |
try { | |
return document.activeElement; | |
} catch (err) {} | |
} | |
jQuery.event = { | |
global: {}, | |
add: function (elem, types, handler, data, selector) { | |
var handleObjIn, eventHandle, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = data_priv.get(elem); | |
if (!elemData) { | |
return; | |
} | |
if (handler.handler) { | |
handleObjIn = handler; | |
handler = handleObjIn.handler; | |
selector = handleObjIn.selector; | |
} | |
if (!handler.guid) { | |
handler.guid = jQuery.guid++; | |
} | |
if (!(events = elemData.events)) { | |
events = elemData.events = {}; | |
} | |
if (!(eventHandle = elemData.handle)) { | |
eventHandle = elemData.handle = function (e) { | |
return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.dispatch.apply(eventHandle.elem, arguments) : undefined; | |
}; | |
eventHandle.elem = elem; | |
} | |
types = (types || "").match(core_rnotwhite) || [""]; | |
t = types.length; | |
while (t--) { | |
tmp = rtypenamespace.exec(types[t]) || []; | |
type = origType = tmp[1]; | |
namespaces = (tmp[2] || "").split(".").sort(); | |
if (!type) { | |
continue; | |
} | |
special = jQuery.event.special[type] || {}; | |
type = (selector ? special.delegateType : special.bindType) || type; | |
special = jQuery.event.special[type] || {}; | |
handleObj = jQuery.extend({ | |
type: type, | |
origType: origType, | |
data: data, | |
handler: handler, | |
guid: handler.guid, | |
selector: selector, | |
needsContext: selector && jQuery.expr.match.needsContext.test(selector), | |
namespace: namespaces.join(".") | |
}, handleObjIn); | |
if (!(handlers = events[type])) { | |
handlers = events[type] = []; | |
handlers.delegateCount = 0; | |
if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) { | |
if (elem.addEventListener) { | |
elem.addEventListener(type, eventHandle, false); | |
} | |
} | |
} | |
if (special.add) { | |
special.add.call(elem, handleObj); | |
if (!handleObj.handler.guid) { | |
handleObj.handler.guid = handler.guid; | |
} | |
} | |
if (selector) { | |
handlers.splice(handlers.delegateCount++, 0, handleObj); | |
} else { | |
handlers.push(handleObj); | |
} | |
jQuery.event.global[type] = true; | |
} | |
elem = null; | |
}, | |
remove: function (elem, types, handler, selector, mappedTypes) { | |
var j, origCount, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = data_priv.hasData(elem) && data_priv.get(elem); | |
if (!elemData || !(events = elemData.events)) { | |
return; | |
} | |
types = (types || "").match(core_rnotwhite) || [""]; | |
t = types.length; | |
while (t--) { | |
tmp = rtypenamespace.exec(types[t]) || []; | |
type = origType = tmp[1]; | |
namespaces = (tmp[2] || "").split(".").sort(); | |
if (!type) { | |
for (type in events) { | |
jQuery.event.remove(elem, type + types[t], handler, selector, true); | |
} | |
continue; | |
} | |
special = jQuery.event.special[type] || {}; | |
type = (selector ? special.delegateType : special.bindType) || type; | |
handlers = events[type] || []; | |
tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)"); | |
origCount = j = handlers.length; | |
while (j--) { | |
handleObj = handlers[j]; | |
if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector)) { | |
handlers.splice(j, 1); | |
if (handleObj.selector) { | |
handlers.delegateCount--; | |
} | |
if (special.remove) { | |
special.remove.call(elem, handleObj); | |
} | |
} | |
} | |
if (origCount && !handlers.length) { | |
if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) { | |
jQuery.removeEvent(elem, type, elemData.handle); | |
} | |
delete events[type]; | |
} | |
} | |
if (jQuery.isEmptyObject(events)) { | |
delete elemData.handle; | |
data_priv.remove(elem, "events"); | |
} | |
}, | |
trigger: function (event, data, elem, onlyHandlers) { | |
var i, cur, tmp, bubbleType, ontype, handle, special, eventPath = [elem || document], | |
type = core_hasOwn.call(event, "type") ? event.type : event, | |
namespaces = core_hasOwn.call(event, "namespace") ? event.namespace.split(".") : []; | |
cur = tmp = elem = elem || document; | |
if (elem.nodeType === 3 || elem.nodeType === 8) { | |
return; | |
} | |
if (rfocusMorph.test(type + jQuery.event.triggered)) { | |
return; | |
} | |
if (type.indexOf(".") >= 0) { | |
namespaces = type.split("."); | |
type = namespaces.shift(); | |
namespaces.sort(); | |
} | |
ontype = type.indexOf(":") < 0 && "on" + type; | |
event = event[jQuery.expando] ? event : new jQuery.Event(type, typeof event === "object" && event); | |
event.isTrigger = onlyHandlers ? 2 : 3; | |
event.namespace = namespaces.join("."); | |
event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; | |
event.result = undefined; | |
if (!event.target) { | |
event.target = elem; | |
} | |
data = data == null ? [event] : jQuery.makeArray(data, [event]); | |
special = jQuery.event.special[type] || {}; | |
if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) { | |
return; | |
} | |
if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) { | |
bubbleType = special.delegateType || type; | |
if (!rfocusMorph.test(bubbleType + type)) { | |
cur = cur.parentNode; | |
} | |
for (; cur; cur = cur.parentNode) { | |
eventPath.push(cur); | |
tmp = cur; | |
} | |
if (tmp === (elem.ownerDocument || document)) { | |
eventPath.push(tmp.defaultView || tmp.parentWindow || window); | |
} | |
} | |
i = 0; | |
while ((cur = eventPath[i++]) && !event.isPropagationStopped()) { | |
event.type = i > 1 ? bubbleType : special.bindType || type; | |
handle = (data_priv.get(cur, "events") || {})[event.type] && data_priv.get(cur, "handle"); | |
if (handle) { | |
handle.apply(cur, data); | |
} | |
handle = ontype && cur[ontype]; | |
if (handle && jQuery.acceptData(cur) && handle.apply && handle.apply(cur, data) === false) { | |
event.preventDefault(); | |
} | |
} | |
event.type = type; | |
if (!onlyHandlers && !event.isDefaultPrevented()) { | |
if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && jQuery.acceptData(elem)) { | |
if (ontype && jQuery.isFunction(elem[type]) && !jQuery.isWindow(elem)) { | |
tmp = elem[ontype]; | |
if (tmp) { | |
elem[ontype] = null; | |
} | |
jQuery.event.triggered = type; | |
elem[type](); | |
jQuery.event.triggered = undefined; | |
if (tmp) { | |
elem[ontype] = tmp; | |
} | |
} | |
} | |
} | |
return event.result; | |
}, | |
dispatch: function (event) { | |
event = jQuery.event.fix(event); | |
var i, j, ret, matched, handleObj, handlerQueue = [], | |
args = core_slice.call(arguments), | |
handlers = (data_priv.get(this, "events") || {})[event.type] || [], | |
special = jQuery.event.special[event.type] || {}; | |
args[0] = event; | |
event.delegateTarget = this; | |
if (special.preDispatch && special.preDispatch.call(this, event) === false) { | |
return; | |
} | |
handlerQueue = jQuery.event.handlers.call(this, event, handlers); | |
i = 0; | |
while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) { | |
event.currentTarget = matched.elem; | |
j = 0; | |
while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) { | |
if (!event.namespace_re || event.namespace_re.test(handleObj.namespace)) { | |
event.handleObj = handleObj; | |
event.data = handleObj.data; | |
ret = ((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args); | |
if (ret !== undefined) { | |
if ((event.result = ret) === false) { | |
event.preventDefault(); | |
event.stopPropagation(); | |
} | |
} | |
} | |
} | |
} | |
if (special.postDispatch) { | |
special.postDispatch.call(this, event); | |
} | |
return event.result; | |
}, | |
handlers: function (event, handlers) { | |
var i, matches, sel, handleObj, handlerQueue = [], | |
delegateCount = handlers.delegateCount, | |
cur = event.target; | |
if (delegateCount && cur.nodeType && (!event.button || event.type !== "click")) { | |
for (; cur !== this; cur = cur.parentNode || this) { | |
if (cur.disabled !== true || event.type !== "click") { | |
matches = []; | |
for (i = 0; i < delegateCount; i++) { | |
handleObj = handlers[i]; | |
sel = handleObj.selector + " "; | |
if (matches[sel] === undefined) { | |
matches[sel] = handleObj.needsContext ? jQuery(sel, this).index(cur) >= 0 : jQuery.find(sel, this, null, [cur]).length; | |
} | |
if (matches[sel]) { | |
matches.push(handleObj); | |
} | |
} | |
if (matches.length) { | |
handlerQueue.push({ | |
elem: cur, | |
handlers: matches | |
}); | |
} | |
} | |
} | |
} | |
if (delegateCount < handlers.length) { | |
handlerQueue.push({ | |
elem: this, | |
handlers: handlers.slice(delegateCount) | |
}); | |
} | |
return handlerQueue; | |
}, | |
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), | |
fixHooks: {}, | |
keyHooks: { | |
props: "char charCode key keyCode".split(" "), | |
filter: function (event, original) { | |
if (event.which == null) { | |
event.which = original.charCode != null ? original.charCode : original.keyCode; | |
} | |
return event; | |
} | |
}, | |
mouseHooks: { | |
props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), | |
filter: function (event, original) { | |
var eventDoc, doc, body, button = original.button; | |
if (event.pageX == null && original.clientX != null) { | |
eventDoc = event.target.ownerDocument || document; | |
doc = eventDoc.documentElement; | |
body = eventDoc.body; | |
event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); | |
event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); | |
} | |
if (!event.which && button !== undefined) { | |
event.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0))); | |
} | |
return event; | |
} | |
}, | |
fix: function (event) { | |
if (event[jQuery.expando]) { | |
return event; | |
} | |
var i, prop, copy, type = event.type, | |
originalEvent = event, | |
fixHook = this.fixHooks[type]; | |
if (!fixHook) { | |
this.fixHooks[type] = fixHook = rmouseEvent.test(type) ? this.mouseHooks : rkeyEvent.test(type) ? this.keyHooks : {}; | |
} | |
copy = fixHook.props ? this.props.concat(fixHook.props) : this.props; | |
event = new jQuery.Event(originalEvent); | |
i = copy.length; | |
while (i--) { | |
prop = copy[i]; | |
event[prop] = originalEvent[prop]; | |
} | |
if (event.target.nodeType === 3) { | |
event.target = event.target.parentNode; | |
} | |
return fixHook.filter ? fixHook.filter(event, originalEvent) : event; | |
}, | |
special: { | |
load: { | |
noBubble: true | |
}, | |
focus: { | |
trigger: function () { | |
if (this !== safeActiveElement() && this.focus) { | |
this.focus(); | |
return false; | |
} | |
}, | |
delegateType: "focusin" | |
}, | |
blur: { | |
trigger: function () { | |
if (this === safeActiveElement() && this.blur) { | |
this.blur(); | |
return false; | |
} | |
}, | |
delegateType: "focusout" | |
}, | |
click: { | |
trigger: function () { | |
if (this.type === "checkbox" && this.click && jQuery.nodeName(this, "input")) { | |
this.click(); | |
return false; | |
} | |
}, | |
_default: function (event) { | |
return jQuery.nodeName(event.target, "a"); | |
} | |
}, | |
beforeunload: { | |
postDispatch: function (event) { | |
if (event.result !== undefined) { | |
event.originalEvent.returnValue = event.result; | |
} | |
} | |
} | |
}, | |
simulate: function (type, elem, event, bubble) { | |
var e = jQuery.extend(new jQuery.Event(), event, { | |
type: type, | |
isSimulated: true, | |
originalEvent: {} | |
}); | |
if (bubble) { | |
jQuery.event.trigger(e, null, elem); | |
} else { | |
jQuery.event.dispatch.call(elem, e); | |
} | |
if (e.isDefaultPrevented()) { | |
event.preventDefault(); | |
} | |
} | |
}; | |
jQuery.removeEvent = function (elem, type, handle) { | |
if (elem.removeEventListener) { | |
elem.removeEventListener(type, handle, false); | |
} | |
}; | |
jQuery.Event = function (src, props) { | |
if (!(this instanceof jQuery.Event)) { | |
return new jQuery.Event(src, props); | |
} | |
if (src && src.type) { | |
this.originalEvent = src; | |
this.type = src.type; | |
this.isDefaultPrevented = (src.defaultPrevented || src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; | |
} else { | |
this.type = src; | |
} | |
if (props) { | |
jQuery.extend(this, props); | |
} | |
this.timeStamp = src && src.timeStamp || jQuery.now(); | |
this[jQuery.expando] = true; | |
}; | |
jQuery.Event.prototype = { | |
isDefaultPrevented: returnFalse, | |
isPropagationStopped: returnFalse, | |
isImmediatePropagationStopped: returnFalse, | |
preventDefault: function () { | |
var e = this.originalEvent; | |
this.isDefaultPrevented = returnTrue; | |
if (e && e.preventDefault) { | |
e.preventDefault(); | |
} | |
}, | |
stopPropagation: function () { | |
var e = this.originalEvent; | |
this.isPropagationStopped = returnTrue; | |
if (e && e.stopPropagation) { | |
e.stopPropagation(); | |
} | |
}, | |
stopImmediatePropagation: function () { | |
this.isImmediatePropagationStopped = returnTrue; | |
this.stopPropagation(); | |
} | |
}; | |
jQuery.each({ | |
mouseenter: "mouseover", | |
mouseleave: "mouseout" | |
}, function (orig, fix) { | |
jQuery.event.special[orig] = { | |
delegateType: fix, | |
bindType: fix, | |
handle: function (event) { | |
var ret, target = this, | |
related = event.relatedTarget, | |
handleObj = event.handleObj; | |
if (!related || (related !== target && !jQuery.contains(target, related))) { | |
event.type = handleObj.origType; | |
ret = handleObj.handler.apply(this, arguments); | |
event.type = fix; | |
} | |
return ret; | |
} | |
}; | |
}); | |
if (!jQuery.support.focusinBubbles) { | |
jQuery.each({ | |
focus: "focusin", | |
blur: "focusout" | |
}, function (orig, fix) { | |
var attaches = 0, | |
handler = function (event) { | |
jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true); | |
}; | |
jQuery.event.special[fix] = { | |
setup: function () { | |
if (attaches++ === 0) { | |
document.addEventListener(orig, handler, true); | |
} | |
}, | |
teardown: function () { | |
if (--attaches === 0) { | |
document.removeEventListener(orig, handler, true); | |
} | |
} | |
}; | |
}); | |
} | |
jQuery.fn.extend({ | |
on: function (types, selector, data, fn, one) { | |
var origFn, type; | |
if (typeof types === "object") { | |
if (typeof selector !== "string") { | |
data = data || selector; | |
selector = undefined; | |
} | |
for (type in types) { | |
this.on(type, selector, data, types[type], one); | |
} | |
return this; | |
} | |
if (data == null && fn == null) { | |
fn = selector; | |
data = selector = undefined; | |
} else if (fn == null) { | |
if (typeof selector === "string") { | |
fn = data; | |
data = undefined; | |
} else { | |
fn = data; | |
data = selector; | |
selector = undefined; | |
} | |
} | |
if (fn === false) { | |
fn = returnFalse; | |
} else if (!fn) { | |
return this; | |
} | |
if (one === 1) { | |
origFn = fn; | |
fn = function (event) { | |
jQuery().off(event); | |
return origFn.apply(this, arguments); | |
}; | |
fn.guid = origFn.guid || (origFn.guid = jQuery.guid++); | |
} | |
return this.each(function () { | |
jQuery.event.add(this, types, fn, data, selector); | |
}); | |
}, | |
one: function (types, selector, data, fn) { | |
return this.on(types, selector, data, fn, 1); | |
}, | |
off: function (types, selector, fn) { | |
var handleObj, type; | |
if (types && types.preventDefault && types.handleObj) { | |
handleObj = types.handleObj; | |
jQuery(types.delegateTarget).off(handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler); | |
return this; | |
} | |
if (typeof types === "object") { | |
for (type in types) { | |
this.off(type, selector, types[type]); | |
} | |
return this; | |
} | |
if (selector === false || typeof selector === "function") { | |
fn = selector; | |
selector = undefined; | |
} | |
if (fn === false) { | |
fn = returnFalse; | |
} | |
return this.each(function () { | |
jQuery.event.remove(this, types, fn, selector); | |
}); | |
}, | |
trigger: function (type, data) { | |
return this.each(function () { | |
jQuery.event.trigger(type, data, this); | |
}); | |
}, | |
triggerHandler: function (type, data) { | |
var elem = this[0]; | |
if (elem) { | |
return jQuery.event.trigger(type, data, elem, true); | |
} | |
} | |
}); | |
var isSimple = /^.[^:#\[\.,]*$/, | |
rneedsContext = jQuery.expr.match.needsContext, | |
guaranteedUnique = { | |
children: true, | |
contents: true, | |
next: true, | |
prev: true | |
}; | |
jQuery.fn.extend({ | |
find: function (selector) { | |
var self, matched, i, l = this.length; | |
if (typeof selector !== "string") { | |
self = this; | |
return this.pushStack(jQuery(selector).filter(function () { | |
for (i = 0; i < l; i++) { | |
if (jQuery.contains(self[i], this)) { | |
return true; | |
} | |
} | |
})); | |
} | |
matched = []; | |
for (i = 0; i < l; i++) { | |
jQuery.find(selector, this[i], matched); | |
} | |
matched = this.pushStack(l > 1 ? jQuery.unique(matched) : matched); | |
matched.selector = (this.selector ? this.selector + " " : "") + selector; | |
return matched; | |
}, | |
has: function (target) { | |
var targets = jQuery(target, this), | |
l = targets.length; | |
return this.filter(function () { | |
var i = 0; | |
for (; i < l; i++) { | |
if (jQuery.contains(this, targets[i])) { | |
return true; | |
} | |
} | |
}); | |
}, | |
not: function (selector) { | |
return this.pushStack(winnow(this, selector || [], true)); | |
}, | |
filter: function (selector) { | |
return this.pushStack(winnow(this, selector || [], false)); | |
}, | |
is: function (selector) { | |
return !!selector && (typeof selector === "string" ? rneedsContext.test(selector) ? jQuery(selector, this.context).index(this[0]) >= 0 : jQuery.filter(selector, this).length > 0 : this.filter(selector).length > 0); | |
}, | |
closest: function (selectors, context) { | |
var cur, i = 0, | |
l = this.length, | |
matched = [], | |
pos = (rneedsContext.test(selectors) || typeof selectors !== "string") ? jQuery(selectors, context || this.context) : 0; | |
for (; i < l; i++) { | |
for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) { | |
if (cur.nodeType < 11 && (pos ? pos.index(cur) > -1 : cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors))) { | |
cur = matched.push(cur); | |
break; | |
} | |
} | |
} | |
return this.pushStack(matched.length > 1 ? jQuery.unique(matched) : matched); | |
}, | |
index: function (elem) { | |
if (!elem) { | |
return (this[0] && this[0].parentNode) ? this.first().prevAll().length : -1; | |
} | |
if (typeof elem === "string") { | |
return core_indexOf.call(jQuery(elem), this[0]); | |
} | |
return core_indexOf.call(this, elem.jquery ? elem[0] : elem); | |
}, | |
add: function (selector, context) { | |
var set = typeof selector === "string" ? jQuery(selector, context) : jQuery.makeArray(selector && selector.nodeType ? [selector] : selector), | |
all = jQuery.merge(this.get(), set); | |
return this.pushStack(jQuery.unique(all)); | |
}, | |
addBack: function (selector) { | |
return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector)); | |
} | |
}); | |
function sibling(cur, dir) { | |
while ((cur = cur[dir]) && cur.nodeType !== 1) {} | |
return cur; | |
} | |
jQuery.each({ | |
parent: function (elem) { | |
var parent = elem.parentNode; | |
return parent && parent.nodeType !== 11 ? parent : null; | |
}, | |
parents: function (elem) { | |
return jQuery.dir(elem, "parentNode"); | |
}, | |
parentsUntil: function (elem, i, until) { | |
return jQuery.dir(elem, "parentNode", until); | |
}, | |
next: function (elem) { | |
return sibling(elem, "nextSibling"); | |
}, | |
prev: function (elem) { | |
return sibling(elem, "previousSibling"); | |
}, | |
nextAll: function (elem) { | |
return jQuery.dir(elem, "nextSibling"); | |
}, | |
prevAll: function (elem) { | |
return jQuery.dir(elem, "previousSibling"); | |
}, | |
nextUntil: function (elem, i, until) { | |
return jQuery.dir(elem, "nextSibling", until); | |
}, | |
prevUntil: function (elem, i, until) { | |
return jQuery.dir(elem, "previousSibling", until); | |
}, | |
siblings: function (elem) { | |
return jQuery.sibling((elem.parentNode || {}).firstChild, elem); | |
}, | |
children: function (elem) { | |
return jQuery.sibling(elem.firstChild); | |
}, | |
contents: function (elem) { | |
return jQuery.nodeName(elem, "iframe") ? elem.contentDocument || elem.contentWindow.document : jQuery.merge([], elem.childNodes); | |
} | |
}, function (name, fn) { | |
jQuery.fn[name] = function (until, selector) { | |
var matched = jQuery.map(this, fn, until); | |
if (name.slice(-5) !== "Until") { | |
selector = until; | |
} | |
if (selector && typeof selector === "string") { | |
matched = jQuery.filter(selector, matched); | |
} | |
if (this.length > 1) { | |
if (!guaranteedUnique[name]) { | |
jQuery.unique(matched); | |
} | |
if (name[0] === "p") { | |
matched.reverse(); | |
} | |
} | |
return this.pushStack(matched); | |
}; | |
}); | |
jQuery.extend({ | |
filter: function (expr, elems, not) { | |
var elem = elems[0]; | |
if (not) { | |
expr = ":not(" + expr + ")"; | |
} | |
return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector(elem, expr) ? [elem] : [] : jQuery.find.matches(expr, jQuery.grep(elems, function (elem) { | |
return elem.nodeType === 1; | |
})); | |
}, | |
dir: function (elem, dir, until) { | |
var matched = [], | |
truncate = until !== undefined; | |
while ((elem = elem[dir]) && elem.nodeType !== 9) { | |
if (elem.nodeType === 1) { | |
if (truncate && jQuery(elem).is(until)) { | |
break; | |
} | |
matched.push(elem); | |
} | |
} | |
return matched; | |
}, | |
sibling: function (n, elem) { | |
var matched = []; | |
for (; n; n = n.nextSibling) { | |
if (n.nodeType === 1 && n !== elem) { | |
matched.push(n); | |
} | |
} | |
return matched; | |
} | |
}); | |
function winnow(elements, qualifier, not) { | |
if (jQuery.isFunction(qualifier)) { | |
return jQuery.grep(elements, function (elem, i) { | |
return !!qualifier.call(elem, i, elem) !== not; | |
}); | |
} | |
if (qualifier.nodeType) { | |
return jQuery.grep(elements, function (elem) { | |
return (elem === qualifier) !== not; | |
}); | |
} | |
if (typeof qualifier === "string") { | |
if (isSimple.test(qualifier)) { | |
return jQuery.filter(qualifier, elements, not); | |
} | |
qualifier = jQuery.filter(qualifier, elements); | |
} | |
return jQuery.grep(elements, function (elem) { | |
return (core_indexOf.call(qualifier, elem) >= 0) !== not; | |
}); | |
} | |
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, | |
rtagName = /<([\w:]+)/, | |
rhtml = /<|&#?\w+;/, | |
rnoInnerhtml = /<(?:script|style|link)/i, | |
manipulation_rcheckableType = /^(?:checkbox|radio)$/i, | |
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
rscriptType = /^$|\/(?:java|ecma)script/i, | |
rscriptTypeMasked = /^true\/(.*)/, | |
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, | |
wrapMap = { | |
option: [1, "<select multiple='multiple'>", "</select>"], | |
thead: [1, "<table>", "</table>"], | |
tr: [2, "<table><tbody>", "</tbody></table>"], | |
td: [3, "<table><tbody><tr>", "</tr></tbody></table>"], | |
_default: [0, "", ""] | |
}; | |
wrapMap.optgroup = wrapMap.option; | |
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.col = wrapMap.thead; | |
wrapMap.th = wrapMap.td; | |
jQuery.fn.extend({ | |
text: function (value) { | |
return jQuery.access(this, function (value) { | |
return value === undefined ? jQuery.text(this) : this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(value)); | |
}, null, value, arguments.length); | |
}, | |
append: function () { | |
return this.domManip(arguments, function (elem) { | |
if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { | |
var target = manipulationTarget(this, elem); | |
target.appendChild(elem); | |
} | |
}); | |
}, | |
prepend: function () { | |
return this.domManip(arguments, function (elem) { | |
if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { | |
var target = manipulationTarget(this, elem); | |
target.insertBefore(elem, target.firstChild); | |
} | |
}); | |
}, | |
before: function () { | |
return this.domManip(arguments, function (elem) { | |
if (this.parentNode) { | |
this.parentNode.insertBefore(elem, this); | |
} | |
}); | |
}, | |
after: function () { | |
return this.domManip(arguments, function (elem) { | |
if (this.parentNode) { | |
this.parentNode.insertBefore(elem, this.nextSibling); | |
} | |
}); | |
}, | |
remove: function (selector, keepData) { | |
var elem, elems = selector ? jQuery.filter(selector, this) : this, | |
i = 0; | |
for (; | |
(elem = elems[i]) != null; i++) { | |
if (!keepData && elem.nodeType === 1) { | |
jQuery.cleanData(getAll(elem)); | |
} | |
if (elem.parentNode) { | |
if (keepData && jQuery.contains(elem.ownerDocument, elem)) { | |
setGlobalEval(getAll(elem, "script")); | |
} | |
elem.parentNode.removeChild(elem); | |
} | |
} | |
return this; | |
}, | |
empty: function () { | |
var elem, i = 0; | |
for (; | |
(elem = this[i]) != null; i++) { | |
if (elem.nodeType === 1) { | |
jQuery.cleanData(getAll(elem, false)); | |
elem.textContent = ""; | |
} | |
} | |
return this; | |
}, | |
clone: function (dataAndEvents, deepDataAndEvents) { | |
dataAndEvents = dataAndEvents == null ? false : dataAndEvents; | |
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; | |
return this.map(function () { | |
return jQuery.clone(this, dataAndEvents, deepDataAndEvents); | |
}); | |
}, | |
html: function (value) { | |
return jQuery.access(this, function (value) { | |
var elem = this[0] || {}, i = 0, | |
l = this.length; | |
if (value === undefined && elem.nodeType === 1) { | |
return elem.innerHTML; | |
} | |
if (typeof value === "string" && !rnoInnerhtml.test(value) && !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) { | |
value = value.replace(rxhtmlTag, "<$1></$2>"); | |
try { | |
for (; i < l; i++) { | |
elem = this[i] || {}; | |
if (elem.nodeType === 1) { | |
jQuery.cleanData(getAll(elem, false)); | |
elem.innerHTML = value; | |
} | |
} | |
elem = 0; | |
} catch (e) {} | |
} | |
if (elem) { | |
this.empty().append(value); | |
} | |
}, null, value, arguments.length); | |
}, | |
replaceWith: function () { | |
var | |
args = jQuery.map(this, function (elem) { | |
return [elem.nextSibling, elem.parentNode]; | |
}), | |
i = 0; | |
this.domManip(arguments, function (elem) { | |
var next = args[i++], | |
parent = args[i++]; | |
if (parent) { | |
jQuery(this).remove(); | |
parent.insertBefore(elem, next); | |
} | |
}, true); | |
return i ? this : this.remove(); | |
}, | |
detach: function (selector) { | |
return this.remove(selector, true); | |
}, | |
domManip: function (args, callback, allowIntersection) { | |
args = core_concat.apply([], args); | |
var fragment, first, scripts, hasScripts, node, doc, i = 0, | |
l = this.length, | |
set = this, | |
iNoClone = l - 1, | |
value = args[0], | |
isFunction = jQuery.isFunction(value); | |
if (isFunction || !(l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test(value))) { | |
return this.each(function (index) { | |
var self = set.eq(index); | |
if (isFunction) { | |
args[0] = value.call(this, index, self.html()); | |
} | |
self.domManip(args, callback, allowIntersection); | |
}); | |
} | |
if (l) { | |
fragment = jQuery.buildFragment(args, this[0].ownerDocument, false, !allowIntersection && this); | |
first = fragment.firstChild; | |
if (fragment.childNodes.length === 1) { | |
fragment = first; | |
} | |
if (first) { | |
scripts = jQuery.map(getAll(fragment, "script"), disableScript); | |
hasScripts = scripts.length; | |
for (; i < l; i++) { | |
node = fragment; | |
if (i !== iNoClone) { | |
node = jQuery.clone(node, true, true); | |
if (hasScripts) { | |
jQuery.merge(scripts, getAll(node, "script")); | |
} | |
} | |
callback.call(this[i], node, i); | |
} | |
if (hasScripts) { | |
doc = scripts[scripts.length - 1].ownerDocument; | |
jQuery.map(scripts, restoreScript); | |
for (i = 0; i < hasScripts; i++) { | |
node = scripts[i]; | |
if (rscriptType.test(node.type || "") && !data_priv.access(node, "globalEval") && jQuery.contains(doc, node)) { | |
if (node.src) { | |
jQuery._evalUrl(node.src); | |
} else { | |
jQuery.globalEval(node.textContent.replace(rcleanScript, "")); | |
} | |
} | |
} | |
} | |
} | |
} | |
return this; | |
} | |
}); | |
jQuery.each({ | |
appendTo: "append", | |
prependTo: "prepend", | |
insertBefore: "before", | |
insertAfter: "after", | |
replaceAll: "replaceWith" | |
}, function (name, original) { | |
jQuery.fn[name] = function (selector) { | |
var elems, ret = [], | |
insert = jQuery(selector), | |
last = insert.length - 1, | |
i = 0; | |
for (; i <= last; i++) { | |
elems = i === last ? this : this.clone(true); | |
jQuery(insert[i])[original](elems); | |
core_push.apply(ret, elems.get()); | |
} | |
return this.pushStack(ret); | |
}; | |
}); | |
jQuery.extend({ | |
clone: function (elem, dataAndEvents, deepDataAndEvents) { | |
var i, l, srcElements, destElements, clone = elem.cloneNode(true), | |
inPage = jQuery.contains(elem.ownerDocument, elem); | |
if (!jQuery.support.noCloneChecked && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) { | |
destElements = getAll(clone); | |
srcElements = getAll(elem); | |
for (i = 0, l = srcElements.length; i < l; i++) { | |
fixInput(srcElements[i], destElements[i]); | |
} | |
} | |
if (dataAndEvents) { | |
if (deepDataAndEvents) { | |
srcElements = srcElements || getAll(elem); | |
destElements = destElements || getAll(clone); | |
for (i = 0, l = srcElements.length; i < l; i++) { | |
cloneCopyEvent(srcElements[i], destElements[i]); | |
} | |
} else { | |
cloneCopyEvent(elem, clone); | |
} | |
} | |
destElements = getAll(clone, "script"); | |
if (destElements.length > 0) { | |
setGlobalEval(destElements, !inPage && getAll(elem, "script")); | |
} | |
return clone; | |
}, | |
buildFragment: function (elems, context, scripts, selection) { | |
var elem, tmp, tag, wrap, contains, j, i = 0, | |
l = elems.length, | |
fragment = context.createDocumentFragment(), | |
nodes = []; | |
for (; i < l; i++) { | |
elem = elems[i]; | |
if (elem || elem === 0) { | |
if (jQuery.type(elem) === "object") { | |
jQuery.merge(nodes, elem.nodeType ? [elem] : elem); | |
} else if (!rhtml.test(elem)) { | |
nodes.push(context.createTextNode(elem)); | |
} else { | |
tmp = tmp || fragment.appendChild(context.createElement("div")); | |
tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(); | |
wrap = wrapMap[tag] || wrapMap._default; | |
tmp.innerHTML = wrap[1] + elem.replace(rxhtmlTag, "<$1></$2>") + wrap[2]; | |
j = wrap[0]; | |
while (j--) { | |
tmp = tmp.firstChild; | |
} | |
jQuery.merge(nodes, tmp.childNodes); | |
tmp = fragment.firstChild; | |
tmp.textContent = ""; | |
} | |
} | |
} | |
fragment.textContent = ""; | |
i = 0; | |
while ((elem = nodes[i++])) { | |
if (selection && jQuery.inArray(elem, selection) !== -1) { | |
continue; | |
} | |
contains = jQuery.contains(elem.ownerDocument, elem); | |
tmp = getAll(fragment.appendChild(elem), "script"); | |
if (contains) { | |
setGlobalEval(tmp); | |
} | |
if (scripts) { | |
j = 0; | |
while ((elem = tmp[j++])) { | |
if (rscriptType.test(elem.type || "")) { | |
scripts.push(elem); | |
} | |
} | |
} | |
} | |
return fragment; | |
}, | |
cleanData: function (elems) { | |
var data, elem, type, l = elems.length, | |
i = 0, | |
special = jQuery.event.special; | |
for (; i < l; i++) { | |
elem = elems[i]; | |
if (jQuery.acceptData(elem)) { | |
data = data_priv.access(elem); | |
if (data) { | |
for (type in data.events) { | |
if (special[type]) { | |
jQuery.event.remove(elem, type); | |
} else { | |
jQuery.removeEvent(elem, type, data.handle); | |
} | |
} | |
} | |
} | |
data_user.discard(elem); | |
data_priv.discard(elem); | |
} | |
}, | |
_evalUrl: function (url) { | |
return jQuery.ajax({ | |
url: url, | |
type: "GET", | |
dataType: "text", | |
async: false, | |
global: false, | |
success: jQuery.globalEval | |
}); | |
} | |
}); | |
function manipulationTarget(elem, content) { | |
return jQuery.nodeName(elem, "table") && jQuery.nodeName(content.nodeType === 1 ? content : content.firstChild, "tr") ? elem.getElementsByTagName("tbody")[0] || elem.appendChild(elem.ownerDocument.createElement("tbody")) : elem; | |
} | |
function disableScript(elem) { | |
elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; | |
return elem; | |
} | |
function restoreScript(elem) { | |
var match = rscriptTypeMasked.exec(elem.type); | |
if (match) { | |
elem.type = match[1]; | |
} else { | |
elem.removeAttribute("type"); | |
} | |
return elem; | |
} | |
function setGlobalEval(elems, refElements) { | |
var l = elems.length, | |
i = 0; | |
for (; i < l; i++) { | |
data_priv.set(elems[i], "globalEval", !refElements || data_priv.get(refElements[i], "globalEval")); | |
} | |
} | |
function cloneCopyEvent(src, dest) { | |
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; | |
if (dest.nodeType !== 1) { | |
return; | |
} | |
if (data_priv.hasData(src)) { | |
pdataOld = data_priv.access(src); | |
pdataCur = jQuery.extend({}, pdataOld); | |
events = pdataOld.events; | |
data_priv.set(dest, pdataCur); | |
if (events) { | |
delete pdataCur.handle; | |
pdataCur.events = {}; | |
for (type in events) { | |
for (i = 0, l = events[type].length; i < l; i++) { | |
jQuery.event.add(dest, type, events[type][i]); | |
} | |
} | |
} | |
} | |
if (data_user.hasData(src)) { | |
udataOld = data_user.access(src); | |
udataCur = jQuery.extend({}, udataOld); | |
data_user.set(dest, udataCur); | |
} | |
} | |
function getAll(context, tag) { | |
var ret = context.getElementsByTagName ? context.getElementsByTagName(tag || "*") : context.querySelectorAll ? context.querySelectorAll(tag || "*") : []; | |
return tag === undefined || tag && jQuery.nodeName(context, tag) ? jQuery.merge([context], ret) : ret; | |
} | |
function fixInput(src, dest) { | |
var nodeName = dest.nodeName.toLowerCase(); | |
if (nodeName === "input" && manipulation_rcheckableType.test(src.type)) { | |
dest.checked = src.checked; | |
} else if (nodeName === "input" || nodeName === "textarea") { | |
dest.defaultValue = src.defaultValue; | |
} | |
} | |
jQuery.fn.extend({ | |
wrapAll: function (html) { | |
var wrap; | |
if (jQuery.isFunction(html)) { | |
return this.each(function (i) { | |
jQuery(this).wrapAll(html.call(this, i)); | |
}); | |
} | |
if (this[0]) { | |
wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true); | |
if (this[0].parentNode) { | |
wrap.insertBefore(this[0]); | |
} | |
wrap.map(function () { | |
var elem = this; | |
while (elem.firstElementChild) { | |
elem = elem.firstElementChild; | |
} | |
return elem; | |
}).append(this); | |
} | |
return this; | |
}, | |
wrapInner: function (html) { | |
if (jQuery.isFunction(html)) { | |
return this.each(function (i) { | |
jQuery(this).wrapInner(html.call(this, i)); | |
}); | |
} | |
return this.each(function () { | |
var self = jQuery(this), | |
contents = self.contents(); | |
if (contents.length) { | |
contents.wrapAll(html); | |
} else { | |
self.append(html); | |
} | |
}); | |
}, | |
wrap: function (html) { | |
var isFunction = jQuery.isFunction(html); | |
return this.each(function (i) { | |
jQuery(this).wrapAll(isFunction ? html.call(this, i) : html); | |
}); | |
}, | |
unwrap: function () { | |
return this.parent().each(function () { | |
if (!jQuery.nodeName(this, "body")) { | |
jQuery(this).replaceWith(this.childNodes); | |
} | |
}).end(); | |
} | |
}); | |
var curCSS, iframe, rdisplayswap = /^(none|table(?!-c[ea]).+)/, | |
rmargin = /^margin/, | |
rnumsplit = new RegExp("^(" + core_pnum + ")(.*)$", "i"), | |
rnumnonpx = new RegExp("^(" + core_pnum + ")(?!px)[a-z%]+$", "i"), | |
rrelNum = new RegExp("^([+-])=(" + core_pnum + ")", "i"), | |
elemdisplay = { | |
BODY: "block" | |
}, cssShow = { | |
position: "absolute", | |
visibility: "hidden", | |
display: "block" | |
}, cssNormalTransform = { | |
letterSpacing: 0, | |
fontWeight: 400 | |
}, cssExpand = ["Top", "Right", "Bottom", "Left"], | |
cssPrefixes = ["Webkit", "O", "Moz", "ms"]; | |
function vendorPropName(style, name) { | |
if (name in style) { | |
return name; | |
} | |
var capName = name.charAt(0).toUpperCase() + name.slice(1), | |
origName = name, | |
i = cssPrefixes.length; | |
while (i--) { | |
name = cssPrefixes[i] + capName; | |
if (name in style) { | |
return name; | |
} | |
} | |
return origName; | |
} | |
function isHidden(elem, el) { | |
elem = el || elem; | |
return jQuery.css(elem, "display") === "none" || !jQuery.contains(elem.ownerDocument, elem); | |
} | |
function getStyles(elem) { | |
return window.getComputedStyle(elem, null); | |
} | |
function showHide(elements, show) { | |
var display, elem, hidden, values = [], | |
index = 0, | |
length = elements.length; | |
for (; index < length; index++) { | |
elem = elements[index]; | |
if (!elem.style) { | |
continue; | |
} | |
values[index] = data_priv.get(elem, "olddisplay"); | |
display = elem.style.display; | |
if (show) { | |
if (!values[index] && display === "none") { | |
elem.style.display = ""; | |
} | |
if (elem.style.display === "" && isHidden(elem)) { | |
values[index] = data_priv.access(elem, "olddisplay", css_defaultDisplay(elem.nodeName)); | |
} | |
} else { | |
if (!values[index]) { | |
hidden = isHidden(elem); | |
if (display && display !== "none" || !hidden) { | |
data_priv.set(elem, "olddisplay", hidden ? display : jQuery.css(elem, "display")); | |
} | |
} | |
} | |
} | |
for (index = 0; index < length; index++) { | |
elem = elements[index]; | |
if (!elem.style) { | |
continue; | |
} | |
if (!show || elem.style.display === "none" || elem.style.display === "") { | |
elem.style.display = show ? values[index] || "" : "none"; | |
} | |
} | |
return elements; | |
} | |
jQuery.fn.extend({ | |
css: function (name, value) { | |
return jQuery.access(this, function (elem, name, value) { | |
var styles, len, map = {}, i = 0; | |
if (jQuery.isArray(name)) { | |
styles = getStyles(elem); | |
len = name.length; | |
for (; i < len; i++) { | |
map[name[i]] = jQuery.css(elem, name[i], false, styles); | |
} | |
return map; | |
} | |
return value !== undefined ? jQuery.style(elem, name, value) : jQuery.css(elem, name); | |
}, name, value, arguments.length > 1); | |
}, | |
show: function () { | |
return showHide(this, true); | |
}, | |
hide: function () { | |
return showHide(this); | |
}, | |
toggle: function (state) { | |
var bool = typeof state === "boolean"; | |
return this.each(function () { | |
if (bool ? state : isHidden(this)) { | |
jQuery(this).show(); | |
} else { | |
jQuery(this).hide(); | |
} | |
}); | |
} | |
}); | |
jQuery.extend({ | |
cssHooks: { | |
opacity: { | |
get: function (elem, computed) { | |
if (computed) { | |
var ret = curCSS(elem, "opacity"); | |
return ret === "" ? "1" : ret; | |
} | |
} | |
} | |
}, | |
cssNumber: { | |
"columnCount": true, | |
"fillOpacity": true, | |
"fontWeight": true, | |
"lineHeight": true, | |
"opacity": true, | |
"orphans": true, | |
"widows": true, | |
"zIndex": true, | |
"zoom": true | |
}, | |
cssProps: { | |
"float": "cssFloat" | |
}, | |
style: function (elem, name, value, extra) { | |
if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) { | |
return; | |
} | |
var ret, type, hooks, origName = jQuery.camelCase(name), | |
style = elem.style; | |
name = jQuery.cssProps[origName] || (jQuery.cssProps[origName] = vendorPropName(style, origName)); | |
hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName]; | |
if (value !== undefined) { | |
type = typeof value; | |
if (type === "string" && (ret = rrelNum.exec(value))) { | |
value = (ret[1] + 1) * ret[2] + parseFloat(jQuery.css(elem, name)); | |
type = "number"; | |
} | |
if (value == null || type === "number" && isNaN(value)) { | |
return; | |
} | |
if (type === "number" && !jQuery.cssNumber[origName]) { | |
value += "px"; | |
} | |
if (!jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0) { | |
style[name] = "inherit"; | |
} | |
if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== undefined) { | |
style[name] = value; | |
} | |
} else { | |
if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) { | |
return ret; | |
} | |
return style[name]; | |
} | |
}, | |
css: function (elem, name, extra, styles) { | |
var val, num, hooks, origName = jQuery.camelCase(name); | |
name = jQuery.cssProps[origName] || (jQuery.cssProps[origName] = vendorPropName(elem.style, origName)); | |
hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName]; | |
if (hooks && "get" in hooks) { | |
val = hooks.get(elem, true, extra); | |
} | |
if (val === undefined) { | |
val = curCSS(elem, name, styles); | |
} | |
if (val === "normal" && name in cssNormalTransform) { | |
val = cssNormalTransform[name]; | |
} | |
if (extra === "" || extra) { | |
num = parseFloat(val); | |
return extra === true || jQuery.isNumeric(num) ? num || 0 : val; | |
} | |
return val; | |
} | |
}); | |
curCSS = function (elem, name, _computed) { | |
var width, minWidth, maxWidth, computed = _computed || getStyles(elem), | |
ret = computed ? computed.getPropertyValue(name) || computed[name] : undefined, | |
style = elem.style; | |
if (computed) { | |
if (ret === "" && !jQuery.contains(elem.ownerDocument, elem)) { | |
ret = jQuery.style(elem, name); | |
} | |
if (rnumnonpx.test(ret) && rmargin.test(name)) { | |
width = style.width; | |
minWidth = style.minWidth; | |
maxWidth = style.maxWidth; | |
style.minWidth = style.maxWidth = style.width = ret; | |
ret = computed.width; | |
style.width = width; | |
style.minWidth = minWidth; | |
style.maxWidth = maxWidth; | |
} | |
} | |
return ret; | |
}; | |
function setPositiveNumber(elem, value, subtract) { | |
var matches = rnumsplit.exec(value); | |
return matches ? Math.max(0, matches[1] - (subtract || 0)) + (matches[2] || "px") : value; | |
} | |
function augmentWidthOrHeight(elem, name, extra, isBorderBox, styles) { | |
var i = extra === (isBorderBox ? "border" : "content") ? 4 : name === "width" ? 1 : 0, | |
val = 0; | |
for (; i < 4; i += 2) { | |
if (extra === "margin") { | |
val += jQuery.css(elem, extra + cssExpand[i], true, styles); | |
} | |
if (isBorderBox) { | |
if (extra === "content") { | |
val -= jQuery.css(elem, "padding" + cssExpand[i], true, styles); | |
} | |
if (extra !== "margin") { | |
val -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles); | |
} | |
} else { | |
val += jQuery.css(elem, "padding" + cssExpand[i], true, styles); | |
if (extra !== "padding") { | |
val += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles); | |
} | |
} | |
} | |
return val; | |
} | |
function getWidthOrHeight(elem, name, extra) { | |
var valueIsBorderBox = true, | |
val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | |
styles = getStyles(elem), | |
isBorderBox = jQuery.support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box"; | |
if (val <= 0 || val == null) { | |
val = curCSS(elem, name, styles); | |
if (val < 0 || val == null) { | |
val = elem.style[name]; | |
} | |
if (rnumnonpx.test(val)) { | |
return val; | |
} | |
valueIsBorderBox = isBorderBox && (jQuery.support.boxSizingReliable || val === elem.style[name]); | |
val = parseFloat(val) || 0; | |
} | |
return (val + | |
augmentWidthOrHeight(elem, name, extra || (isBorderBox ? "border" : "content"), valueIsBorderBox, styles)) + "px"; | |
} | |
function css_defaultDisplay(nodeName) { | |
var doc = document, | |
display = elemdisplay[nodeName]; | |
if (!display) { | |
display = actualDisplay(nodeName, doc); | |
if (display === "none" || !display) { | |
iframe = (iframe || jQuery("<iframe frameborder='0' width='0' height='0'/>").css("cssText", "display:block !important")).appendTo(doc.documentElement); | |
doc = (iframe[0].contentWindow || iframe[0].contentDocument).document; | |
doc.write("<!doctype html><html><body>"); | |
doc.close(); | |
display = actualDisplay(nodeName, doc); | |
iframe.detach(); | |
} | |
elemdisplay[nodeName] = display; | |
} | |
return display; | |
} | |
function actualDisplay(name, doc) { | |
var elem = jQuery(doc.createElement(name)).appendTo(doc.body), | |
display = jQuery.css(elem[0], "display"); | |
elem.remove(); | |
return display; | |
} | |
jQuery.each(["height", "width"], function (i, name) { | |
jQuery.cssHooks[name] = { | |
get: function (elem, computed, extra) { | |
if (computed) { | |
return elem.offsetWidth === 0 && rdisplayswap.test(jQuery.css(elem, "display")) ? jQuery.swap(elem, cssShow, function () { | |
return getWidthOrHeight(elem, name, extra); | |
}) : getWidthOrHeight(elem, name, extra); | |
} | |
}, | |
set: function (elem, value, extra) { | |
var styles = extra && getStyles(elem); | |
return setPositiveNumber(elem, value, extra ? augmentWidthOrHeight(elem, name, extra, jQuery.support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box", styles) : 0); | |
} | |
}; | |
}); | |
jQuery(function () { | |
if (!jQuery.support.reliableMarginRight) { | |
jQuery.cssHooks.marginRight = { | |
get: function (elem, computed) { | |
if (computed) { | |
return jQuery.swap(elem, { | |
"display": "inline-block" | |
}, curCSS, [elem, "marginRight"]); | |
} | |
} | |
}; | |
} | |
if (!jQuery.support.pixelPosition && jQuery.fn.position) { | |
jQuery.each(["top", "left"], function (i, prop) { | |
jQuery.cssHooks[prop] = { | |
get: function (elem, computed) { | |
if (computed) { | |
computed = curCSS(elem, prop); | |
return rnumnonpx.test(computed) ? jQuery(elem).position()[prop] + "px" : computed; | |
} | |
} | |
}; | |
}); | |
} | |
}); | |
if (jQuery.expr && jQuery.expr.filters) { | |
jQuery.expr.filters.hidden = function (elem) { | |
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; | |
}; | |
jQuery.expr.filters.visible = function (elem) { | |
return !jQuery.expr.filters.hidden(elem); | |
}; | |
} | |
jQuery.each({ | |
margin: "", | |
padding: "", | |
border: "Width" | |
}, function (prefix, suffix) { | |
jQuery.cssHooks[prefix + suffix] = { | |
expand: function (value) { | |
var i = 0, | |
expanded = {}, parts = typeof value === "string" ? value.split(" ") : [value]; | |
for (; i < 4; i++) { | |
expanded[prefix + cssExpand[i] + suffix] = parts[i] || parts[i - 2] || parts[0]; | |
} | |
return expanded; | |
} | |
}; | |
if (!rmargin.test(prefix)) { | |
jQuery.cssHooks[prefix + suffix].set = setPositiveNumber; | |
} | |
}); | |
var r20 = /%20/g, | |
rbracket = /\[\]$/, | |
rCRLF = /\r?\n/g, | |
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, | |
rsubmittable = /^(?:input|select|textarea|keygen)/i; | |
jQuery.fn.extend({ | |
serialize: function () { | |
return jQuery.param(this.serializeArray()); | |
}, | |
serializeArray: function () { | |
return this.map(function () { | |
var elements = jQuery.prop(this, "elements"); | |
return elements ? jQuery.makeArray(elements) : this; | |
}).filter(function () { | |
var type = this.type; | |
return this.name && !jQuery(this).is(":disabled") && rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) && (this.checked || !manipulation_rcheckableType.test(type)); | |
}).map(function (i, elem) { | |
var val = jQuery(this).val(); | |
return val == null ? null : jQuery.isArray(val) ? jQuery.map(val, function (val) { | |
return { | |
name: elem.name, | |
value: val.replace(rCRLF, "\r\n") | |
}; | |
}) : { | |
name: elem.name, | |
value: val.replace(rCRLF, "\r\n") | |
}; | |
}).get(); | |
} | |
}); | |
jQuery.param = function (a, traditional) { | |
var prefix, s = [], | |
add = function (key, value) { | |
value = jQuery.isFunction(value) ? value() : (value == null ? "" : value); | |
s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value); | |
}; | |
if (traditional === undefined) { | |
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; | |
} | |
if (jQuery.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) { | |
jQuery.each(a, function () { | |
add(this.name, this.value); | |
}); | |
} else { | |
for (prefix in a) { | |
buildParams(prefix, a[prefix], traditional, add); | |
} | |
} | |
return s.join("&").replace(r20, "+"); | |
}; | |
function buildParams(prefix, obj, traditional, add) { | |
var name; | |
if (jQuery.isArray(obj)) { | |
jQuery.each(obj, function (i, v) { | |
if (traditional || rbracket.test(prefix)) { | |
add(prefix, v); | |
} else { | |
buildParams(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add); | |
} | |
}); | |
} else if (!traditional && jQuery.type(obj) === "object") { | |
for (name in obj) { | |
buildParams(prefix + "[" + name + "]", obj[name], traditional, add); | |
} | |
} else { | |
add(prefix, obj); | |
} | |
} | |
jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup error contextmenu").split(" "), function (i, name) { | |
jQuery.fn[name] = function (data, fn) { | |
return arguments.length > 0 ? this.on(name, null, data, fn) : this.trigger(name); | |
}; | |
}); | |
jQuery.fn.extend({ | |
hover: function (fnOver, fnOut) { | |
return this.mouseenter(fnOver).mouseleave(fnOut || fnOver); | |
}, | |
bind: function (types, data, fn) { | |
return this.on(types, null, data, fn); | |
}, | |
unbind: function (types, fn) { | |
return this.off(types, null, fn); | |
}, | |
delegate: function (selector, types, data, fn) { | |
return this.on(types, selector, data, fn); | |
}, | |
undelegate: function (selector, types, fn) { | |
return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn); | |
} | |
}); | |
var | |
ajaxLocParts, ajaxLocation, ajax_nonce = jQuery.now(), | |
ajax_rquery = /\?/, | |
rhash = /#.*$/, | |
rts = /([?&])_=[^&]*/, | |
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, | |
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, | |
rnoContent = /^(?:GET|HEAD)$/, | |
rprotocol = /^\/\//, | |
rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, | |
_load = jQuery.fn.load, | |
prefilters = {}, transports = {}, allTypes = "*/".concat("*"); | |
try { | |
ajaxLocation = location.href; | |
} catch (e) { | |
ajaxLocation = document.createElement("a"); | |
ajaxLocation.href = ""; | |
ajaxLocation = ajaxLocation.href; | |
} | |
ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || []; | |
function addToPrefiltersOrTransports(structure) { | |
return function (dataTypeExpression, func) { | |
if (typeof dataTypeExpression !== "string") { | |
func = dataTypeExpression; | |
dataTypeExpression = "*"; | |
} | |
var dataType, i = 0, | |
dataTypes = dataTypeExpression.toLowerCase().match(core_rnotwhite) || []; | |
if (jQuery.isFunction(func)) { | |
while ((dataType = dataTypes[i++])) { | |
if (dataType[0] === "+") { | |
dataType = dataType.slice(1) || "*"; | |
(structure[dataType] = structure[dataType] || []).unshift(func); | |
} else { | |
(structure[dataType] = structure[dataType] || []).push(func); | |
} | |
} | |
} | |
}; | |
} | |
function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) { | |
var inspected = {}, seekingTransport = (structure === transports); | |
function inspect(dataType) { | |
var selected; | |
inspected[dataType] = true; | |
jQuery.each(structure[dataType] || [], function (_, prefilterOrFactory) { | |
var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR); | |
if (typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[dataTypeOrTransport]) { | |
options.dataTypes.unshift(dataTypeOrTransport); | |
inspect(dataTypeOrTransport); | |
return false; | |
} else if (seekingTransport) { | |
return !(selected = dataTypeOrTransport); | |
} | |
}); | |
return selected; | |
} | |
return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*"); | |
} | |
function ajaxExtend(target, src) { | |
var key, deep, flatOptions = jQuery.ajaxSettings.flatOptions || {}; | |
for (key in src) { | |
if (src[key] !== undefined) { | |
(flatOptions[key] ? target : (deep || (deep = {})))[key] = src[key]; | |
} | |
} | |
if (deep) { | |
jQuery.extend(true, target, deep); | |
} | |
return target; | |
} | |
jQuery.fn.load = function (url, params, callback) { | |
if (typeof url !== "string" && _load) { | |
return _load.apply(this, arguments); | |
} | |
var selector, type, response, self = this, | |
off = url.indexOf(" "); | |
if (off >= 0) { | |
selector = url.slice(off); | |
url = url.slice(0, off); | |
} | |
if (jQuery.isFunction(params)) { | |
callback = params; | |
params = undefined; | |
} else if (params && typeof params === "object") { | |
type = "POST"; | |
} | |
if (self.length > 0) { | |
jQuery.ajax({ | |
url: url, | |
type: type, | |
dataType: "html", | |
data: params | |
}).done(function (responseText) { | |
response = arguments; | |
self.html(selector ? jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) : responseText); | |
}).complete(callback && function (jqXHR, status) { | |
self.each(callback, response || [jqXHR.responseText, status, jqXHR]); | |
}); | |
} | |
return this; | |
}; | |
jQuery.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function (i, type) { | |
jQuery.fn[type] = function (fn) { | |
return this.on(type, fn); | |
}; | |
}); | |
jQuery.extend({ | |
active: 0, | |
lastModified: {}, | |
etag: {}, | |
ajaxSettings: { | |
url: ajaxLocation, | |
type: "GET", | |
isLocal: rlocalProtocol.test(ajaxLocParts[1]), | |
global: true, | |
processData: true, | |
async: true, | |
contentType: "application/x-www-form-urlencoded; charset=UTF-8", | |
accepts: { | |
"*": allTypes, | |
text: "text/plain", | |
html: "text/html", | |
xml: "application/xml, text/xml", | |
json: "application/json, text/javascript" | |
}, | |
contents: { | |
xml: /xml/, | |
html: /html/, | |
json: /json/ | |
}, | |
responseFields: { | |
xml: "responseXML", | |
text: "responseText", | |
json: "responseJSON" | |
}, | |
converters: { | |
"* text": String, | |
"text html": true, | |
"text json": jQuery.parseJSON, | |
"text xml": jQuery.parseXML | |
}, | |
flatOptions: { | |
url: true, | |
context: true | |
} | |
}, | |
ajaxSetup: function (target, settings) { | |
return settings ? ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) : ajaxExtend(jQuery.ajaxSettings, target); | |
}, | |
ajaxPrefilter: addToPrefiltersOrTransports(prefilters), | |
ajaxTransport: addToPrefiltersOrTransports(transports), | |
ajax: function (url, options) { | |
if (typeof url === "object") { | |
options = url; | |
url = undefined; | |
} | |
options = options || {}; | |
var transport, cacheURL, responseHeadersString, responseHeaders, timeoutTimer, parts, fireGlobals, i, s = jQuery.ajaxSetup({}, options), | |
callbackContext = s.context || s, | |
globalEventContext = s.context && (callbackContext.nodeType || callbackContext.jquery) ? jQuery(callbackContext) : jQuery.event, | |
deferred = jQuery.Deferred(), | |
completeDeferred = jQuery.Callbacks("once memory"), | |
statusCode = s.statusCode || {}, requestHeaders = {}, requestHeadersNames = {}, state = 0, | |
strAbort = "canceled", | |
jqXHR = { | |
readyState: 0, | |
getResponseHeader: function (key) { | |
var match; | |
if (state === 2) { | |
if (!responseHeaders) { | |
responseHeaders = {}; | |
while ((match = rheaders.exec(responseHeadersString))) { | |
responseHeaders[match[1].toLowerCase()] = match[2]; | |
} | |
} | |
match = responseHeaders[key.toLowerCase()]; | |
} | |
return match == null ? null : match; | |
}, | |
getAllResponseHeaders: function () { | |
return state === 2 ? responseHeadersString : null; | |
}, | |
setRequestHeader: function (name, value) { | |
var lname = name.toLowerCase(); | |
if (!state) { | |
name = requestHeadersNames[lname] = requestHeadersNames[lname] || name; | |
requestHeaders[name] = value; | |
} | |
return this; | |
}, | |
overrideMimeType: function (type) { | |
if (!state) { | |
s.mimeType = type; | |
} | |
return this; | |
}, | |
statusCode: function (map) { | |
var code; | |
if (map) { | |
if (state < 2) { | |
for (code in map) { | |
statusCode[code] = [statusCode[code], map[code]]; | |
} | |
} else { | |
jqXHR.always(map[jqXHR.status]); | |
} | |
} | |
return this; | |
}, | |
abort: function (statusText) { | |
var finalText = statusText || strAbort; | |
if (transport) { | |
transport.abort(finalText); | |
} | |
done(0, finalText); | |
return this; | |
} | |
}; | |
deferred.promise(jqXHR).complete = completeDeferred.add; | |
jqXHR.success = jqXHR.done; | |
jqXHR.error = jqXHR.fail; | |
s.url = ((url || s.url || ajaxLocation) + "").replace(rhash, "").replace(rprotocol, ajaxLocParts[1] + "//"); | |
s.type = options.method || options.type || s.method || s.type; | |
s.dataTypes = jQuery.trim(s.dataType || "*").toLowerCase().match(core_rnotwhite) || [""]; | |
if (s.crossDomain == null) { | |
parts = rurl.exec(s.url.toLowerCase()); | |
s.crossDomain = !! (parts && (parts[1] !== ajaxLocParts[1] || parts[2] !== ajaxLocParts[2] || (parts[3] || (parts[1] === "http:" ? "80" : "443")) !== (ajaxLocParts[3] || (ajaxLocParts[1] === "http:" ? "80" : "443")))); | |
} | |
if (s.data && s.processData && typeof s.data !== "string") { | |
s.data = jQuery.param(s.data, s.traditional); | |
} | |
inspectPrefiltersOrTransports(prefilters, s, options, jqXHR); | |
if (state === 2) { | |
return jqXHR; | |
} | |
fireGlobals = s.global; | |
if (fireGlobals && jQuery.active++ === 0) { | |
jQuery.event.trigger("ajaxStart"); | |
} | |
s.type = s.type.toUpperCase(); | |
s.hasContent = !rnoContent.test(s.type); | |
cacheURL = s.url; | |
if (!s.hasContent) { | |
if (s.data) { | |
cacheURL = (s.url += (ajax_rquery.test(cacheURL) ? "&" : "?") + s.data); | |
delete s.data; | |
} | |
if (s.cache === false) { | |
s.url = rts.test(cacheURL) ? cacheURL.replace(rts, "$1_=" + ajax_nonce++) : cacheURL + (ajax_rquery.test(cacheURL) ? "&" : "?") + "_=" + ajax_nonce++; | |
} | |
} | |
if (s.ifModified) { | |
if (jQuery.lastModified[cacheURL]) { | |
jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[cacheURL]); | |
} | |
if (jQuery.etag[cacheURL]) { | |
jqXHR.setRequestHeader("If-None-Match", jQuery.etag[cacheURL]); | |
} | |
} | |
if (s.data && s.hasContent && s.contentType !== false || options.contentType) { | |
jqXHR.setRequestHeader("Content-Type", s.contentType); | |
} | |
jqXHR.setRequestHeader("Accept", s.dataTypes[0] && s.accepts[s.dataTypes[0]] ? s.accepts[s.dataTypes[0]] + (s.dataTypes[0] !== "*" ? ", " + allTypes + "; q=0.01" : "") : s.accepts["*"]); | |
for (i in s.headers) { | |
jqXHR.setRequestHeader(i, s.headers[i]); | |
} | |
if (s.beforeSend && (s.beforeSend.call(callbackContext, jqXHR, s) === false || state === 2)) { | |
return jqXHR.abort(); | |
} | |
strAbort = "abort"; | |
for (i in { | |
success: 1, | |
error: 1, | |
complete: 1 | |
}) { | |
jqXHR[i](s[i]); | |
} | |
transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR); | |
if (!transport) { | |
done(-1, "No Transport"); | |
} else { | |
jqXHR.readyState = 1; | |
if (fireGlobals) { | |
globalEventContext.trigger("ajaxSend", [jqXHR, s]); | |
} | |
if (s.async && s.timeout > 0) { | |
timeoutTimer = setTimeout(function () { | |
jqXHR.abort("timeout"); | |
}, s.timeout); | |
} | |
try { | |
state = 1; | |
transport.send(requestHeaders, done); | |
} catch (e) { | |
if (state < 2) { | |
done(-1, e); | |
} else { | |
throw e; | |
} | |
} | |
} | |
function done(status, nativeStatusText, responses, headers) { | |
var isSuccess, success, error, response, modified, statusText = nativeStatusText; | |
if (state === 2) { | |
return; | |
} | |
state = 2; | |
if (timeoutTimer) { | |
clearTimeout(timeoutTimer); | |
} | |
transport = undefined; | |
responseHeadersString = headers || ""; | |
jqXHR.readyState = status > 0 ? 4 : 0; | |
isSuccess = status >= 200 && status < 300 || status === 304; | |
if (responses) { | |
response = ajaxHandleResponses(s, jqXHR, responses); | |
} | |
response = ajaxConvert(s, response, jqXHR, isSuccess); | |
if (isSuccess) { | |
if (s.ifModified) { | |
modified = jqXHR.getResponseHeader("Last-Modified"); | |
if (modified) { | |
jQuery.lastModified[cacheURL] = modified; | |
} | |
modified = jqXHR.getResponseHeader("etag"); | |
if (modified) { | |
jQuery.etag[cacheURL] = modified; | |
} | |
} | |
if (status === 204) { | |
statusText = "nocontent"; | |
} else if (status === 304) { | |
statusText = "notmodified"; | |
} else { | |
statusText = response.state; | |
success = response.data; | |
error = response.error; | |
isSuccess = !error; | |
} | |
} else { | |
error = statusText; | |
if (status || !statusText) { | |
statusText = "error"; | |
if (status < 0) { | |
status = 0; | |
} | |
} | |
} | |
jqXHR.status = status; | |
jqXHR.statusText = (nativeStatusText || statusText) + ""; | |
if (isSuccess) { | |
deferred.resolveWith(callbackContext, [success, statusText, jqXHR]); | |
} else { | |
deferred.rejectWith(callbackContext, [jqXHR, statusText, error]); | |
} | |
jqXHR.statusCode(statusCode); | |
statusCode = undefined; | |
if (fireGlobals) { | |
globalEventContext.trigger(isSuccess ? "ajaxSuccess" : "ajaxError", [jqXHR, s, isSuccess ? success : error]); | |
} | |
completeDeferred.fireWith(callbackContext, [jqXHR, statusText]); | |
if (fireGlobals) { | |
globalEventContext.trigger("ajaxComplete", [jqXHR, s]); | |
if (!(--jQuery.active)) { | |
jQuery.event.trigger("ajaxStop"); | |
} | |
} | |
} | |
return jqXHR; | |
}, | |
getJSON: function (url, data, callback) { | |
return jQuery.get(url, data, callback, "json"); | |
}, | |
getScript: function (url, callback) { | |
return jQuery.get(url, undefined, callback, "script"); | |
} | |
}); | |
jQuery.each(["get", "post"], function (i, method) { | |
jQuery[method] = function (url, data, callback, type) { | |
if (jQuery.isFunction(data)) { | |
type = type || callback; | |
callback = data; | |
data = undefined; | |
} | |
return jQuery.ajax({ | |
url: url, | |
type: method, | |
dataType: type, | |
data: data, | |
success: callback | |
}); | |
}; | |
}); | |
function ajaxHandleResponses(s, jqXHR, responses) { | |
var ct, type, finalDataType, firstDataType, contents = s.contents, | |
dataTypes = s.dataTypes; | |
while (dataTypes[0] === "*") { | |
dataTypes.shift(); | |
if (ct === undefined) { | |
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); | |
} | |
} | |
if (ct) { | |
for (type in contents) { | |
if (contents[type] && contents[type].test(ct)) { | |
dataTypes.unshift(type); | |
break; | |
} | |
} | |
} | |
if (dataTypes[0] in responses) { | |
finalDataType = dataTypes[0]; | |
} else { | |
for (type in responses) { | |
if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) { | |
finalDataType = type; | |
break; | |
} | |
if (!firstDataType) { | |
firstDataType = type; | |
} | |
} | |
finalDataType = finalDataType || firstDataType; | |
} | |
if (finalDataType) { | |
if (finalDataType !== dataTypes[0]) { | |
dataTypes.unshift(finalDataType); | |
} | |
return responses[finalDataType]; | |
} | |
} | |
function ajaxConvert(s, response, jqXHR, isSuccess) { | |
var conv2, current, conv, tmp, prev, converters = {}, dataTypes = s.dataTypes.slice(); | |
if (dataTypes[1]) { | |
for (conv in s.converters) { | |
converters[conv.toLowerCase()] = s.converters[conv]; | |
} | |
} | |
current = dataTypes.shift(); | |
while (current) { | |
if (s.responseFields[current]) { | |
jqXHR[s.responseFields[current]] = response; | |
} | |
if (!prev && isSuccess && s.dataFilter) { | |
response = s.dataFilter(response, s.dataType); | |
} | |
prev = current; | |
current = dataTypes.shift(); | |
if (current) { | |
if (current === "*") { | |
current = prev; | |
} else if (prev !== "*" && prev !== current) { | |
conv = converters[prev + " " + current] || converters["* " + current]; | |
if (!conv) { | |
for (conv2 in converters) { | |
tmp = conv2.split(" "); | |
if (tmp[1] === current) { | |
conv = converters[prev + " " + tmp[0]] || converters["* " + tmp[0]]; | |
if (conv) { | |
if (conv === true) { | |
conv = converters[conv2]; | |
} else if (converters[conv2] !== true) { | |
current = tmp[0]; | |
dataTypes.unshift(tmp[1]); | |
} | |
break; | |
} | |
} | |
} | |
} | |
if (conv !== true) { | |
if (conv && s["throws"]) { | |
response = conv(response); | |
} else { | |
try { | |
response = conv(response); | |
} catch (e) { | |
return { | |
state: "parsererror", | |
error: conv ? e : "No conversion from " + prev + " to " + current | |
}; | |
} | |
} | |
} | |
} | |
} | |
} | |
return { | |
state: "success", | |
data: response | |
}; | |
} | |
jQuery.ajaxSetup({ | |
accepts: { | |
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" | |
}, | |
contents: { | |
script: /(?:java|ecma)script/ | |
}, | |
converters: { | |
"text script": function (text) { | |
jQuery.globalEval(text); | |
return text; | |
} | |
} | |
}); | |
jQuery.ajaxPrefilter("script", function (s) { | |
if (s.cache === undefined) { | |
s.cache = false; | |
} | |
if (s.crossDomain) { | |
s.type = "GET"; | |
} | |
}); | |
jQuery.ajaxTransport("script", function (s) { | |
if (s.crossDomain) { | |
var script, callback; | |
return { | |
send: function (_, complete) { | |
script = jQuery("<script>").prop({ | |
async: true, | |
charset: s.scriptCharset, | |
src: s.url | |
}).on("load error", callback = function (evt) { | |
script.remove(); | |
callback = null; | |
if (evt) { | |
complete(evt.type === "error" ? 404 : 200, evt.type); | |
} | |
}); | |
document.head.appendChild(script[0]); | |
}, | |
abort: function () { | |
if (callback) { | |
callback(); | |
} | |
} | |
}; | |
} | |
}); | |
var oldCallbacks = [], | |
rjsonp = /(=)\?(?=&|$)|\?\?/; | |
jQuery.ajaxSetup({ | |
jsonp: "callback", | |
jsonpCallback: function () { | |
var callback = oldCallbacks.pop() || (jQuery.expando + "_" + (ajax_nonce++)); | |
this[callback] = true; | |
return callback; | |
} | |
}); | |
jQuery.ajaxPrefilter("json jsonp", function (s, originalSettings, jqXHR) { | |
var callbackName, overwritten, responseContainer, jsonProp = s.jsonp !== false && (rjsonp.test(s.url) ? "url" : typeof s.data === "string" && !(s.contentType || "").indexOf("application/x-www-form-urlencoded") && rjsonp.test(s.data) && "data"); | |
if (jsonProp || s.dataTypes[0] === "jsonp") { | |
callbackName = s.jsonpCallback = jQuery.isFunction(s.jsonpCallback) ? s.jsonpCallback() : s.jsonpCallback; | |
if (jsonProp) { | |
s[jsonProp] = s[jsonProp].replace(rjsonp, "$1" + callbackName); | |
} else if (s.jsonp !== false) { | |
s.url += (ajax_rquery.test(s.url) ? "&" : "?") + s.jsonp + "=" + callbackName; | |
} | |
s.converters["script json"] = function () { | |
if (!responseContainer) { | |
jQuery.error(callbackName + " was not called"); | |
} | |
return responseContainer[0]; | |
}; | |
s.dataTypes[0] = "json"; | |
overwritten = window[callbackName]; | |
window[callbackName] = function () { | |
responseContainer = arguments; | |
}; | |
jqXHR.always(function () { | |
window[callbackName] = overwritten; | |
if (s[callbackName]) { | |
s.jsonpCallback = originalSettings.jsonpCallback; | |
oldCallbacks.push(callbackName); | |
} | |
if (responseContainer && jQuery.isFunction(overwritten)) { | |
overwritten(responseContainer[0]); | |
} | |
responseContainer = overwritten = undefined; | |
}); | |
return "script"; | |
} | |
}); | |
jQuery.ajaxSettings.xhr = function () { | |
try { | |
return new XMLHttpRequest(); | |
} catch (e) {} | |
}; | |
var xhrSupported = jQuery.ajaxSettings.xhr(), | |
xhrSuccessStatus = { | |
0: 200, | |
1223: 204 | |
}, xhrId = 0, | |
xhrCallbacks = {}; | |
if (window.ActiveXObject) { | |
jQuery(window).on("unload", function () { | |
for (var key in xhrCallbacks) { | |
xhrCallbacks[key](); | |
} | |
xhrCallbacks = undefined; | |
}); | |
} | |
jQuery.support.cors = !! xhrSupported && ("withCredentials" in xhrSupported); | |
jQuery.support.ajax = xhrSupported = !! xhrSupported; | |
jQuery.ajaxTransport(function (options) { | |
var callback; | |
if (jQuery.support.cors || xhrSupported && !options.crossDomain) { | |
return { | |
send: function (headers, complete) { | |
var i, id, xhr = options.xhr(); | |
xhr.open(options.type, options.url, options.async, options.username, options.password); | |
if (options.xhrFields) { | |
for (i in options.xhrFields) { | |
xhr[i] = options.xhrFields[i]; | |
} | |
} | |
if (options.mimeType && xhr.overrideMimeType) { | |
xhr.overrideMimeType(options.mimeType); | |
} | |
if (!options.crossDomain && !headers["X-Requested-With"]) { | |
headers["X-Requested-With"] = "XMLHttpRequest"; | |
} | |
for (i in headers) { | |
xhr.setRequestHeader(i, headers[i]); | |
} | |
callback = function (type) { | |
return function () { | |
if (callback) { | |
delete xhrCallbacks[id]; | |
callback = xhr.onload = xhr.onerror = null; | |
if (type === "abort") { | |
xhr.abort(); | |
} else if (type === "error") { | |
complete(xhr.status || 404, xhr.statusText); | |
} else { | |
complete(xhrSuccessStatus[xhr.status] || xhr.status, xhr.statusText, typeof xhr.responseText === "string" ? { | |
text: xhr.responseText | |
} : undefined, xhr.getAllResponseHeaders()); | |
} | |
} | |
}; | |
}; | |
xhr.onload = callback(); | |
xhr.onerror = callback("error"); | |
callback = xhrCallbacks[(id = xhrId++)] = callback("abort"); | |
xhr.send(options.hasContent && options.data || null); | |
}, | |
abort: function () { | |
if (callback) { | |
callback(); | |
} | |
} | |
}; | |
} | |
}); | |
var fxNow, timerId, rfxtypes = /^(?:toggle|show|hide)$/, | |
rfxnum = new RegExp("^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i"), | |
rrun = /queueHooks$/, | |
animationPrefilters = [defaultPrefilter], | |
tweeners = { | |
"*": [ | |
function (prop, value) { | |
var end, unit, tween = this.createTween(prop, value), | |
parts = rfxnum.exec(value), | |
target = tween.cur(), | |
start = +target || 0, | |
scale = 1, | |
maxIterations = 20; | |
if (parts) { | |
end = +parts[2]; | |
unit = parts[3] || (jQuery.cssNumber[prop] ? "" : "px"); | |
if (unit !== "px" && start) { | |
start = jQuery.css(tween.elem, prop, true) || end || 1; | |
do { | |
scale = scale || ".5"; | |
start = start / scale; | |
jQuery.style(tween.elem, prop, start + unit); | |
} while (scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations); | |
} | |
tween.unit = unit; | |
tween.start = start; | |
tween.end = parts[1] ? start + (parts[1] + 1) * end : end; | |
} | |
return tween; | |
} | |
] | |
}; | |
function createFxNow() { | |
setTimeout(function () { | |
fxNow = undefined; | |
}); | |
return (fxNow = jQuery.now()); | |
} | |
function createTweens(animation, props) { | |
jQuery.each(props, function (prop, value) { | |
var collection = (tweeners[prop] || []).concat(tweeners["*"]), | |
index = 0, | |
length = collection.length; | |
for (; index < length; index++) { | |
if (collection[index].call(animation, prop, value)) { | |
return; | |
} | |
} | |
}); | |
} | |
function Animation(elem, properties, options) { | |
var result, stopped, index = 0, | |
length = animationPrefilters.length, | |
deferred = jQuery.Deferred().always(function () { | |
delete tick.elem; | |
}), | |
tick = function () { | |
if (stopped) { | |
return false; | |
} | |
var currentTime = fxNow || createFxNow(), | |
remaining = Math.max(0, animation.startTime + animation.duration - currentTime), | |
temp = remaining / animation.duration || 0, | |
percent = 1 - temp, | |
index = 0, | |
length = animation.tweens.length; | |
for (; index < length; index++) { | |
animation.tweens[index].run(percent); | |
} | |
deferred.notifyWith(elem, [animation, percent, remaining]); | |
if (percent < 1 && length) { | |
return remaining; | |
} else { | |
deferred.resolveWith(elem, [animation]); | |
return false; | |
} | |
}, animation = deferred.promise({ | |
elem: elem, | |
props: jQuery.extend({}, properties), | |
opts: jQuery.extend(true, { | |
specialEasing: {} | |
}, options), | |
originalProperties: properties, | |
originalOptions: options, | |
startTime: fxNow || createFxNow(), | |
duration: options.duration, | |
tweens: [], | |
createTween: function (prop, end) { | |
var tween = jQuery.Tween(elem, animation.opts, prop, end, animation.opts.specialEasing[prop] || animation.opts.easing); | |
animation.tweens.push(tween); | |
return tween; | |
}, | |
stop: function (gotoEnd) { | |
var index = 0, | |
length = gotoEnd ? animation.tweens.length : 0; | |
if (stopped) { | |
return this; | |
} | |
stopped = true; | |
for (; index < length; index++) { | |
animation.tweens[index].run(1); | |
} | |
if (gotoEnd) { | |
deferred.resolveWith(elem, [animation, gotoEnd]); | |
} else { | |
deferred.rejectWith(elem, [animation, gotoEnd]); | |
} | |
return this; | |
} | |
}), | |
props = animation.props; | |
propFilter(props, animation.opts.specialEasing); | |
for (; index < length; index++) { | |
result = animationPrefilters[index].call(animation, elem, props, animation.opts); | |
if (result) { | |
return result; | |
} | |
} | |
createTweens(animation, props); | |
if (jQuery.isFunction(animation.opts.start)) { | |
animation.opts.start.call(elem, animation); | |
} | |
jQuery.fx.timer(jQuery.extend(tick, { | |
elem: elem, | |
anim: animation, | |
queue: animation.opts.queue | |
})); | |
return animation.progress(animation.opts.progress).done(animation.opts.done, animation.opts.complete).fail(animation.opts.fail).always(animation.opts.always); | |
} | |
function propFilter(props, specialEasing) { | |
var index, name, easing, value, hooks; | |
for (index in props) { | |
name = jQuery.camelCase(index); | |
easing = specialEasing[name]; | |
value = props[index]; | |
if (jQuery.isArray(value)) { | |
easing = value[1]; | |
value = props[index] = value[0]; | |
} | |
if (index !== name) { | |
props[name] = value; | |
delete props[index]; | |
} | |
hooks = jQuery.cssHooks[name]; | |
if (hooks && "expand" in hooks) { | |
value = hooks.expand(value); | |
delete props[name]; | |
for (index in value) { | |
if (!(index in props)) { | |
props[index] = value[index]; | |
specialEasing[index] = easing; | |
} | |
} | |
} else { | |
specialEasing[name] = easing; | |
} | |
} | |
} | |
jQuery.Animation = jQuery.extend(Animation, { | |
tweener: function (props, callback) { | |
if (jQuery.isFunction(props)) { | |
callback = props; | |
props = ["*"]; | |
} else { | |
props = props.split(" "); | |
} | |
var prop, index = 0, | |
length = props.length; | |
for (; index < length; index++) { | |
prop = props[index]; | |
tweeners[prop] = tweeners[prop] || []; | |
tweeners[prop].unshift(callback); | |
} | |
}, | |
prefilter: function (callback, prepend) { | |
if (prepend) { | |
animationPrefilters.unshift(callback); | |
} else { | |
animationPrefilters.push(callback); | |
} | |
} | |
}); | |
function defaultPrefilter(elem, props, opts) { | |
var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire, anim = this, | |
style = elem.style, | |
orig = {}, handled = [], | |
hidden = elem.nodeType && isHidden(elem); | |
if (!opts.queue) { | |
hooks = jQuery._queueHooks(elem, "fx"); | |
if (hooks.unqueued == null) { | |
hooks.unqueued = 0; | |
oldfire = hooks.empty.fire; | |
hooks.empty.fire = function () { | |
if (!hooks.unqueued) { | |
oldfire(); | |
} | |
}; | |
} | |
hooks.unqueued++; | |
anim.always(function () { | |
anim.always(function () { | |
hooks.unqueued--; | |
if (!jQuery.queue(elem, "fx").length) { | |
hooks.empty.fire(); | |
} | |
}); | |
}); | |
} | |
if (elem.nodeType === 1 && ("height" in props || "width" in props)) { | |
opts.overflow = [style.overflow, style.overflowX, style.overflowY]; | |
if (jQuery.css(elem, "display") === "inline" && jQuery.css(elem, "float") === "none") { | |
style.display = "inline-block"; | |
} | |
} | |
if (opts.overflow) { | |
style.overflow = "hidden"; | |
anim.always(function () { | |
style.overflow = opts.overflow[0]; | |
style.overflowX = opts.overflow[1]; | |
style.overflowY = opts.overflow[2]; | |
}); | |
} | |
dataShow = data_priv.get(elem, "fxshow"); | |
for (index in props) { | |
value = props[index]; | |
if (rfxtypes.exec(value)) { | |
delete props[index]; | |
toggle = toggle || value === "toggle"; | |
if (value === (hidden ? "hide" : "show")) { | |
if (value === "show" && dataShow !== undefined && dataShow[index] !== undefined) { | |
hidden = true; | |
} else { | |
continue; | |
} | |
} | |
handled.push(index); | |
} | |
} | |
length = handled.length; | |
if (length) { | |
dataShow = data_priv.get(elem, "fxshow") || data_priv.access(elem, "fxshow", {}); | |
if ("hidden" in dataShow) { | |
hidden = dataShow.hidden; | |
} | |
if (toggle) { | |
dataShow.hidden = !hidden; | |
} | |
if (hidden) { | |
jQuery(elem).show(); | |
} else { | |
anim.done(function () { | |
jQuery(elem).hide(); | |
}); | |
} | |
anim.done(function () { | |
var prop; | |
data_priv.remove(elem, "fxshow"); | |
for (prop in orig) { | |
jQuery.style(elem, prop, orig[prop]); | |
} | |
}); | |
for (index = 0; index < length; index++) { | |
prop = handled[index]; | |
tween = anim.createTween(prop, hidden ? dataShow[prop] : 0); | |
orig[prop] = dataShow[prop] || jQuery.style(elem, prop); | |
if (!(prop in dataShow)) { | |
dataShow[prop] = tween.start; | |
if (hidden) { | |
tween.end = tween.start; | |
tween.start = prop === "width" || prop === "height" ? 1 : 0; | |
} | |
} | |
} | |
} | |
} | |
function Tween(elem, options, prop, end, easing) { | |
return new Tween.prototype.init(elem, options, prop, end, easing); | |
} | |
jQuery.Tween = Tween; | |
Tween.prototype = { | |
constructor: Tween, | |
init: function (elem, options, prop, end, easing, unit) { | |
this.elem = elem; | |
this.prop = prop; | |
this.easing = easing || "swing"; | |
this.options = options; | |
this.start = this.now = this.cur(); | |
this.end = end; | |
this.unit = unit || (jQuery.cssNumber[prop] ? "" : "px"); | |
}, | |
cur: function () { | |
var hooks = Tween.propHooks[this.prop]; | |
return hooks && hooks.get ? hooks.get(this) : Tween.propHooks._default.get(this); | |
}, | |
run: function (percent) { | |
var eased, hooks = Tween.propHooks[this.prop]; | |
if (this.options.duration) { | |
this.pos = eased = jQuery.easing[this.easing](percent, this.options.duration * percent, 0, 1, this.options.duration); | |
} else { | |
this.pos = eased = percent; | |
} | |
this.now = (this.end - this.start) * eased + this.start; | |
if (this.options.step) { | |
this.options.step.call(this.elem, this.now, this); | |
} | |
if (hooks && hooks.set) { | |
hooks.set(this); | |
} else { | |
Tween.propHooks._default.set(this); | |
} | |
return this; | |
} | |
}; | |
Tween.prototype.init.prototype = Tween.prototype; | |
Tween.propHooks = { | |
_default: { | |
get: function (tween) { | |
var result; | |
if (tween.elem[tween.prop] != null && (!tween.elem.style || tween.elem.style[tween.prop] == null)) { | |
return tween.elem[tween.prop]; | |
} | |
result = jQuery.css(tween.elem, tween.prop, ""); | |
return !result || result === "auto" ? 0 : result; | |
}, | |
set: function (tween) { | |
if (jQuery.fx.step[tween.prop]) { | |
jQuery.fx.step[tween.prop](tween); | |
} else if (tween.elem.style && (tween.elem.style[jQuery.cssProps[tween.prop]] != null || jQuery.cssHooks[tween.prop])) { | |
jQuery.style(tween.elem, tween.prop, tween.now + tween.unit); | |
} else { | |
tween.elem[tween.prop] = tween.now; | |
} | |
} | |
} | |
}; | |
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { | |
set: function (tween) { | |
if (tween.elem.nodeType && tween.elem.parentNode) { | |
tween.elem[tween.prop] = tween.now; | |
} | |
} | |
}; | |
jQuery.each(["toggle", "show", "hide"], function (i, name) { | |
var cssFn = jQuery.fn[name]; | |
jQuery.fn[name] = function (speed, easing, callback) { | |
return speed == null || typeof speed === "boolean" ? cssFn.apply(this, arguments) : this.animate(genFx(name, true), speed, easing, callback); | |
}; | |
}); | |
jQuery.fn.extend({ | |
fadeTo: function (speed, to, easing, callback) { | |
return this.filter(isHidden).css("opacity", 0).show().end().animate({ | |
opacity: to | |
}, speed, easing, callback); | |
}, | |
animate: function (prop, speed, easing, callback) { | |
var empty = jQuery.isEmptyObject(prop), | |
optall = jQuery.speed(speed, easing, callback), | |
doAnimation = function () { | |
var anim = Animation(this, jQuery.extend({}, prop), optall); | |
doAnimation.finish = function () { | |
anim.stop(true); | |
}; | |
if (empty || data_priv.get(this, "finish")) { | |
anim.stop(true); | |
} | |
}; | |
doAnimation.finish = doAnimation; | |
return empty || optall.queue === false ? this.each(doAnimation) : this.queue(optall.queue, doAnimation); | |
}, | |
stop: function (type, clearQueue, gotoEnd) { | |
var stopQueue = function (hooks) { | |
var stop = hooks.stop; | |
delete hooks.stop; | |
stop(gotoEnd); | |
}; | |
if (typeof type !== "string") { | |
gotoEnd = clearQueue; | |
clearQueue = type; | |
type = undefined; | |
} | |
if (clearQueue && type !== false) { | |
this.queue(type || "fx", []); | |
} | |
return this.each(function () { | |
var dequeue = true, | |
index = type != null && type + "queueHooks", | |
timers = jQuery.timers, | |
data = data_priv.get(this); | |
if (index) { | |
if (data[index] && data[index].stop) { | |
stopQueue(data[index]); | |
} | |
} else { | |
for (index in data) { | |
if (data[index] && data[index].stop && rrun.test(index)) { | |
stopQueue(data[index]); | |
} | |
} | |
} | |
for (index = timers.length; index--;) { | |
if (timers[index].elem === this && (type == null || timers[index].queue === type)) { | |
timers[index].anim.stop(gotoEnd); | |
dequeue = false; | |
timers.splice(index, 1); | |
} | |
} | |
if (dequeue || !gotoEnd) { | |
jQuery.dequeue(this, type); | |
} | |
}); | |
}, | |
finish: function (type) { | |
if (type !== false) { | |
type = type || "fx"; | |
} | |
return this.each(function () { | |
var index, data = data_priv.get(this), | |
queue = data[type + "queue"], | |
hooks = data[type + "queueHooks"], | |
timers = jQuery.timers, | |
length = queue ? queue.length : 0; | |
data.finish = true; | |
jQuery.queue(this, type, []); | |
if (hooks && hooks.cur && hooks.cur.finish) { | |
hooks.cur.finish.call(this); | |
} | |
for (index = timers.length; index--;) { | |
if (timers[index].elem === this && timers[index].queue === type) { | |
timers[index].anim.stop(true); | |
timers.splice(index, 1); | |
} | |
} | |
for (index = 0; index < length; index++) { | |
if (queue[index] && queue[index].finish) { | |
queue[index].finish.call(this); | |
} | |
} | |
delete data.finish; | |
}); | |
} | |
}); | |
function genFx(type, includeWidth) { | |
var which, attrs = { | |
height: type | |
}, i = 0; | |
includeWidth = includeWidth ? 1 : 0; | |
for (; i < 4; i += 2 - includeWidth) { | |
which = cssExpand[i]; | |
attrs["margin" + which] = attrs["padding" + which] = type; | |
} | |
if (includeWidth) { | |
attrs.opacity = attrs.width = type; | |
} | |
return attrs; | |
} | |
jQuery.each({ | |
slideDown: genFx("show"), | |
slideUp: genFx("hide"), | |
slideToggle: genFx("toggle"), | |
fadeIn: { | |
opacity: "show" | |
}, | |
fadeOut: { | |
opacity: "hide" | |
}, | |
fadeToggle: { | |
opacity: "toggle" | |
} | |
}, function (name, props) { | |
jQuery.fn[name] = function (speed, easing, callback) { | |
return this.animate(props, speed, easing, callback); | |
}; | |
}); | |
jQuery.speed = function (speed, easing, fn) { | |
var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : { | |
complete: fn || !fn && easing || jQuery.isFunction(speed) && speed, | |
duration: speed, | |
easing: fn && easing || easing && !jQuery.isFunction(easing) && easing | |
}; | |
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default; | |
if (opt.queue == null || opt.queue === true) { | |
opt.queue = "fx"; | |
} | |
opt.old = opt.complete; | |
opt.complete = function () { | |
if (jQuery.isFunction(opt.old)) { | |
opt.old.call(this); | |
} | |
if (opt.queue) { | |
jQuery.dequeue(this, opt.queue); | |
} | |
}; | |
return opt; | |
}; | |
jQuery.easing = { | |
linear: function (p) { | |
return p; | |
}, | |
swing: function (p) { | |
return 0.5 - Math.cos(p * Math.PI) / 2; | |
} | |
}; | |
jQuery.timers = []; | |
jQuery.fx = Tween.prototype.init; | |
jQuery.fx.tick = function () { | |
var timer, timers = jQuery.timers, | |
i = 0; | |
fxNow = jQuery.now(); | |
for (; i < timers.length; i++) { | |
timer = timers[i]; | |
if (!timer() && timers[i] === timer) { | |
timers.splice(i--, 1); | |
} | |
} | |
if (!timers.length) { | |
jQuery.fx.stop(); | |
} | |
fxNow = undefined; | |
}; | |
jQuery.fx.timer = function (timer) { | |
if (timer() && jQuery.timers.push(timer)) { | |
jQuery.fx.start(); | |
} | |
}; | |
jQuery.fx.interval = 13; | |
jQuery.fx.start = function () { | |
if (!timerId) { | |
timerId = setInterval(jQuery.fx.tick, jQuery.fx.interval); | |
} | |
}; | |
jQuery.fx.stop = function () { | |
clearInterval(timerId); | |
timerId = null; | |
}; | |
jQuery.fx.speeds = { | |
slow: 600, | |
fast: 200, | |
_default: 400 | |
}; | |
jQuery.fx.step = {}; | |
if (jQuery.expr && jQuery.expr.filters) { | |
jQuery.expr.filters.animated = function (elem) { | |
return jQuery.grep(jQuery.timers, function (fn) { | |
return elem === fn.elem; | |
}).length; | |
}; | |
} | |
jQuery.fn.offset = function (options) { | |
if (arguments.length) { | |
return options === undefined ? this : this.each(function (i) { | |
jQuery.offset.setOffset(this, options, i); | |
}); | |
} | |
var docElem, win, elem = this[0], | |
box = { | |
top: 0, | |
left: 0 | |
}, doc = elem && elem.ownerDocument; | |
if (!doc) { | |
return; | |
} | |
docElem = doc.documentElement; | |
if (!jQuery.contains(docElem, elem)) { | |
return box; | |
} | |
if (typeof elem.getBoundingClientRect !== core_strundefined) { | |
box = elem.getBoundingClientRect(); | |
} | |
win = getWindow(doc); | |
return { | |
top: box.top + win.pageYOffset - docElem.clientTop, | |
left: box.left + win.pageXOffset - docElem.clientLeft | |
}; | |
}; | |
jQuery.offset = { | |
setOffset: function (elem, options, i) { | |
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, position = jQuery.css(elem, "position"), | |
curElem = jQuery(elem), | |
props = {}; | |
if (position === "static") { | |
elem.style.position = "relative"; | |
} | |
curOffset = curElem.offset(); | |
curCSSTop = jQuery.css(elem, "top"); | |
curCSSLeft = jQuery.css(elem, "left"); | |
calculatePosition = (position === "absolute" || position === "fixed") && (curCSSTop + curCSSLeft).indexOf("auto") > -1; | |
if (calculatePosition) { | |
curPosition = curElem.position(); | |
curTop = curPosition.top; | |
curLeft = curPosition.left; | |
} else { | |
curTop = parseFloat(curCSSTop) || 0; | |
curLeft = parseFloat(curCSSLeft) || 0; | |
} | |
if (jQuery.isFunction(options)) { | |
options = options.call(elem, i, curOffset); | |
} | |
if (options.top != null) { | |
props.top = (options.top - curOffset.top) + curTop; | |
} | |
if (options.left != null) { | |
props.left = (options.left - curOffset.left) + curLeft; | |
} | |
if ("using" in options) { | |
options.using.call(elem, props); | |
} else { | |
curElem.css(props); | |
} | |
} | |
}; | |
jQuery.fn.extend({ | |
position: function () { | |
if (!this[0]) { | |
return; | |
} | |
var offsetParent, offset, elem = this[0], | |
parentOffset = { | |
top: 0, | |
left: 0 | |
}; | |
if (jQuery.css(elem, "position") === "fixed") { | |
offset = elem.getBoundingClientRect(); | |
} else { | |
offsetParent = this.offsetParent(); | |
offset = this.offset(); | |
if (!jQuery.nodeName(offsetParent[0], "html")) { | |
parentOffset = offsetParent.offset(); | |
} | |
parentOffset.top += jQuery.css(offsetParent[0], "borderTopWidth", true); | |
parentOffset.left += jQuery.css(offsetParent[0], "borderLeftWidth", true); | |
} | |
return { | |
top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true), | |
left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true) | |
}; | |
}, | |
offsetParent: function () { | |
return this.map(function () { | |
var offsetParent = this.offsetParent || docElem; | |
while (offsetParent && (!jQuery.nodeName(offsetParent, "html") && jQuery.css(offsetParent, "position") === "static")) { | |
offsetParent = offsetParent.offsetParent; | |
} | |
return offsetParent || docElem; | |
}); | |
} | |
}); | |
jQuery.each({ | |
scrollLeft: "pageXOffset", | |
scrollTop: "pageYOffset" | |
}, function (method, prop) { | |
var top = "pageYOffset" === prop; | |
jQuery.fn[method] = function (val) { | |
return jQuery.access(this, function (elem, method, val) { | |
var win = getWindow(elem); | |
if (val === undefined) { | |
return win ? win[prop] : elem[method]; | |
} | |
if (win) { | |
win.scrollTo(!top ? val : window.pageXOffset, top ? val : window.pageYOffset); | |
} else { | |
elem[method] = val; | |
} | |
}, method, val, arguments.length, null); | |
}; | |
}); | |
function getWindow(elem) { | |
return jQuery.isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView; | |
} | |
jQuery.each({ | |
Height: "height", | |
Width: "width" | |
}, function (name, type) { | |
jQuery.each({ | |
padding: "inner" + name, | |
content: type, | |
"": "outer" + name | |
}, function (defaultExtra, funcName) { | |
jQuery.fn[funcName] = function (margin, value) { | |
var chainable = arguments.length && (defaultExtra || typeof margin !== "boolean"), | |
extra = defaultExtra || (margin === true || value === true ? "margin" : "border"); | |
return jQuery.access(this, function (elem, type, value) { | |
var doc; | |
if (jQuery.isWindow(elem)) { | |
return elem.document.documentElement["client" + name]; | |
} | |
if (elem.nodeType === 9) { | |
doc = elem.documentElement; | |
return Math.max(elem.body["scroll" + name], doc["scroll" + name], elem.body["offset" + name], doc["offset" + name], doc["client" + name]); | |
} | |
return value === undefined ? jQuery.css(elem, type, extra) : jQuery.style(elem, type, value, extra); | |
}, type, chainable ? margin : undefined, chainable, null); | |
}; | |
}); | |
}); | |
jQuery.fn.size = function () { | |
return this.length; | |
}; | |
jQuery.fn.andSelf = jQuery.fn.addBack; | |
if (typeof module === "object" && typeof module.exports === "object") { | |
module.exports = jQuery; | |
} else { | |
if (typeof define === "function" && define.amd) { | |
define("jquery", [], function () { | |
return jQuery; | |
}); | |
} | |
} | |
if (typeof window === "object" && typeof window.document === "object") { | |
window.jQuery = window.$ = jQuery; | |
} | |
})(window); | |
(function () { | |
var root = this; | |
var previousBackbone = root.Backbone; | |
var array = []; | |
var push = array.push; | |
var slice = array.slice; | |
var splice = array.splice; | |
var Backbone; | |
if (typeof exports !== 'undefined') { | |
Backbone = exports; | |
} else { | |
Backbone = root.Backbone = {}; | |
} | |
Backbone.VERSION = '1.0.0'; | |
var _ = root._; | |
if (!_ && (typeof require !== 'undefined')) _ = require('underscore'); | |
Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$; | |
Backbone.noConflict = function () { | |
root.Backbone = previousBackbone; | |
return this; | |
}; | |
Backbone.emulateHTTP = false; | |
Backbone.emulateJSON = false; | |
var Events = Backbone.Events = { | |
on: function (name, callback, context) { | |
if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this; | |
this._events || (this._events = {}); | |
var events = this._events[name] || (this._events[name] = []); | |
events.push({ | |
callback: callback, | |
context: context, | |
ctx: context || this | |
}); | |
return this; | |
}, | |
once: function (name, callback, context) { | |
if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this; | |
var self = this; | |
var once = _.once(function () { | |
self.off(name, once); | |
callback.apply(this, arguments); | |
}); | |
once._callback = callback; | |
return this.on(name, once, context); | |
}, | |
off: function (name, callback, context) { | |
var retain, ev, events, names, i, l, j, k; | |
if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; | |
if (!name && !callback && !context) { | |
this._events = {}; | |
return this; | |
} | |
names = name ? [name] : _.keys(this._events); | |
for (i = 0, l = names.length; i < l; i++) { | |
name = names[i]; | |
if (events = this._events[name]) { | |
this._events[name] = retain = []; | |
if (callback || context) { | |
for (j = 0, k = events.length; j < k; j++) { | |
ev = events[j]; | |
if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || (context && context !== ev.context)) { | |
retain.push(ev); | |
} | |
} | |
} | |
if (!retain.length) delete this._events[name]; | |
} | |
} | |
return this; | |
}, | |
trigger: function (name) { | |
if (!this._events) return this; | |
var args = slice.call(arguments, 1); | |
if (!eventsApi(this, 'trigger', name, args)) return this; | |
var events = this._events[name]; | |
var allEvents = this._events.all; | |
if (events) triggerEvents(events, args); | |
if (allEvents) triggerEvents(allEvents, arguments); | |
return this; | |
}, | |
stopListening: function (obj, name, callback) { | |
var listeners = this._listeners; | |
if (!listeners) return this; | |
var deleteListener = !name && !callback; | |
if (typeof name === 'object') callback = this; | |
if (obj)(listeners = {})[obj._listenerId] = obj; | |
for (var id in listeners) { | |
listeners[id].off(name, callback, this); | |
if (deleteListener) delete this._listeners[id]; | |
} | |
return this; | |
} | |
}; | |
var eventSplitter = /\s+/; | |
var eventsApi = function (obj, action, name, rest) { | |
if (!name) return true; | |
if (typeof name === 'object') { | |
for (var key in name) { | |
obj[action].apply(obj, [key, name[key]].concat(rest)); | |
} | |
return false; | |
} | |
if (eventSplitter.test(name)) { | |
var names = name.split(eventSplitter); | |
for (var i = 0, l = names.length; i < l; i++) { | |
obj[action].apply(obj, [names[i]].concat(rest)); | |
} | |
return false; | |
} | |
return true; | |
}; | |
var triggerEvents = function (events, args) { | |
var ev, i = -1, | |
l = events.length, | |
a1 = args[0], | |
a2 = args[1], | |
a3 = args[2]; | |
switch (args.length) { | |
case 0: | |
while (++i < l)(ev = events[i]).callback.call(ev.ctx); | |
return; | |
case 1: | |
while (++i < l)(ev = events[i]).callback.call(ev.ctx, a1); | |
return; | |
case 2: | |
while (++i < l)(ev = events[i]).callback.call(ev.ctx, a1, a2); | |
return; | |
case 3: | |
while (++i < l)(ev = events[i]).callback.call(ev.ctx, a1, a2, a3); | |
return; | |
default: | |
while (++i < l)(ev = events[i]).callback.apply(ev.ctx, args); | |
} | |
}; | |
var listenMethods = { | |
listenTo: 'on', | |
listenToOnce: 'once' | |
}; | |
_.each(listenMethods, function (implementation, method) { | |
Events[method] = function (obj, name, callback) { | |
var listeners = this._listeners || (this._listeners = {}); | |
var id = obj._listenerId || (obj._listenerId = _.uniqueId('l')); | |
listeners[id] = obj; | |
if (typeof name === 'object') callback = this; | |
obj[implementation](name, callback, this); | |
return this; | |
}; | |
}); | |
Events.bind = Events.on; | |
Events.unbind = Events.off; | |
_.extend(Backbone, Events); | |
var Model = Backbone.Model = function (attributes, options) { | |
var defaults; | |
var attrs = attributes || {}; | |
options || (options = {}); | |
this.cid = _.uniqueId('c'); | |
this.attributes = {}; | |
_.extend(this, _.pick(options, modelOptions)); | |
if (options.parse) attrs = this.parse(attrs, options) || {}; | |
if (defaults = _.result(this, 'defaults')) { | |
attrs = _.defaults({}, attrs, defaults); | |
} | |
this.set(attrs, options); | |
this.changed = {}; | |
this.initialize.apply(this, arguments); | |
}; | |
var modelOptions = ['url', 'urlRoot', 'collection']; | |
_.extend(Model.prototype, Events, { | |
changed: null, | |
validationError: null, | |
idAttribute: 'id', | |
initialize: function () {}, | |
toJSON: function (options) { | |
return _.clone(this.attributes); | |
}, | |
sync: function () { | |
return Backbone.sync.apply(this, arguments); | |
}, | |
get: function (attr) { | |
return this.attributes[attr]; | |
}, | |
escape: function (attr) { | |
return _.escape(this.get(attr)); | |
}, | |
has: function (attr) { | |
return this.get(attr) != null; | |
}, | |
set: function (key, val, options) { | |
var attr, attrs, unset, changes, silent, changing, prev, current; | |
if (key == null) return this; | |
if (typeof key === 'object') { | |
attrs = key; | |
options = val; | |
} else { | |
(attrs = {})[key] = val; | |
} | |
options || (options = {}); | |
if (!this._validate(attrs, options)) return false; | |
unset = options.unset; | |
silent = options.silent; | |
changes = []; | |
changing = this._changing; | |
this._changing = true; | |
if (!changing) { | |
this._previousAttributes = _.clone(this.attributes); | |
this.changed = {}; | |
} | |
current = this.attributes, prev = this._previousAttributes; | |
if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; | |
for (attr in attrs) { | |
val = attrs[attr]; | |
if (!_.isEqual(current[attr], val)) changes.push(attr); | |
if (!_.isEqual(prev[attr], val)) { | |
this.changed[attr] = val; | |
} else { | |
delete this.changed[attr]; | |
} | |
unset ? delete current[attr] : current[attr] = val; | |
} | |
if (!silent) { | |
if (changes.length) this._pending = true; | |
for (var i = 0, l = changes.length; i < l; i++) { | |
this.trigger('change:' + changes[i], this, current[changes[i]], options); | |
} | |
} | |
if (changing) return this; | |
if (!silent) { | |
while (this._pending) { | |
this._pending = false; | |
this.trigger('change', this, options); | |
} | |
} | |
this._pending = false; | |
this._changing = false; | |
return this; | |
}, | |
unset: function (attr, options) { | |
return this.set(attr, void 0, _.extend({}, options, { | |
unset: true | |
})); | |
}, | |
clear: function (options) { | |
var attrs = {}; | |
for (var key in this.attributes) attrs[key] = void 0; | |
return this.set(attrs, _.extend({}, options, { | |
unset: true | |
})); | |
}, | |
hasChanged: function (attr) { | |
if (attr == null) return !_.isEmpty(this.changed); | |
return _.has(this.changed, attr); | |
}, | |
changedAttributes: function (diff) { | |
if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; | |
var val, changed = false; | |
var old = this._changing ? this._previousAttributes : this.attributes; | |
for (var attr in diff) { | |
if (_.isEqual(old[attr], (val = diff[attr]))) continue; | |
(changed || (changed = {}))[attr] = val; | |
} | |
return changed; | |
}, | |
previous: function (attr) { | |
if (attr == null || !this._previousAttributes) return null; | |
return this._previousAttributes[attr]; | |
}, | |
previousAttributes: function () { | |
return _.clone(this._previousAttributes); | |
}, | |
fetch: function (options) { | |
options = options ? _.clone(options) : {}; | |
if (options.parse === void 0) options.parse = true; | |
var model = this; | |
var success = options.success; | |
options.success = function (resp) { | |
if (!model.set(model.parse(resp, options), options)) return false; | |
if (success) success(model, resp, options); | |
model.trigger('sync', model, resp, options); | |
}; | |
wrapError(this, options); | |
return this.sync('read', this, options); | |
}, | |
save: function (key, val, options) { | |
var attrs, method, xhr, attributes = this.attributes; | |
if (key == null || typeof key === 'object') { | |
attrs = key; | |
options = val; | |
} else { | |
(attrs = {})[key] = val; | |
} | |
if (attrs && (!options || !options.wait) && !this.set(attrs, options)) return false; | |
options = _.extend({ | |
validate: true | |
}, options); | |
if (!this._validate(attrs, options)) return false; | |
if (attrs && options.wait) { | |
this.attributes = _.extend({}, attributes, attrs); | |
} | |
if (options.parse === void 0) options.parse = true; | |
var model = this; | |
var success = options.success; | |
options.success = function (resp) { | |
model.attributes = attributes; | |
var serverAttrs = model.parse(resp, options); | |
if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); | |
if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { | |
return false; | |
} | |
if (success) success(model, resp, options); | |
model.trigger('sync', model, resp, options); | |
}; | |
wrapError(this, options); | |
method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); | |
if (method === 'patch') options.attrs = attrs; | |
xhr = this.sync(method, this, options); | |
if (attrs && options.wait) this.attributes = attributes; | |
return xhr; | |
}, | |
destroy: function (options) { | |
options = options ? _.clone(options) : {}; | |
var model = this; | |
var success = options.success; | |
var destroy = function () { | |
model.trigger('destroy', model, model.collection, options); | |
}; | |
options.success = function (resp) { | |
if (options.wait || model.isNew()) destroy(); | |
if (success) success(model, resp, options); | |
if (!model.isNew()) model.trigger('sync', model, resp, options); | |
}; | |
if (this.isNew()) { | |
options.success(); | |
return false; | |
} | |
wrapError(this, options); | |
var xhr = this.sync('delete', this, options); | |
if (!options.wait) destroy(); | |
return xhr; | |
}, | |
url: function () { | |
var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError(); | |
if (this.isNew()) return base; | |
return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id); | |
}, | |
parse: function (resp, options) { | |
return resp; | |
}, | |
clone: function () { | |
return new this.constructor(this.attributes); | |
}, | |
isNew: function () { | |
return this.id == null; | |
}, | |
isValid: function (options) { | |
return this._validate({}, _.extend(options || {}, { | |
validate: true | |
})); | |
}, | |
_validate: function (attrs, options) { | |
if (!options.validate || !this.validate) return true; | |
attrs = _.extend({}, this.attributes, attrs); | |
var error = this.validationError = this.validate(attrs, options) || null; | |
if (!error) return true; | |
this.trigger('invalid', this, error, _.extend(options || {}, { | |
validationError: error | |
})); | |
return false; | |
} | |
}); | |
var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit']; | |
_.each(modelMethods, function (method) { | |
Model.prototype[method] = function () { | |
var args = slice.call(arguments); | |
args.unshift(this.attributes); | |
return _[method].apply(_, args); | |
}; | |
}); | |
var Collection = Backbone.Collection = function (models, options) { | |
options || (options = {}); | |
if (options.url) this.url = options.url; | |
if (options.model) this.model = options.model; | |
if (options.comparator !== void 0) this.comparator = options.comparator; | |
this._reset(); | |
this.initialize.apply(this, arguments); | |
if (models) this.reset(models, _.extend({ | |
silent: true | |
}, options)); | |
}; | |
var setOptions = { | |
add: true, | |
remove: true, | |
merge: true | |
}; | |
var addOptions = { | |
add: true, | |
merge: false, | |
remove: false | |
}; | |
_.extend(Collection.prototype, Events, { | |
model: Model, | |
initialize: function () {}, | |
toJSON: function (options) { | |
return this.map(function (model) { | |
return model.toJSON(options); | |
}); | |
}, | |
sync: function () { | |
return Backbone.sync.apply(this, arguments); | |
}, | |
add: function (models, options) { | |
return this.set(models, _.defaults(options || {}, addOptions)); | |
}, | |
remove: function (models, options) { | |
models = _.isArray(models) ? models.slice() : [models]; | |
options || (options = {}); | |
var i, l, index, model; | |
for (i = 0, l = models.length; i < l; i++) { | |
model = this.get(models[i]); | |
if (!model) continue; | |
delete this._byId[model.id]; | |
delete this._byId[model.cid]; | |
index = this.indexOf(model); | |
this.models.splice(index, 1); | |
this.length--; | |
if (!options.silent) { | |
options.index = index; | |
model.trigger('remove', model, this, options); | |
} | |
this._removeReference(model); | |
} | |
return this; | |
}, | |
set: function (models, options) { | |
options = _.defaults(options || {}, setOptions); | |
if (options.parse) models = this.parse(models, options); | |
if (!_.isArray(models)) models = models ? [models] : []; | |
var i, l, model, attrs, existing, sort; | |
var at = options.at; | |
var sortable = this.comparator && (at == null) && options.sort !== false; | |
var sortAttr = _.isString(this.comparator) ? this.comparator : null; | |
var toAdd = [], | |
toRemove = [], | |
modelMap = {}; | |
for (i = 0, l = models.length; i < l; i++) { | |
if (!(model = this._prepareModel(models[i], options))) continue; | |
if (existing = this.get(model)) { | |
if (options.remove) modelMap[existing.cid] = true; | |
if (options.merge) { | |
existing.set(model.attributes, options); | |
if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true; | |
} | |
} else if (options.add) { | |
toAdd.push(model); | |
model.on('all', this._onModelEvent, this); | |
this._byId[model.cid] = model; | |
if (model.id != null) this._byId[model.id] = model; | |
} | |
} | |
if (options.remove) { | |
for (i = 0, l = this.length; i < l; ++i) { | |
if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model); | |
} | |
if (toRemove.length) this.remove(toRemove, options); | |
} | |
if (toAdd.length) { | |
if (sortable) sort = true; | |
this.length += toAdd.length; | |
if (at != null) { | |
splice.apply(this.models, [at, 0].concat(toAdd)); | |
} else { | |
push.apply(this.models, toAdd); | |
} | |
} | |
if (sort) this.sort({ | |
silent: true | |
}); | |
if (options.silent) return this; | |
for (i = 0, l = toAdd.length; i < l; i++) { | |
(model = toAdd[i]).trigger('add', model, this, options); | |
} | |
if (sort) this.trigger('sort', this, options); | |
return this; | |
}, | |
reset: function (models, options) { | |
options || (options = {}); | |
for (var i = 0, l = this.models.length; i < l; i++) { | |
this._removeReference(this.models[i]); | |
} | |
options.previousModels = this.models; | |
this._reset(); | |
this.add(models, _.extend({ | |
silent: true | |
}, options)); | |
if (!options.silent) this.trigger('reset', this, options); | |
return this; | |
}, | |
push: function (model, options) { | |
model = this._prepareModel(model, options); | |
this.add(model, _.extend({ | |
at: this.length | |
}, options)); | |
return model; | |
}, | |
pop: function (options) { | |
var model = this.at(this.length - 1); | |
this.remove(model, options); | |
return model; | |
}, | |
unshift: function (model, options) { | |
model = this._prepareModel(model, options); | |
this.add(model, _.extend({ | |
at: 0 | |
}, options)); | |
return model; | |
}, | |
shift: function (options) { | |
var model = this.at(0); | |
this.remove(model, options); | |
return model; | |
}, | |
slice: function (begin, end) { | |
return this.models.slice(begin, end); | |
}, | |
get: function (obj) { | |
if (obj == null) return void 0; | |
return this._byId[obj.id != null ? obj.id : obj.cid || obj]; | |
}, | |
at: function (index) { | |
return this.models[index]; | |
}, | |
where: function (attrs, first) { | |
if (_.isEmpty(attrs)) return first ? void 0 : []; | |
return this[first ? 'find' : 'filter'](function (model) { | |
for (var key in attrs) { | |
if (attrs[key] !== model.get(key)) return false; | |
} | |
return true; | |
}); | |
}, | |
findWhere: function (attrs) { | |
return this.where(attrs, true); | |
}, | |
sort: function (options) { | |
if (!this.comparator) throw new Error('Cannot sort a set without a comparator'); | |
options || (options = {}); | |
if (_.isString(this.comparator) || this.comparator.length === 1) { | |
this.models = this.sortBy(this.comparator, this); | |
} else { | |
this.models.sort(_.bind(this.comparator, this)); | |
} | |
if (!options.silent) this.trigger('sort', this, options); | |
return this; | |
}, | |
sortedIndex: function (model, value, context) { | |
value || (value = this.comparator); | |
var iterator = _.isFunction(value) ? value : function (model) { | |
return model.get(value); | |
}; | |
return _.sortedIndex(this.models, model, iterator, context); | |
}, | |
pluck: function (attr) { | |
return _.invoke(this.models, 'get', attr); | |
}, | |
fetch: function (options) { | |
options = options ? _.clone(options) : {}; | |
if (options.parse === void 0) options.parse = true; | |
var success = options.success; | |
var collection = this; | |
options.success = function (resp) { | |
var method = options.reset ? 'reset' : 'set'; | |
collection[method](resp, options); | |
if (success) success(collection, resp, options); | |
collection.trigger('sync', collection, resp, options); | |
}; | |
wrapError(this, options); | |
return this.sync('read', this, options); | |
}, | |
create: function (model, options) { | |
options = options ? _.clone(options) : {}; | |
if (!(model = this._prepareModel(model, options))) return false; | |
if (!options.wait) this.add(model, options); | |
var collection = this; | |
var success = options.success; | |
options.success = function (resp) { | |
if (options.wait) collection.add(model, options); | |
if (success) success(model, resp, options); | |
}; | |
model.save(null, options); | |
return model; | |
}, | |
parse: function (resp, options) { | |
return resp; | |
}, | |
clone: function () { | |
return new this.constructor(this.models); | |
}, | |
_reset: function () { | |
this.length = 0; | |
this.models = []; | |
this._byId = {}; | |
}, | |
_prepareModel: function (attrs, options) { | |
if (attrs instanceof Model) { | |
if (!attrs.collection) attrs.collection = this; | |
return attrs; | |
} | |
options || (options = {}); | |
options.collection = this; | |
var model = new this.model(attrs, options); | |
if (!model._validate(attrs, options)) { | |
this.trigger('invalid', this, attrs, options); | |
return false; | |
} | |
return model; | |
}, | |
_removeReference: function (model) { | |
if (this === model.collection) delete model.collection; | |
model.off('all', this._onModelEvent, this); | |
}, | |
_onModelEvent: function (event, model, collection, options) { | |
if ((event === 'add' || event === 'remove') && collection !== this) return; | |
if (event === 'destroy') this.remove(model, options); | |
if (model && event === 'change:' + model.idAttribute) { | |
delete this._byId[model.previous(model.idAttribute)]; | |
if (model.id != null) this._byId[model.id] = model; | |
} | |
this.trigger.apply(this, arguments); | |
} | |
}); | |
var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf', 'isEmpty', 'chain']; | |
_.each(methods, function (method) { | |
Collection.prototype[method] = function () { | |
var args = slice.call(arguments); | |
args.unshift(this.models); | |
return _[method].apply(_, args); | |
}; | |
}); | |
var attributeMethods = ['groupBy', 'countBy', 'sortBy']; | |
_.each(attributeMethods, function (method) { | |
Collection.prototype[method] = function (value, context) { | |
var iterator = _.isFunction(value) ? value : function (model) { | |
return model.get(value); | |
}; | |
return _[method](this.models, iterator, context); | |
}; | |
}); | |
var View = Backbone.View = function (options) { | |
this.cid = _.uniqueId('view'); | |
this._configure(options || {}); | |
this._ensureElement(); | |
this.initialize.apply(this, arguments); | |
this.delegateEvents(); | |
}; | |
var delegateEventSplitter = /^(\S+)\s*(.*)$/; | |
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; | |
_.extend(View.prototype, Events, { | |
tagName: 'div', | |
$: function (selector) { | |
return this.$el.find(selector); | |
}, | |
initialize: function () {}, | |
render: function () { | |
return this; | |
}, | |
remove: function () { | |
this.$el.remove(); | |
this.stopListening(); | |
return this; | |
}, | |
setElement: function (element, delegate) { | |
if (this.$el) this.undelegateEvents(); | |
this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); | |
this.el = this.$el[0]; | |
if (delegate !== false) this.delegateEvents(); | |
return this; | |
}, | |
delegateEvents: function (events) { | |
if (!(events || (events = _.result(this, 'events')))) return this; | |
this.undelegateEvents(); | |
for (var key in events) { | |
var method = events[key]; | |
if (!_.isFunction(method)) method = this[events[key]]; | |
if (!method) continue; | |
var match = key.match(delegateEventSplitter); | |
var eventName = match[1], | |
selector = match[2]; | |
method = _.bind(method, this); | |
eventName += '.delegateEvents' + this.cid; | |
if (selector === '') { | |
this.$el.on(eventName, method); | |
} else { | |
this.$el.on(eventName, selector, method); | |
} | |
} | |
return this; | |
}, | |
undelegateEvents: function () { | |
this.$el.off('.delegateEvents' + this.cid); | |
return this; | |
}, | |
_configure: function (options) { | |
if (this.options) options = _.extend({}, _.result(this, 'options'), options); | |
_.extend(this, _.pick(options, viewOptions)); | |
this.options = options; | |
}, | |
_ensureElement: function () { | |
if (!this.el) { | |
var attrs = _.extend({}, _.result(this, 'attributes')); | |
if (this.id) attrs.id = _.result(this, 'id'); | |
if (this.className) attrs['class'] = _.result(this, 'className'); | |
var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs); | |
this.setElement($el, false); | |
} else { | |
this.setElement(_.result(this, 'el'), false); | |
} | |
} | |
}); | |
Backbone.sync = function (method, model, options) { | |
var type = methodMap[method]; | |
_.defaults(options || (options = {}), { | |
emulateHTTP: Backbone.emulateHTTP, | |
emulateJSON: Backbone.emulateJSON | |
}); | |
var params = { | |
type: type, | |
dataType: 'json' | |
}; | |
if (!options.url) { | |
params.url = _.result(model, 'url') || urlError(); | |
} | |
if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { | |
params.contentType = 'application/json'; | |
params.data = JSON.stringify(options.attrs || model.toJSON(options)); | |
} | |
if (options.emulateJSON) { | |
params.contentType = 'application/x-www-form-urlencoded'; | |
params.data = params.data ? { | |
model: params.data | |
} : {}; | |
} | |
if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { | |
params.type = 'POST'; | |
if (options.emulateJSON) params.data._method = type; | |
var beforeSend = options.beforeSend; | |
options.beforeSend = function (xhr) { | |
xhr.setRequestHeader('X-HTTP-Method-Override', type); | |
if (beforeSend) return beforeSend.apply(this, arguments); | |
}; | |
} | |
if (params.type !== 'GET' && !options.emulateJSON) { | |
params.processData = false; | |
} | |
if (params.type === 'PATCH' && window.ActiveXObject && !(window.external && window.external.msActiveXFilteringEnabled)) { | |
params.xhr = function () { | |
return new ActiveXObject("Microsoft.XMLHTTP"); | |
}; | |
} | |
var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); | |
model.trigger('request', model, xhr, options); | |
return xhr; | |
}; | |
var methodMap = { | |
'create': 'POST', | |
'update': 'PUT', | |
'patch': 'PATCH', | |
'delete': 'DELETE', | |
'read': 'GET' | |
}; | |
Backbone.ajax = function () { | |
return Backbone.$.ajax.apply(Backbone.$, arguments); | |
}; | |
var Router = Backbone.Router = function (options) { | |
options || (options = {}); | |
if (options.routes) this.routes = options.routes; | |
this._bindRoutes(); | |
this.initialize.apply(this, arguments); | |
}; | |
var optionalParam = /\((.*?)\)/g; | |
var namedParam = /(\(\?)?:\w+/g; | |
var splatParam = /\*\w+/g; | |
var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; | |
_.extend(Router.prototype, Events, { | |
initialize: function () {}, | |
route: function (route, name, callback) { | |
if (!_.isRegExp(route)) route = this._routeToRegExp(route); | |
if (_.isFunction(name)) { | |
callback = name; | |
name = ''; | |
} | |
if (!callback) callback = this[name]; | |
var router = this; | |
Backbone.history.route(route, function (fragment) { | |
var args = router._extractParameters(route, fragment); | |
callback && callback.apply(router, args); | |
router.trigger.apply(router, ['route:' + name].concat(args)); | |
router.trigger('route', name, args); | |
Backbone.history.trigger('route', router, name, args); | |
}); | |
return this; | |
}, | |
navigate: function (fragment, options) { | |
Backbone.history.navigate(fragment, options); | |
return this; | |
}, | |
_bindRoutes: function () { | |
if (!this.routes) return; | |
this.routes = _.result(this, 'routes'); | |
var route, routes = _.keys(this.routes); | |
while ((route = routes.pop()) != null) { | |
this.route(route, this.routes[route]); | |
} | |
}, | |
_routeToRegExp: function (route) { | |
route = route.replace(escapeRegExp, '\\$&').replace(optionalParam, '(?:$1)?').replace(namedParam, function (match, optional) { | |
return optional ? match : '([^\/]+)'; | |
}).replace(splatParam, '(.*?)'); | |
return new RegExp('^' + route + '$'); | |
}, | |
_extractParameters: function (route, fragment) { | |
var params = route.exec(fragment).slice(1); | |
return _.map(params, function (param) { | |
return param ? decodeURIComponent(param) : null; | |
}); | |
} | |
}); | |
var History = Backbone.History = function () { | |
this.handlers = []; | |
_.bindAll(this, 'checkUrl'); | |
if (typeof window !== 'undefined') { | |
this.location = window.location; | |
this.history = window.history; | |
} | |
}; | |
var routeStripper = /^[#\/]|\s+$/g; | |
var rootStripper = /^\/+|\/+$/g; | |
var isExplorer = /msie [\w.]+/; | |
var trailingSlash = /\/$/; | |
History.started = false; | |
_.extend(History.prototype, Events, { | |
interval: 50, | |
getHash: function (window) { | |
var match = (window || this).location.href.match(/#(.*)$/); | |
return match ? match[1] : ''; | |
}, | |
getFragment: function (fragment, forcePushState) { | |
if (fragment == null) { | |
if (this._hasPushState || !this._wantsHashChange || forcePushState) { | |
fragment = this.location.pathname; | |
var root = this.root.replace(trailingSlash, ''); | |
if (!fragment.indexOf(root)) fragment = fragment.substr(root.length); | |
} else { | |
fragment = this.getHash(); | |
} | |
} | |
return fragment.replace(routeStripper, ''); | |
}, | |
start: function (options) { | |
if (History.started) throw new Error("Backbone.history has already been started"); | |
History.started = true; | |
this.options = _.extend({}, { | |
root: '/' | |
}, this.options, options); | |
this.root = this.options.root; | |
this._wantsHashChange = this.options.hashChange !== false; | |
this._wantsPushState = !! this.options.pushState; | |
this._hasPushState = !! (this.options.pushState && this.history && this.history.pushState); | |
var fragment = this.getFragment(); | |
var docMode = document.documentMode; | |
var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); | |
this.root = ('/' + this.root + '/').replace(rootStripper, '/'); | |
if (oldIE && this._wantsHashChange) { | |
this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow; | |
this.navigate(fragment); | |
} | |
if (this._hasPushState) { | |
Backbone.$(window).on('popstate', this.checkUrl); | |
} else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { | |
Backbone.$(window).on('hashchange', this.checkUrl); | |
} else if (this._wantsHashChange) { | |
this._checkUrlInterval = setInterval(this.checkUrl, this.interval); | |
} | |
this.fragment = fragment; | |
var loc = this.location; | |
var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root; | |
if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) { | |
this.fragment = this.getFragment(null, true); | |
this.location.replace(this.root + this.location.search + '#' + this.fragment); | |
return true; | |
} else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) { | |
this.fragment = this.getHash().replace(routeStripper, ''); | |
this.history.replaceState({}, document.title, this.root + this.fragment + loc.search); | |
} | |
if (!this.options.silent) return this.loadUrl(); | |
}, | |
stop: function () { | |
Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl); | |
clearInterval(this._checkUrlInterval); | |
History.started = false; | |
}, | |
route: function (route, callback) { | |
this.handlers.unshift({ | |
route: route, | |
callback: callback | |
}); | |
}, | |
checkUrl: function (e) { | |
var current = this.getFragment(); | |
if (current === this.fragment && this.iframe) { | |
current = this.getFragment(this.getHash(this.iframe)); | |
} | |
if (current === this.fragment) return false; | |
if (this.iframe) this.navigate(current); | |
this.loadUrl() || this.loadUrl(this.getHash()); | |
}, | |
loadUrl: function (fragmentOverride) { | |
var fragment = this.fragment = this.getFragment(fragmentOverride); | |
var matched = _.any(this.handlers, function (handler) { | |
if (handler.route.test(fragment)) { | |
handler.callback(fragment); | |
return true; | |
} | |
}); | |
return matched; | |
}, | |
navigate: function (fragment, options) { | |
if (!History.started) return false; | |
if (!options || options === true) options = { | |
trigger: options | |
}; | |
fragment = this.getFragment(fragment || ''); | |
if (this.fragment === fragment) return; | |
this.fragment = fragment; | |
var url = this.root + fragment; | |
if (this._hasPushState) { | |
this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url); | |
} else if (this._wantsHashChange) { | |
this._updateHash(this.location, fragment, options.replace); | |
if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) { | |
if (!options.replace) this.iframe.document.open().close(); | |
this._updateHash(this.iframe.location, fragment, options.replace); | |
} | |
} else { | |
return this.location.assign(url); | |
} | |
if (options.trigger) this.loadUrl(fragment); | |
}, | |
_updateHash: function (location, fragment, replace) { | |
if (replace) { | |
var href = location.href.replace(/(javascript:|#).*$/, ''); | |
location.replace(href + '#' + fragment); | |
} else { | |
location.hash = '#' + fragment; | |
} | |
} | |
}); | |
Backbone.history = new History; | |
var extend = function (protoProps, staticProps) { | |
var parent = this; | |
var child; | |
if (protoProps && _.has(protoProps, 'constructor')) { | |
child = protoProps.constructor; | |
} else { | |
child = function () { | |
return parent.apply(this, arguments); | |
}; | |
} | |
_.extend(child, parent, staticProps); | |
var Surrogate = function () { | |
this.constructor = child; | |
}; | |
Surrogate.prototype = parent.prototype; | |
child.prototype = new Surrogate; | |
if (protoProps) _.extend(child.prototype, protoProps); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend; | |
var urlError = function () { | |
throw new Error('A "url" property or function must be specified'); | |
}; | |
var wrapError = function (model, options) { | |
var error = options.error; | |
options.error = function (resp) { | |
if (error) error(model, resp, options); | |
model.trigger('error', model, resp, options); | |
}; | |
}; | |
}).call(this); | |
function blur(img, radius) { | |
var c = document.createElement('canvas'); | |
var context = c.getContext('2d'); | |
c.width = img.width | |
width = c.width | |
c.height = img.height | |
height = c.height | |
context.drawImage(img, 0, 0, width, height); | |
function BlurStack() { | |
this.r = 0; | |
this.g = 0; | |
this.b = 0; | |
this.a = 0; | |
this.next = null; | |
} | |
var mul_table = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259]; | |
var shg_table = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]; | |
var imageData = context.getImageData(0, 0, width, height) | |
var pixels = imageData.data; | |
var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, r_out_sum, g_out_sum, b_out_sum, r_in_sum, g_in_sum, b_in_sum, pr, pg, pb, rbs; | |
var div = radius + radius + 1; | |
var w4 = width << 2; | |
var widthMinus1 = width - 1; | |
var heightMinus1 = height - 1; | |
var radiusPlus1 = radius + 1; | |
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2; | |
var stackStart = new BlurStack(); | |
var stack = stackStart; | |
for (i = 1; i < div; i++) { | |
stack = stack.next = new BlurStack(); | |
if (i == radiusPlus1) var stackEnd = stack; | |
} | |
stack.next = stackStart; | |
var stackIn = null; | |
var stackOut = null; | |
yw = yi = 0; | |
var mul_sum = mul_table[radius]; | |
var shg_sum = shg_table[radius]; | |
for (y = 0; y < height; y++) { | |
r_in_sum = g_in_sum = b_in_sum = r_sum = g_sum = b_sum = 0; | |
r_out_sum = radiusPlus1 * (pr = pixels[yi]); | |
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]); | |
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]); | |
r_sum += sumFactor * pr; | |
g_sum += sumFactor * pg; | |
b_sum += sumFactor * pb; | |
stack = stackStart; | |
for (i = 0; i < radiusPlus1; i++) { | |
stack.r = pr; | |
stack.g = pg; | |
stack.b = pb; | |
stack = stack.next; | |
} | |
for (i = 1; i < radiusPlus1; i++) { | |
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2); | |
r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i); | |
g_sum += (stack.g = (pg = pixels[p + 1])) * rbs; | |
b_sum += (stack.b = (pb = pixels[p + 2])) * rbs; | |
r_in_sum += pr; | |
g_in_sum += pg; | |
b_in_sum += pb; | |
stack = stack.next; | |
} | |
stackIn = stackStart; | |
stackOut = stackEnd; | |
for (x = 0; x < width; x++) { | |
pixels[yi] = (r_sum * mul_sum) >> shg_sum; | |
pixels[yi + 1] = (g_sum * mul_sum) >> shg_sum; | |
pixels[yi + 2] = (b_sum * mul_sum) >> shg_sum; | |
r_sum -= r_out_sum; | |
g_sum -= g_out_sum; | |
b_sum -= b_out_sum; | |
r_out_sum -= stackIn.r; | |
g_out_sum -= stackIn.g; | |
b_out_sum -= stackIn.b; | |
p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2; | |
r_in_sum += (stackIn.r = pixels[p]); | |
g_in_sum += (stackIn.g = pixels[p + 1]); | |
b_in_sum += (stackIn.b = pixels[p + 2]); | |
r_sum += r_in_sum; | |
g_sum += g_in_sum; | |
b_sum += b_in_sum; | |
stackIn = stackIn.next; | |
r_out_sum += (pr = stackOut.r); | |
g_out_sum += (pg = stackOut.g); | |
b_out_sum += (pb = stackOut.b); | |
r_in_sum -= pr; | |
g_in_sum -= pg; | |
b_in_sum -= pb; | |
stackOut = stackOut.next; | |
yi += 4; | |
} | |
yw += width; | |
} | |
for (x = 0; x < width; x++) { | |
g_in_sum = b_in_sum = r_in_sum = g_sum = b_sum = r_sum = 0; | |
yi = x << 2; | |
r_out_sum = radiusPlus1 * (pr = pixels[yi]); | |
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]); | |
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]); | |
r_sum += sumFactor * pr; | |
g_sum += sumFactor * pg; | |
b_sum += sumFactor * pb; | |
stack = stackStart; | |
for (i = 0; i < radiusPlus1; i++) { | |
stack.r = pr; | |
stack.g = pg; | |
stack.b = pb; | |
stack = stack.next; | |
} | |
yp = width; | |
for (i = 1; i <= radius; i++) { | |
yi = (yp + x) << 2; | |
r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i); | |
g_sum += (stack.g = (pg = pixels[yi + 1])) * rbs; | |
b_sum += (stack.b = (pb = pixels[yi + 2])) * rbs; | |
r_in_sum += pr; | |
g_in_sum += pg; | |
b_in_sum += pb; | |
stack = stack.next; | |
if (i < heightMinus1) { | |
yp += width; | |
} | |
} | |
yi = x; | |
stackIn = stackStart; | |
stackOut = stackEnd; | |
for (y = 0; y < height; y++) { | |
p = yi << 2; | |
pixels[p] = (r_sum * mul_sum) >> shg_sum; | |
pixels[p + 1] = (g_sum * mul_sum) >> shg_sum; | |
pixels[p + 2] = (b_sum * mul_sum) >> shg_sum; | |
r_sum -= r_out_sum; | |
g_sum -= g_out_sum; | |
b_sum -= b_out_sum; | |
r_out_sum -= stackIn.r; | |
g_out_sum -= stackIn.g; | |
b_out_sum -= stackIn.b; | |
p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2; | |
r_sum += (r_in_sum += (stackIn.r = pixels[p])); | |
g_sum += (g_in_sum += (stackIn.g = pixels[p + 1])); | |
b_sum += (b_in_sum += (stackIn.b = pixels[p + 2])); | |
stackIn = stackIn.next; | |
r_out_sum += (pr = stackOut.r); | |
g_out_sum += (pg = stackOut.g); | |
b_out_sum += (pb = stackOut.b); | |
r_in_sum -= pr; | |
g_in_sum -= pg; | |
b_in_sum -= pb; | |
stackOut = stackOut.next; | |
yi += width; | |
} | |
} | |
context.putImageData(imageData, 0, 0); | |
var blured_img = new Image(width, height) | |
blured_img.src = c.toDataURL("image/jpeg", 0.85); | |
return blured_img; | |
} | |
(function (window) { | |
'use strict'; | |
var CanvasPrototype = window.HTMLCanvasElement && window.HTMLCanvasElement.prototype, | |
hasBlobConstructor = window.Blob && (function () { | |
try { | |
return Boolean(new Blob()); | |
} catch (e) { | |
return false; | |
} | |
}()), | |
hasArrayBufferViewSupport = hasBlobConstructor && window.Uint8Array && (function () { | |
try { | |
return new Blob([new Uint8Array(100)]).size === 100; | |
} catch (e) { | |
return false; | |
} | |
}()), | |
BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder, | |
dataURLtoBlob = (hasBlobConstructor || BlobBuilder) && window.atob && window.ArrayBuffer && window.Uint8Array && function (dataURI) { | |
var byteString, arrayBuffer, intArray, i, mimeString, bb; | |
if (dataURI.split(',')[0].indexOf('base64') >= 0) { | |
byteString = atob(dataURI.split(',')[1]); | |
} else { | |
byteString = decodeURIComponent(dataURI.split(',')[1]); | |
} | |
arrayBuffer = new ArrayBuffer(byteString.length); | |
intArray = new Uint8Array(arrayBuffer); | |
for (i = 0; i < byteString.length; i += 1) { | |
intArray[i] = byteString.charCodeAt(i); | |
} | |
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; | |
if (hasBlobConstructor) { | |
return new Blob([hasArrayBufferViewSupport ? intArray : arrayBuffer], { | |
type: mimeString | |
}); | |
} | |
bb = new BlobBuilder(); | |
bb.append(arrayBuffer); | |
return bb.getBlob(mimeString); | |
}; | |
if (window.HTMLCanvasElement && !CanvasPrototype.toBlob) { | |
if (CanvasPrototype.mozGetAsFile) { | |
CanvasPrototype.toBlob = function (callback, type, quality) { | |
if (quality && CanvasPrototype.toDataURL && dataURLtoBlob) { | |
callback(dataURLtoBlob(this.toDataURL(type, quality))); | |
} else { | |
callback(this.mozGetAsFile('blob', type)); | |
} | |
}; | |
} else if (CanvasPrototype.toDataURL && dataURLtoBlob) { | |
CanvasPrototype.toBlob = function (callback, type, quality) { | |
callback(dataURLtoBlob(this.toDataURL(type, quality))); | |
}; | |
} | |
} | |
if (typeof define === 'function' && define.amd) { | |
define(function () { | |
return dataURLtoBlob; | |
}); | |
} else { | |
window.dataURLtoBlob = dataURLtoBlob; | |
} | |
}(this)); | |
(function (module) { | |
if (typeof define === 'function' && define.amd) { | |
define(['jquery'], module); | |
} else { | |
module(jQuery); | |
} | |
})(function (jQuery, undefined) { | |
var | |
threshold = 6, | |
add = jQuery.event.add, | |
remove = jQuery.event.remove, | |
trigger = function (node, type, data) { | |
jQuery.event.trigger(type, data, node); | |
}, requestFrame = (function () { | |
return (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (fn, element) { | |
return window.setTimeout(function () { | |
fn(); | |
}, 25); | |
}); | |
})(), | |
ignoreTags = { | |
textarea: true, | |
input: true, | |
select: true, | |
button: true | |
}, mouseevents = { | |
move: 'mousemove', | |
cancel: 'mouseup dragstart', | |
end: 'mouseup' | |
}, touchevents = { | |
move: 'touchmove', | |
cancel: 'touchend', | |
end: 'touchend' | |
}; | |
function Timer(fn) { | |
var callback = fn, | |
active = false, | |
running = false; | |
function trigger(time) { | |
if (active) { | |
callback(); | |
requestFrame(trigger); | |
running = true; | |
active = false; | |
} else { | |
running = false; | |
} | |
} | |
this.kick = function (fn) { | |
active = true; | |
if (!running) { | |
trigger(); | |
} | |
}; | |
this.end = function (fn) { | |
var cb = callback; | |
if (!fn) { | |
return; | |
} | |
if (!running) { | |
fn(); | |
} else { | |
callback = active ? function () { | |
cb(); | |
fn(); | |
} : fn; | |
active = true; | |
} | |
}; | |
} | |
function returnTrue() { | |
return true; | |
} | |
function returnFalse() { | |
return false; | |
} | |
function preventDefault(e) { | |
e.preventDefault(); | |
} | |
function preventIgnoreTags(e) { | |
if (ignoreTags[e.target.tagName.toLowerCase()]) { | |
return; | |
} | |
e.preventDefault(); | |
} | |
function isLeftButton(e) { | |
return (e.which === 1 && !e.ctrlKey && !e.altKey); | |
} | |
function identifiedTouch(touchList, id) { | |
var i, l; | |
if (touchList.identifiedTouch) { | |
return touchList.identifiedTouch(id); | |
} | |
i = -1; | |
l = touchList.length; | |
while (++i < l) { | |
if (touchList[i].identifier === id) { | |
return touchList[i]; | |
} | |
} | |
} | |
function changedTouch(e, event) { | |
var touch = identifiedTouch(e.changedTouches, event.identifier); | |
if (!touch) { | |
return; | |
} | |
if (touch.pageX === event.pageX && touch.pageY === event.pageY) { | |
return; | |
} | |
return touch; | |
} | |
function mousedown(e) { | |
var data; | |
if (!isLeftButton(e)) { | |
return; | |
} | |
data = { | |
target: e.target, | |
startX: e.pageX, | |
startY: e.pageY, | |
timeStamp: e.timeStamp | |
}; | |
add(document, mouseevents.move, mousemove, data); | |
add(document, mouseevents.cancel, mouseend, data); | |
} | |
function mousemove(e) { | |
var data = e.data; | |
checkThreshold(e, data, e, removeMouse); | |
} | |
function mouseend(e) { | |
removeMouse(); | |
} | |
function removeMouse() { | |
remove(document, mouseevents.move, mousemove); | |
remove(document, mouseevents.cancel, mouseend); | |
} | |
function touchstart(e) { | |
var touch, template; | |
if (ignoreTags[e.target.tagName.toLowerCase()]) { | |
return; | |
} | |
touch = e.changedTouches[0]; | |
template = { | |
target: touch.target, | |
startX: touch.pageX, | |
startY: touch.pageY, | |
timeStamp: e.timeStamp, | |
identifier: touch.identifier | |
}; | |
add(document, touchevents.move + '.' + touch.identifier, touchmove, template); | |
add(document, touchevents.cancel + '.' + touch.identifier, touchend, template); | |
} | |
function touchmove(e) { | |
var data = e.data, | |
touch = changedTouch(e, data); | |
if (!touch) { | |
return; | |
} | |
checkThreshold(e, data, touch, removeTouch); | |
} | |
function touchend(e) { | |
var template = e.data, | |
touch = identifiedTouch(e.changedTouches, template.identifier); | |
if (!touch) { | |
return; | |
} | |
removeTouch(template.identifier); | |
} | |
function removeTouch(identifier) { | |
remove(document, '.' + identifier, touchmove); | |
remove(document, '.' + identifier, touchend); | |
} | |
function checkThreshold(e, template, touch, fn) { | |
var distX = touch.pageX - template.startX, | |
distY = touch.pageY - template.startY; | |
if ((distX * distX) + (distY * distY) < (threshold * threshold)) { | |
return; | |
} | |
triggerStart(e, template, touch, distX, distY, fn); | |
} | |
function handled() { | |
this._handled = returnTrue; | |
return false; | |
} | |
function flagAsHandled(e) { | |
e._handled(); | |
} | |
function triggerStart(e, template, touch, distX, distY, fn) { | |
var node = template.target, | |
touches, time; | |
touches = e.targetTouches; | |
time = e.timeStamp - template.timeStamp; | |
template.type = 'movestart'; | |
template.distX = distX; | |
template.distY = distY; | |
template.deltaX = distX; | |
template.deltaY = distY; | |
template.pageX = touch.pageX; | |
template.pageY = touch.pageY; | |
template.velocityX = distX / time; | |
template.velocityY = distY / time; | |
template.targetTouches = touches; | |
template.finger = touches ? touches.length : 1; | |
template._handled = handled; | |
template._preventTouchmoveDefault = function () { | |
e.preventDefault(); | |
}; | |
trigger(template.target, template); | |
fn(template.identifier); | |
} | |
function activeMousemove(e) { | |
var event = e.data.event, | |
timer = e.data.timer; | |
updateEvent(event, e, e.timeStamp, timer); | |
} | |
function activeMouseend(e) { | |
var event = e.data.event, | |
timer = e.data.timer; | |
removeActiveMouse(); | |
endEvent(event, timer, function () { | |
setTimeout(function () { | |
remove(event.target, 'click', returnFalse); | |
}, 0); | |
}); | |
} | |
function removeActiveMouse(event) { | |
remove(document, mouseevents.move, activeMousemove); | |
remove(document, mouseevents.end, activeMouseend); | |
} | |
function activeTouchmove(e) { | |
var event = e.data.event, | |
timer = e.data.timer, | |
touch = changedTouch(e, event); | |
if (!touch) { | |
return; | |
} | |
e.preventDefault(); | |
event.targetTouches = e.targetTouches; | |
updateEvent(event, touch, e.timeStamp, timer); | |
} | |
function activeTouchend(e) { | |
var event = e.data.event, | |
timer = e.data.timer, | |
touch = identifiedTouch(e.changedTouches, event.identifier); | |
if (!touch) { | |
return; | |
} | |
removeActiveTouch(event); | |
endEvent(event, timer); | |
} | |
function removeActiveTouch(event) { | |
remove(document, '.' + event.identifier, activeTouchmove); | |
remove(document, '.' + event.identifier, activeTouchend); | |
} | |
function updateEvent(event, touch, timeStamp, timer) { | |
var time = timeStamp - event.timeStamp; | |
event.type = 'move'; | |
event.distX = touch.pageX - event.startX; | |
event.distY = touch.pageY - event.startY; | |
event.deltaX = touch.pageX - event.pageX; | |
event.deltaY = touch.pageY - event.pageY; | |
event.velocityX = 0.3 * event.velocityX + 0.7 * event.deltaX / time; | |
event.velocityY = 0.3 * event.velocityY + 0.7 * event.deltaY / time; | |
event.pageX = touch.pageX; | |
event.pageY = touch.pageY; | |
timer.kick(); | |
} | |
function endEvent(event, timer, fn) { | |
timer.end(function () { | |
event.type = 'moveend'; | |
trigger(event.target, event); | |
return fn && fn(); | |
}); | |
} | |
function setup(data, namespaces, eventHandle) { | |
add(this, 'movestart.move', flagAsHandled); | |
return true; | |
} | |
function teardown(namespaces) { | |
remove(this, 'dragstart drag', preventDefault); | |
remove(this, 'mousedown touchstart', preventIgnoreTags); | |
remove(this, 'movestart', flagAsHandled); | |
return true; | |
} | |
function addMethod(handleObj) { | |
if (handleObj.namespace === "move" || handleObj.namespace === "moveend") { | |
return; | |
} | |
add(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid, preventDefault, undefined, handleObj.selector); | |
add(this, 'mousedown.' + handleObj.guid, preventIgnoreTags, undefined, handleObj.selector); | |
} | |
function removeMethod(handleObj) { | |
if (handleObj.namespace === "move" || handleObj.namespace === "moveend") { | |
return; | |
} | |
remove(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid); | |
remove(this, 'mousedown.' + handleObj.guid); | |
} | |
jQuery.event.special.movestart = { | |
setup: setup, | |
teardown: teardown, | |
add: addMethod, | |
remove: removeMethod, | |
_default: function (e) { | |
var template, data; | |
if (!e._handled()) { | |
return; | |
} | |
template = { | |
target: e.target, | |
startX: e.startX, | |
startY: e.startY, | |
pageX: e.pageX, | |
pageY: e.pageY, | |
distX: e.distX, | |
distY: e.distY, | |
deltaX: e.deltaX, | |
deltaY: e.deltaY, | |
velocityX: e.velocityX, | |
velocityY: e.velocityY, | |
timeStamp: e.timeStamp, | |
identifier: e.identifier, | |
targetTouches: e.targetTouches, | |
finger: e.finger | |
}; | |
data = { | |
event: template, | |
timer: new Timer(function (time) { | |
trigger(e.target, template); | |
}) | |
}; | |
if (e.identifier === undefined) { | |
add(e.target, 'click', returnFalse); | |
add(document, mouseevents.move, activeMousemove, data); | |
add(document, mouseevents.end, activeMouseend, data); | |
} else { | |
e._preventTouchmoveDefault(); | |
add(document, touchevents.move + '.' + e.identifier, activeTouchmove, data); | |
add(document, touchevents.end + '.' + e.identifier, activeTouchend, data); | |
} | |
} | |
}; | |
jQuery.event.special.move = { | |
setup: function () { | |
add(this, 'movestart.move', jQuery.noop); | |
}, | |
teardown: function () { | |
remove(this, 'movestart.move', jQuery.noop); | |
} | |
}; | |
jQuery.event.special.moveend = { | |
setup: function () { | |
add(this, 'movestart.moveend', jQuery.noop); | |
}, | |
teardown: function () { | |
remove(this, 'movestart.moveend', jQuery.noop); | |
} | |
}; | |
add(document, 'mousedown.move', mousedown); | |
add(document, 'touchstart.move', touchstart); | |
if (typeof Array.prototype.indexOf === 'function') { | |
(function (jQuery, undefined) { | |
var props = ["changedTouches", "targetTouches"], | |
l = props.length; | |
while (l--) { | |
if (jQuery.event.props.indexOf(props[l]) === -1) { | |
jQuery.event.props.push(props[l]); | |
} | |
} | |
})(jQuery); | |
}; | |
}); | |
(function (module) { | |
if (typeof define === 'function' && define.amd) { | |
define(['jquery'], module); | |
} else { | |
module(jQuery); | |
} | |
})(function (jQuery, undefined) { | |
var add = jQuery.event.add, | |
remove = jQuery.event.remove, | |
trigger = function (node, type, data) { | |
jQuery.event.trigger(type, data, node); | |
}, settings = { | |
threshold: 0.4, | |
sensitivity: 6 | |
}; | |
function moveend(e) { | |
var w, h, event; | |
w = e.target.offsetWidth; | |
h = e.target.offsetHeight; | |
event = { | |
distX: e.distX, | |
distY: e.distY, | |
velocityX: e.velocityX, | |
velocityY: e.velocityY, | |
finger: e.finger | |
}; | |
event.type = 'swipecanceled'; | |
if (e.distX > e.distY) { | |
if (e.distX > -e.distY) { | |
if (e.distX / w > settings.threshold || e.velocityX * e.distX / w * settings.sensitivity > 1) { | |
event.type = 'swiperight'; | |
} | |
} else { | |
if (-e.distY / h > settings.threshold || e.velocityY * e.distY / w * settings.sensitivity > 1) { | |
event.type = 'swipeup'; | |
} | |
} | |
} else { | |
if (e.distX > -e.distY) { | |
if (e.distY / h > settings.threshold || e.velocityY * e.distY / w * settings.sensitivity > 1) { | |
event.type = 'swipedown'; | |
} | |
} else { | |
if (-e.distX / w > settings.threshold || e.velocityX * e.distX / w * settings.sensitivity > 1) { | |
event.type = 'swipeleft'; | |
} | |
} | |
} | |
trigger(e.currentTarget, event); | |
} | |
function getData(node) { | |
var data = jQuery.data(node, 'event_swipe'); | |
if (!data) { | |
data = { | |
count: 0 | |
}; | |
jQuery.data(node, 'event_swipe', data); | |
} | |
return data; | |
} | |
jQuery.event.special.swipe = jQuery.event.special.swipeleft = jQuery.event.special.swiperight = jQuery.event.special.swipeup = jQuery.event.special.swipedown = { | |
setup: function (data, namespaces, eventHandle) { | |
var data = getData(this); | |
if (data.count++ > 0) { | |
return; | |
} | |
add(this, 'moveend', moveend); | |
return true; | |
}, | |
teardown: function () { | |
var data = getData(this); | |
if (--data.count > 0) { | |
return; | |
} | |
remove(this, 'moveend', moveend); | |
return true; | |
}, | |
settings: settings | |
}; | |
}); | |
(function () { | |
(typeof exports !== "undefined" && exports !== null ? exports : this).ExifReader = (function () { | |
function ExifReader() { | |
var _this = this; | |
this._getTagValueAt = { | |
1: function (offset) { | |
return _this._getByteAt(offset); | |
}, | |
2: function (offset) { | |
return _this._getAsciiAt(offset); | |
}, | |
3: function (offset) { | |
return _this._getShortAt(offset); | |
}, | |
4: function (offset) { | |
return _this._getLongAt(offset); | |
}, | |
5: function (offset) { | |
return _this._getRationalAt(offset); | |
}, | |
7: function (offset) { | |
return _this._getUndefinedAt(offset); | |
}, | |
9: function (offset) { | |
return _this._getSlongAt(offset); | |
}, | |
10: function (offset) { | |
return _this._getSrationalAt(offset); | |
} | |
}; | |
} | |
ExifReader.prototype.load = function (data) { | |
return this.loadView(new DataView(data)); | |
}; | |
ExifReader.prototype.loadView = function (_dataView) { | |
this._dataView = _dataView; | |
this._tags = {}; | |
this._checkImageHeader(); | |
return this._readTags(); | |
}; | |
ExifReader.prototype._checkImageHeader = function () { | |
var byteLength, dataView, i; | |
dataView = this._dataView; | |
byteLength = dataView.byteLength; | |
if (byteLength < 12) { | |
throw "Data buffer too short"; | |
} | |
if (dataView.getUint32(0, false) === 0xffd8ffe1) { | |
if (dataView.getUint32(6, false) === 0x45786966 && dataView.getUint16(10, false) === 0x0000) { | |
this._tiffHeaderOffset = 0x0c; | |
return; | |
} | |
} else if (dataView.getUint32(0, false) === 0xffd8ffe0) { | |
i = 10; | |
while (i < byteLength) { | |
if (dataView.getUint8(i, false) === 0x45 && dataView.getUint32(i, false) === 0x45786966 && dataView.getUint16(i + 4, false) === 0x0000) { | |
this._tiffHeaderOffset = i + 6; | |
return; | |
} | |
i++; | |
} | |
} else { | |
throw "Invalid image format"; | |
} | |
throw "No Exif data"; | |
}; | |
ExifReader.prototype._readTags = function () { | |
this._setByteOrder(); | |
this._read0thIfd(); | |
this._readExifIfd(); | |
this._readGpsIfd(); | |
return this._readInteroperabilityIfd(); | |
}; | |
ExifReader.prototype._setByteOrder = function () { | |
if (this._dataView.getUint16(this._tiffHeaderOffset) === 0x4949) { | |
return this._littleEndian = true; | |
} else if (this._dataView.getUint16(this._tiffHeaderOffset) === 0x4d4d) { | |
return this._littleEndian = false; | |
} else { | |
throw 'Illegal byte order value. Faulty image.'; | |
} | |
}; | |
ExifReader.prototype._read0thIfd = function () { | |
var ifdOffset; | |
ifdOffset = this._getIfdOffset(); | |
return this._readIfd('0th', ifdOffset); | |
}; | |
ExifReader.prototype._getIfdOffset = function () { | |
return this._tiffHeaderOffset + this._getLongAt(this._tiffHeaderOffset + 4); | |
}; | |
ExifReader.prototype._readExifIfd = function () { | |
var ifdOffset; | |
if (this._tags['Exif IFD Pointer'] != null) { | |
ifdOffset = this._tiffHeaderOffset + this._tags['Exif IFD Pointer'].value; | |
return this._readIfd('exif', ifdOffset); | |
} | |
}; | |
ExifReader.prototype._readGpsIfd = function () { | |
var ifdOffset; | |
if (this._tags['GPS Info IFD Pointer'] != null) { | |
ifdOffset = this._tiffHeaderOffset + this._tags['GPS Info IFD Pointer'].value; | |
return this._readIfd('gps', ifdOffset); | |
} | |
}; | |
ExifReader.prototype._readInteroperabilityIfd = function () { | |
var ifdOffset; | |
if (this._tags['Interoperability IFD Pointer'] != null) { | |
ifdOffset = this._tiffHeaderOffset + this._tags['Interoperability IFD Pointer'].value; | |
return this._readIfd('interoperability', ifdOffset); | |
} | |
}; | |
ExifReader.prototype._readIfd = function (ifdType, offset) { | |
var fieldIndex, numberOfFields, tag, _i, _results; | |
numberOfFields = this._getShortAt(offset); | |
offset += 2; | |
_results = []; | |
for (fieldIndex = _i = 0; 0 <= numberOfFields ? _i < numberOfFields : _i > numberOfFields; fieldIndex = 0 <= numberOfFields ? ++_i : --_i) { | |
tag = this._readTag(ifdType, offset); | |
this._tags[tag.name] = { | |
'value': tag.value, | |
'description': tag.description | |
}; | |
_results.push(offset += 12); | |
} | |
return _results; | |
}; | |
ExifReader.prototype._readTag = function (ifdType, offset) { | |
var tagCode, tagCount, tagDescription, tagName, tagType, tagValue, tagValueOffset; | |
tagCode = this._getShortAt(offset); | |
tagType = this._getShortAt(offset + 2); | |
tagCount = this._getLongAt(offset + 4); | |
if (this._typeSizes[tagType] * tagCount <= 4) { | |
tagValue = this._getTagValue(offset + 8, tagType, tagCount); | |
} else { | |
tagValueOffset = this._getLongAt(offset + 8); | |
tagValue = this._getTagValue(this._tiffHeaderOffset + tagValueOffset, tagType, tagCount); | |
} | |
if (tagType === this._tagTypes['ASCII']) { | |
tagValue = this._splitNullSeparatedAsciiString(tagValue); | |
} | |
if (this._tagNames[ifdType][tagCode] != null) { | |
if ((this._tagNames[ifdType][tagCode]['name'] != null) && (this._tagNames[ifdType][tagCode]['description'] != null)) { | |
tagName = this._tagNames[ifdType][tagCode]['name']; | |
tagDescription = this._tagNames[ifdType][tagCode]['description'](tagValue); | |
} else { | |
tagName = this._tagNames[ifdType][tagCode]; | |
if (tagValue instanceof Array) { | |
tagDescription = tagValue.join(', '); | |
} else { | |
tagDescription = tagValue; | |
} | |
} | |
return { | |
'name': tagName, | |
'value': tagValue, | |
'description': tagDescription | |
}; | |
} else { | |
return { | |
'name': "undefined-" + tagCode, | |
'value': tagValue, | |
'description': tagValue | |
}; | |
} | |
}; | |
ExifReader.prototype._getTagValue = function (offset, type, count) { | |
var tagValue, value, valueIndex; | |
value = (function () { | |
var _i, _results; | |
_results = []; | |
for (valueIndex = _i = 0; 0 <= count ? _i < count : _i > count; valueIndex = 0 <= count ? ++_i : --_i) { | |
tagValue = this._getTagValueAt[type](offset); | |
offset += this._typeSizes[type]; | |
_results.push(tagValue); | |
} | |
return _results; | |
}).call(this); | |
if (value.length === 1) { | |
value = value[0]; | |
} else if (type === this._tagTypes['ASCII']) { | |
value = this._getAsciiValue(value); | |
} | |
return value; | |
}; | |
ExifReader.prototype._getAsciiValue = function (charArray) { | |
var char, newCharArray; | |
return newCharArray = (function () { | |
var _i, _len, _results; | |
_results = []; | |
for (_i = 0, _len = charArray.length; _i < _len; _i++) { | |
char = charArray[_i]; | |
_results.push(String.fromCharCode(char)); | |
} | |
return _results; | |
})(); | |
}; | |
ExifReader.prototype._getByteAt = function (offset) { | |
return this._dataView.getUint8(offset); | |
}; | |
ExifReader.prototype._getAsciiAt = function (offset) { | |
return this._dataView.getUint8(offset); | |
}; | |
ExifReader.prototype._getShortAt = function (offset) { | |
return this._dataView.getUint16(offset, this._littleEndian); | |
}; | |
ExifReader.prototype._getLongAt = function (offset) { | |
return this._dataView.getUint32(offset, this._littleEndian); | |
}; | |
ExifReader.prototype._getRationalAt = function (offset) { | |
return this._getLongAt(offset) / this._getLongAt(offset + 4); | |
}; | |
ExifReader.prototype._getUndefinedAt = function (offset) { | |
return this._getByteAt(offset); | |
}; | |
ExifReader.prototype._getSlongAt = function (offset) { | |
return this._dataView.getInt32(offset, this._littleEndian); | |
}; | |
ExifReader.prototype._getSrationalAt = function (offset) { | |
return this._getSlongAt(offset) / this._getSlongAt(offset + 4); | |
}; | |
ExifReader.prototype._splitNullSeparatedAsciiString = function (string) { | |
var char, i, tagValue, _i, _len; | |
tagValue = []; | |
i = 0; | |
for (_i = 0, _len = string.length; _i < _len; _i++) { | |
char = string[_i]; | |
if (char === '\x00') { | |
i++; | |
continue; | |
} | |
if (tagValue[i] == null) { | |
tagValue[i] = ''; | |
} | |
tagValue[i] += char; | |
} | |
return tagValue; | |
}; | |
ExifReader.prototype._typeSizes = { | |
1: 1, | |
2: 1, | |
3: 2, | |
4: 4, | |
5: 8, | |
7: 1, | |
9: 4, | |
10: 8 | |
}; | |
ExifReader.prototype._tagTypes = { | |
'BYTE': 1, | |
'ASCII': 2, | |
'SHORT': 3, | |
'LONG': 4, | |
'RATIONAL': 5, | |
'UNDEFINED': 7, | |
'SLONG': 9, | |
'SRATIONAL': 10 | |
}; | |
ExifReader.prototype._tagNames = { | |
'0th': { | |
0x0100: 'ImageWidth', | |
0x0101: 'ImageLength', | |
0x0102: 'BitsPerSample', | |
0x0103: 'Compression', | |
0x0106: 'PhotometricInterpretation', | |
0x010e: 'ImageDescription', | |
0x010f: 'Make', | |
0x0110: 'Model', | |
0x0111: 'StripOffsets', | |
0x0112: { | |
'name': 'Orientation', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'top-left'; | |
case 2: | |
return 'top-right'; | |
case 3: | |
return 'bottom-right'; | |
case 4: | |
return 'bottom-left'; | |
case 5: | |
return 'left-top'; | |
case 6: | |
return 'right-top'; | |
case 7: | |
return 'right-bottom'; | |
case 8: | |
return 'left-bottom'; | |
default: | |
return 'Undefined'; | |
} | |
} | |
}, | |
0x0115: 'SamplesPerPixel', | |
0x0116: 'RowsPerStrip', | |
0x0117: 'StripByteCounts', | |
0x011a: 'XResolution', | |
0x011b: 'YResolution', | |
0x011c: 'PlanarConfiguration', | |
0x0128: { | |
'name': 'ResolutionUnit', | |
'description': function (value) { | |
switch (value) { | |
case 2: | |
return 'inches'; | |
case 3: | |
return 'centimeters'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x012d: 'TransferFunction', | |
0x0131: 'Software', | |
0x0132: 'DateTime', | |
0x013b: 'Artist', | |
0x013e: 'WhitePoint', | |
0x013f: 'PrimaryChromaticities', | |
0x0201: 'JPEGInterchangeFormat', | |
0x0202: 'JPEGInterchangeFormatLength', | |
0x0211: 'YCbCrCoefficients', | |
0x0212: 'YCbCrSubSampling', | |
0x0213: { | |
'name': 'YCbCrPositioning', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'centered'; | |
case 2: | |
return 'co-sited'; | |
default: | |
return 'undefied ' + value; | |
} | |
} | |
}, | |
0x0214: 'ReferenceBlackWhite', | |
0x8298: { | |
'name': 'Copyright', | |
'description': function (value) { | |
return value.join('; '); | |
} | |
}, | |
0x8769: 'Exif IFD Pointer', | |
0x8825: 'GPS Info IFD Pointer' | |
}, | |
'exif': { | |
0x829a: 'ExposureTime', | |
0x829d: 'FNumber', | |
0x8822: { | |
'name': 'ExposureProgram', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Undefined'; | |
case 1: | |
return 'Manual'; | |
case 2: | |
return 'Normal program'; | |
case 3: | |
return 'Aperture priority'; | |
case 4: | |
return 'Shutter priority'; | |
case 5: | |
return 'Creative program'; | |
case 6: | |
return 'Action program'; | |
case 7: | |
return 'Portrait mode'; | |
case 8: | |
return 'Landscape mode'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x8824: 'SpectralSensitivity', | |
0x8827: 'ISOSpeedRatings', | |
0x8828: { | |
'name': 'OECF', | |
'description': function (value) { | |
return '[Raw OECF table data]'; | |
} | |
}, | |
0x9000: { | |
'name': 'ExifVersion', | |
'description': function (value) { | |
var char, string, _i, _len; | |
string = ''; | |
for (_i = 0, _len = value.length; _i < _len; _i++) { | |
char = value[_i]; | |
string += String.fromCharCode(char); | |
} | |
return string; | |
} | |
}, | |
0x9003: 'DateTimeOriginal', | |
0x9004: 'DateTimeDigitized', | |
0x9101: { | |
'name': 'ComponentsConfiguration', | |
'description': function (value) { | |
var char, string, _i, _len; | |
string = ''; | |
for (_i = 0, _len = value.length; _i < _len; _i++) { | |
char = value[_i]; | |
switch (char) { | |
case 0x31: | |
string += 'Y'; | |
break; | |
case 0x32: | |
string += 'Cb'; | |
break; | |
case 0x33: | |
string += 'Cr'; | |
break; | |
case 0x34: | |
string += 'R'; | |
break; | |
case 0x35: | |
string += 'G'; | |
break; | |
case 0x36: | |
string += 'B'; | |
} | |
} | |
return string; | |
} | |
}, | |
0x9102: 'CompressedBitsPerPixel', | |
0x9201: 'ShutterSpeedValue', | |
0x9202: 'ApertureValue', | |
0x9203: 'BrightnessValue', | |
0x9204: 'ExposureBiasValue', | |
0x9205: 'MaxApertureValue', | |
0x9206: 'SubjectDistance', | |
0x9207: { | |
'name': 'MeteringMode', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'Average'; | |
case 2: | |
return 'CenterWeightedAverage'; | |
case 3: | |
return 'Spot'; | |
case 4: | |
return 'MultiSpot'; | |
case 5: | |
return 'Pattern'; | |
case 6: | |
return 'Partial'; | |
case 255: | |
return 'Other'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x9208: { | |
'name': 'LightSource', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'Daylight'; | |
case 2: | |
return 'Fluorescent'; | |
case 3: | |
return 'Tungsten (incandescent light)'; | |
case 4: | |
return 'Flash'; | |
case 9: | |
return 'Fine weather'; | |
case 10: | |
return 'Cloudy weather'; | |
case 11: | |
return 'Shade'; | |
case 12: | |
return 'Daylight fluorescent (D 5700 – 7100K)'; | |
case 13: | |
return 'Day white fluorescent (N 4600 – 5400K)'; | |
case 14: | |
return 'Cool white fluorescent (W 3900 – 4500K)'; | |
case 15: | |
return 'White fluorescent (WW 3200 – 3700K)'; | |
case 17: | |
return 'Standard light A'; | |
case 18: | |
return 'Standard light B'; | |
case 19: | |
return 'Standard light C'; | |
case 20: | |
return 'D55'; | |
case 21: | |
return 'D65'; | |
case 22: | |
return 'D75'; | |
case 23: | |
return 'D50'; | |
case 24: | |
return 'ISO studio tungsten'; | |
case 255: | |
return 'Other light source'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x9209: { | |
'name': 'Flash', | |
'description': function (value) { | |
switch (value) { | |
case 0x00: | |
return 'Flash did not fire'; | |
case 0x01: | |
return 'Flash fired'; | |
case 0x05: | |
return 'Strobe return light not detected'; | |
case 0x07: | |
return 'Strobe return light detected'; | |
case 0x09: | |
return 'Flash fired, compulsory flash mode'; | |
case 0x0d: | |
return 'Flash fired, compulsory flash mode, return light not detected'; | |
case 0x0f: | |
return 'Flash fired, compulsory flash mode, return light detected'; | |
case 0x10: | |
return 'Flash did not fire, compulsory flash mode'; | |
case 0x18: | |
return 'Flash did not fire, auto mode'; | |
case 0x19: | |
return 'Flash fired, auto mode'; | |
case 0x1d: | |
return 'Flash fired, auto mode, return light not detected'; | |
case 0x1f: | |
return 'Flash fired, auto mode, return light detected'; | |
case 0x20: | |
return 'No flash function'; | |
case 0x41: | |
return 'Flash fired, red-eye reduction mode'; | |
case 0x45: | |
return 'Flash fired, red-eye reduction mode, return light not detected'; | |
case 0x47: | |
return 'Flash fired, red-eye reduction mode, return light detected'; | |
case 0x49: | |
return 'Flash fired, compulsory flash mode, red-eye reduction mode'; | |
case 0x4d: | |
return 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected'; | |
case 0x4f: | |
return 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected'; | |
case 0x59: | |
return 'Flash fired, auto mode, red-eye reduction mode'; | |
case 0x5d: | |
return 'Flash fired, auto mode, return light not detected, red-eye reduction mode'; | |
case 0x5f: | |
return 'Flash fired, auto mode, return light detected, red-eye reduction mode'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x920a: 'FocalLength', | |
0x9214: { | |
'name': 'SubjectArea', | |
'description': function (value) { | |
switch (value.length) { | |
case 2: | |
return "Location; X: " + value[0] + ", Y: " + value[1]; | |
case 3: | |
return "Circle; X: " + value[0] + ", Y: " + value[1] + ", diameter: " + value[2]; | |
case 4: | |
return "Rectangle; X: " + value[0] + ", Y: " + value[1] + ", width: " + value[2] + ", height: " + value[3]; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x927c: { | |
'name': 'MakerNote', | |
'description': function (value) { | |
return '[Raw maker note data]'; | |
} | |
}, | |
0x9286: { | |
'name': 'UserComment', | |
'description': function (value) { | |
switch (value.slice(0, 8).map(function (byte) { | |
return String.fromCharCode(byte); | |
}).join('')) { | |
case 'ASCII\x00\x00\x00': | |
return value.slice(8, value.length).map(function (byte) { | |
return String.fromCharCode(byte); | |
}).join(''); | |
case 'JIS\x00\x00\x00\x00\x00': | |
return '[JIS encoded text]'; | |
case 'UNICODE\x00': | |
return '[Unicode encoded text]'; | |
case '\x00\x00\x00\x00\x00\x00\x00\x00': | |
return '[Undefined encoding]'; | |
} | |
} | |
}, | |
0x9290: 'SubSecTime', | |
0x9291: 'SubSecTimeOriginal', | |
0x9292: 'SubSecTimeDigitized', | |
0xa000: { | |
'name': 'FlashpixVersion', | |
'description': function (value) { | |
var char, string, _i, _len; | |
string = ''; | |
for (_i = 0, _len = value.length; _i < _len; _i++) { | |
char = value[_i]; | |
string += String.fromCharCode(char); | |
} | |
return string; | |
} | |
}, | |
0xa001: { | |
'name': 'ColorSpace', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'sRGB'; | |
case 0xffff: | |
return 'Uncalibrated'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa002: 'PixelXDimension', | |
0xa003: 'PixelYDimension', | |
0xa004: 'RelatedSoundFile', | |
0xa005: 'Interoperability IFD Pointer', | |
0xa20b: 'FlashEnergy', | |
0xa20c: { | |
'name': 'SpatialFrequencyResponse', | |
'description': function (value) { | |
return '[Raw SFR table data]'; | |
} | |
}, | |
0xa20e: 'FocalPlaneXResolution', | |
0xa20f: 'FocalPlaneYResolution', | |
0xa210: { | |
'name': 'FocalPlaneResolutionUnit', | |
'description': function (value) { | |
switch (value) { | |
case 2: | |
return 'inches'; | |
case 3: | |
return 'centimeters'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa214: { | |
'name': 'SubjectLocation', | |
'description': function (value) { | |
return "X: " + value[0] + ", Y: " + value[1]; | |
} | |
}, | |
0xa215: 'ExposureIndex', | |
0xa217: { | |
'name': 'SensingMethod', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'Undefined'; | |
case 2: | |
return 'One-chip color area sensor'; | |
case 3: | |
return 'Two-chip color area sensor'; | |
case 4: | |
return 'Three-chip color area sensor'; | |
case 5: | |
return 'Color sequential area sensor'; | |
case 7: | |
return 'Trilinear sensor'; | |
case 8: | |
return 'Color sequential linear sensor'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa300: { | |
'name': 'FileSource', | |
'description': function (value) { | |
switch (value) { | |
case 3: | |
return 'DSC'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa301: { | |
'name': 'SceneType', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'A directly photographed image'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa302: { | |
'name': 'CFAPattern', | |
'description': function (value) { | |
return '[Raw CFA pattern table data]'; | |
} | |
}, | |
0xa401: { | |
'name': 'CustomRendered', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Normal process'; | |
case 1: | |
return 'Custom process'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa402: { | |
'name': 'ExposureMode', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Auto exposure'; | |
case 1: | |
return 'Manual exposure'; | |
case 2: | |
return 'Auto bracket'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa403: { | |
'name': 'WhiteBalance', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Auto white balance'; | |
case 1: | |
return 'Manual white balance'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa404: { | |
'name': 'DigitalZoomRatio', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Digital zoom was not used'; | |
default: | |
return value; | |
} | |
} | |
}, | |
0xa405: { | |
'name': 'FocalLengthIn35mmFilm', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Unknown'; | |
default: | |
return value; | |
} | |
} | |
}, | |
0xa406: { | |
'name': 'SceneCaptureType', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Standard'; | |
case 1: | |
return 'Landscape'; | |
case 2: | |
return 'Portrait'; | |
case 3: | |
return 'Night scene'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa407: { | |
'name': 'GainControl', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'None'; | |
case 1: | |
return 'Low gain up'; | |
case 2: | |
return 'High gain up'; | |
case 3: | |
return 'Low gain down'; | |
case 4: | |
return 'High gain down'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa408: { | |
'name': 'Contrast', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Normal'; | |
case 1: | |
return 'Soft'; | |
case 2: | |
return 'Hard'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa409: { | |
'name': 'Saturation', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Normal'; | |
case 1: | |
return 'Low saturation'; | |
case 2: | |
return 'High saturation'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa40a: { | |
'name': 'Sharpness', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Normal'; | |
case 1: | |
return 'Soft'; | |
case 2: | |
return 'Hard'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa40b: { | |
'name': 'DeviceSettingDescription', | |
'description': function (value) { | |
return '[Raw device settings table data]'; | |
} | |
}, | |
0xa40c: { | |
'name': 'SubjectDistanceRange', | |
'description': function (value) { | |
switch (value) { | |
case 1: | |
return 'Macro'; | |
case 2: | |
return 'Close view'; | |
case 3: | |
return 'Distant view'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0xa420: 'ImageUniqueID' | |
}, | |
'gps': { | |
0x0000: { | |
'name': 'GPSVersionID', | |
'description': function (value) { | |
var _ref, _ref1; | |
if ((value[0] === (_ref = value[1]) && _ref === 2) && (value[2] === (_ref1 = value[3]) && _ref1 === 0)) { | |
return 'Version 2.2'; | |
} else { | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0001: { | |
'name': 'GPSLatitudeRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'N': | |
return 'North latitude'; | |
case 'S': | |
return 'South latitude'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0002: { | |
'name': 'GPSLatitude', | |
'description': function (value) { | |
return value[0] + value[1] / 60 + value[2] / 3600; | |
} | |
}, | |
0x0003: { | |
'name': 'GPSLongitudeRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'E': | |
return 'East longitude'; | |
case 'W': | |
return 'West longitude'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0004: { | |
'name': 'GPSLongitude', | |
'description': function (value) { | |
return value[0] + value[1] / 60 + value[2] / 3600; | |
} | |
}, | |
0x0005: { | |
'name': 'GPSAltitudeRef', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Sea level'; | |
case 1: | |
return 'Sea level reference (negative value)'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0006: { | |
'name': 'GPSAltitude', | |
'description': function (value) { | |
return value + ' m'; | |
} | |
}, | |
0x0007: { | |
'name': 'GPSTimeStamp', | |
'description': function (value) { | |
var padZero; | |
padZero = function (num) { | |
var i; | |
return ((function () { | |
var _i, _ref, _results; | |
_results = []; | |
for (i = _i = 0, _ref = 2 - ('' + Math.floor(num)).length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { | |
_results.push('0'); | |
} | |
return _results; | |
})()) + num; | |
}; | |
return value.map(padZero).join(':'); | |
} | |
}, | |
0x0008: 'GPSSatellites', | |
0x0009: { | |
'name': 'GPSStatus', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'A': | |
return 'Measurement in progress'; | |
case 'V': | |
return 'Measurement Interoperability'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x000a: { | |
'name': 'GPSMeasureMode', | |
'description': function (value) { | |
switch (value.join('')) { | |
case '2': | |
return '2-dimensional measurement'; | |
case '3': | |
return '3-dimensional measurement'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x000b: 'GPSDOP', | |
0x000c: { | |
'name': 'GPSSpeedRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'K': | |
return 'Kilometers per hour'; | |
case 'M': | |
return 'Miles per hour'; | |
case 'N': | |
return 'Knots'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x000d: 'GPSSpeed', | |
0x000e: { | |
'name': 'GPSTrackRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'T': | |
return 'True direction'; | |
case 'M': | |
return 'Magnetic direction'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x000f: 'GPSTrack', | |
0x0010: { | |
'name': 'GPSImgDirectionRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'T': | |
return 'True direction'; | |
case 'M': | |
return 'Magnetic direction'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0011: 'GPSImgDirection', | |
0x0012: 'GPSMapDatum', | |
0x0013: { | |
'name': 'GPSDestLatitudeRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'N': | |
return 'North latitude'; | |
case 'S': | |
return 'South latitude'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0014: { | |
'name': 'GPSDestLatitude', | |
'description': function (value) { | |
return value[0] + value[1] / 60 + value[2] / 3600; | |
} | |
}, | |
0x0015: { | |
'name': 'GPSDestLongitudeRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'E': | |
return 'East longitude'; | |
case 'W': | |
return 'West longitude'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0016: { | |
'name': 'GPSDestLongitude', | |
'description': function (value) { | |
return value[0] + value[1] / 60 + value[2] / 3600; | |
} | |
}, | |
0x0017: { | |
'name': 'GPSDestBearingRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'T': | |
return 'True direction'; | |
case 'M': | |
return 'Magnetic direction'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x0018: 'GPSDestBearing', | |
0x0019: { | |
'name': 'GPSDestDistanceRef', | |
'description': function (value) { | |
switch (value.join('')) { | |
case 'K': | |
return 'Kilometers'; | |
case 'M': | |
return 'Miles'; | |
case 'N': | |
return 'Knots'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
}, | |
0x001a: 'GPSDestDistance', | |
0x001b: { | |
'name': 'GPSProcessingMethod', | |
'description': function (value) { | |
switch (value.slice(0, 8).map(function (byte) { | |
return String.fromCharCode(byte); | |
}).join('')) { | |
case 'ASCII\x00\x00\x00': | |
return value.slice(8, value.length).map(function (byte) { | |
return String.fromCharCode(byte); | |
}).join(''); | |
case 'JIS\x00\x00\x00\x00\x00': | |
return '[JIS encoded text]'; | |
case 'UNICODE\x00': | |
return '[Unicode encoded text]'; | |
case '\x00\x00\x00\x00\x00\x00\x00\x00': | |
return '[Undefined encoding]'; | |
} | |
} | |
}, | |
0x001c: { | |
'name': 'GPSAreaInformation', | |
'description': function (value) { | |
switch (value.slice(0, 8).map(function (byte) { | |
return String.fromCharCode(byte); | |
}).join('')) { | |
case 'ASCII\x00\x00\x00': | |
return value.slice(8, value.length).map(function (byte) { | |
return String.fromCharCode(byte); | |
}).join(''); | |
case 'JIS\x00\x00\x00\x00\x00': | |
return '[JIS encoded text]'; | |
case 'UNICODE\x00': | |
return '[Unicode encoded text]'; | |
case '\x00\x00\x00\x00\x00\x00\x00\x00': | |
return '[Undefined encoding]'; | |
} | |
} | |
}, | |
0x001d: 'GPSDateStamp', | |
0x001e: { | |
'name': 'GPSDifferential', | |
'description': function (value) { | |
switch (value) { | |
case 0: | |
return 'Measurement without differential correction'; | |
case 1: | |
return 'Differential correction applied'; | |
default: | |
return 'Unknown'; | |
} | |
} | |
} | |
}, | |
'interoperability': { | |
0x0001: 'InteroperabilityIndex', | |
0x0002: 'UnknownInteroperabilityTag0x0002', | |
0x1001: 'UnknownInteroperabilityTag0x1001', | |
0x1002: 'UnknownInteroperabilityTag0x1002' | |
} | |
}; | |
ExifReader.prototype.getTagValue = function (name) { | |
if (this._tags[name] != null) { | |
return this._tags[name].value; | |
} else { | |
throw 'Undefined'; | |
} | |
}; | |
ExifReader.prototype.getTagDescription = function (name) { | |
if (this._tags[name] != null) { | |
return this._tags[name].description; | |
} else { | |
throw 'Undefined'; | |
} | |
}; | |
ExifReader.prototype.getAllTags = function () { | |
return this._tags; | |
}; | |
return ExifReader; | |
})(); | |
}).call(this); | |
function s4() { | |
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); | |
}; | |
function guid() { | |
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | |
s4() + '-' + s4() + s4() + s4(); | |
}; | |
(function (global) { | |
var k, _handlers = {}, _mods = { | |
16: false, | |
18: false, | |
17: false, | |
91: false | |
}, _scope = 'all', | |
_MODIFIERS = { | |
'⇧': 16, | |
shift: 16, | |
'⌥': 18, | |
alt: 18, | |
option: 18, | |
'⌃': 17, | |
ctrl: 17, | |
control: 17, | |
'⌘': 91, | |
command: 91 | |
}, _MAP = { | |
backspace: 8, | |
tab: 9, | |
clear: 12, | |
enter: 13, | |
'return': 13, | |
esc: 27, | |
escape: 27, | |
space: 32, | |
left: 37, | |
up: 38, | |
right: 39, | |
down: 40, | |
del: 46, | |
'delete': 46, | |
home: 36, | |
end: 35, | |
pageup: 33, | |
pagedown: 34, | |
',': 188, | |
'.': 190, | |
'/': 191, | |
'`': 192, | |
'-': 189, | |
'=': 187, | |
';': 186, | |
'\'': 222, | |
'[': 219, | |
']': 221, | |
'\\': 220 | |
}, code = function (x) { | |
return _MAP[x] || x.toUpperCase().charCodeAt(0); | |
}, _downKeys = []; | |
for (k = 1; k < 20; k++) _MAP['f' + k] = 111 + k; | |
function index(array, item) { | |
var i = array.length; | |
while (i--) | |
if (array[i] === item) return i; | |
return -1; | |
} | |
function compareArray(a1, a2) { | |
if (a1.length != a2.length) return false; | |
for (var i = 0; i < a1.length; i++) { | |
if (a1[i] !== a2[i]) return false; | |
} | |
return true; | |
} | |
var modifierMap = { | |
16: 'shiftKey', | |
18: 'altKey', | |
17: 'ctrlKey', | |
91: 'metaKey' | |
}; | |
function updateModifierKey(event) { | |
for (k in _mods) _mods[k] = event[modifierMap[k]]; | |
}; | |
function dispatch(event, scope) { | |
var key, handler, k, i, modifiersMatch; | |
key = event.keyCode; | |
if (index(_downKeys, key) == -1) { | |
_downKeys.push(key); | |
} | |
if (key == 93 || key == 224) key = 91; | |
if (key in _mods) { | |
_mods[key] = true; | |
for (k in _MODIFIERS) | |
if (_MODIFIERS[k] == key) assignKey[k] = true; | |
return; | |
} | |
updateModifierKey(event); | |
if (!assignKey.filter.call(this, event)) return; | |
if (!(key in _handlers)) return; | |
for (i = 0; i < _handlers[key].length; i++) { | |
handler = _handlers[key][i]; | |
if (handler.scope == scope || handler.scope == 'all') { | |
modifiersMatch = handler.mods.length > 0; | |
for (k in _mods) | |
if ((!_mods[k] && index(handler.mods, +k) > -1) || (_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false; | |
if ((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch) { | |
if (handler.method(event, handler) === false) { | |
if (event.preventDefault) event.preventDefault(); | |
else event.returnValue = false; if (event.stopPropagation) event.stopPropagation(); | |
if (event.cancelBubble) event.cancelBubble = true; | |
} | |
} | |
} | |
} | |
}; | |
function clearModifier(event) { | |
var key = event.keyCode, | |
k, i = index(_downKeys, key); | |
if (i >= 0) { | |
_downKeys.splice(i, 1); | |
} | |
if (key == 93 || key == 224) key = 91; | |
if (key in _mods) { | |
_mods[key] = false; | |
for (k in _MODIFIERS) | |
if (_MODIFIERS[k] == key) assignKey[k] = false; | |
} | |
}; | |
function resetModifiers() { | |
for (k in _mods) _mods[k] = false; | |
for (k in _MODIFIERS) assignKey[k] = false; | |
}; | |
function assignKey(key, scope, method) { | |
var keys, mods; | |
keys = getKeys(key); | |
if (method === undefined) { | |
method = scope; | |
scope = 'all'; | |
} | |
for (var i = 0; i < keys.length; i++) { | |
mods = []; | |
key = keys[i].split('+'); | |
if (key.length > 1) { | |
mods = getMods(key); | |
key = [key[key.length - 1]]; | |
} | |
key = key[0] | |
key = code(key); | |
if (!(key in _handlers)) _handlers[key] = []; | |
_handlers[key].push({ | |
shortcut: keys[i], | |
scope: scope, | |
method: method, | |
key: keys[i], | |
mods: mods | |
}); | |
} | |
}; | |
function unbindKey(key, scope) { | |
var keys = key.split('+'), | |
mods = [], | |
i, obj; | |
if (keys.length > 1) { | |
mods = getMods(keys); | |
key = keys[keys.length - 1]; | |
} | |
key = code(key); | |
if (scope === undefined) { | |
scope = getScope(); | |
} | |
if (!_handlers[key]) { | |
return; | |
} | |
for (i in _handlers[key]) { | |
obj = _handlers[key][i]; | |
if (obj.scope === scope && compareArray(obj.mods, mods)) { | |
_handlers[key][i] = {}; | |
} | |
} | |
}; | |
function isPressed(keyCode) { | |
if (typeof (keyCode) == 'string') { | |
keyCode = code(keyCode); | |
} | |
return index(_downKeys, keyCode) != -1; | |
} | |
function getPressedKeyCodes() { | |
return _downKeys.slice(0); | |
} | |
function filter(event) { | |
var tagName = (event.target || event.srcElement).tagName; | |
return !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA'); | |
} | |
for (k in _MODIFIERS) assignKey[k] = false; | |
function setScope(scope) { | |
_scope = scope || 'all' | |
}; | |
function getScope() { | |
return _scope || 'all' | |
}; | |
function deleteScope(scope) { | |
var key, handlers, i; | |
for (key in _handlers) { | |
handlers = _handlers[key]; | |
for (i = 0; i < handlers.length;) { | |
if (handlers[i].scope === scope) handlers.splice(i, 1); | |
else i++; | |
} | |
} | |
}; | |
function getKeys(key) { | |
var keys; | |
key = key.replace(/\s/g, ''); | |
keys = key.split(','); | |
if ((keys[keys.length - 1]) == '') { | |
keys[keys.length - 2] += ','; | |
} | |
return keys; | |
} | |
function getMods(key) { | |
var mods = key.slice(0, key.length - 1); | |
for (var mi = 0; mi < mods.length; mi++) | |
mods[mi] = _MODIFIERS[mods[mi]]; | |
return mods; | |
} | |
function addEvent(object, event, method) { | |
if (object.addEventListener) | |
object.addEventListener(event, method, false); | |
else if (object.attachEvent) | |
object.attachEvent('on' + event, function () { | |
method(window.event) | |
}); | |
}; | |
addEvent(document, 'keydown', function (event) { | |
dispatch(event, _scope) | |
}); | |
addEvent(document, 'keyup', clearModifier); | |
addEvent(window, 'focus', resetModifiers); | |
var previousKey = global.key; | |
function noConflict() { | |
var k = global.key; | |
global.key = previousKey; | |
return k; | |
} | |
global.key = assignKey; | |
global.key.setScope = setScope; | |
global.key.getScope = getScope; | |
global.key.deleteScope = deleteScope; | |
global.key.filter = filter; | |
global.key.isPressed = isPressed; | |
global.key.getPressedKeyCodes = getPressedKeyCodes; | |
global.key.noConflict = noConflict; | |
global.key.unbind = unbindKey; | |
if (typeof module !== 'undefined') module.exports = key; | |
})(this); | |
(function () { | |
var _this = this; | |
this.linear_partition = function (seq, k) { | |
var ans, i, j, m, n, solution, table, x, y, _i, _j, _k, _l; | |
n = seq.length; | |
if (k <= 0) { | |
return []; | |
} | |
if (k > n) { | |
return seq.map(function (x) { | |
return [x]; | |
}); | |
} | |
table = (function () { | |
var _i, _results; | |
_results = []; | |
for (y = _i = 0; 0 <= n ? _i < n : _i > n; y = 0 <= n ? ++_i : --_i) { | |
_results.push((function () { | |
var _j, _results1; | |
_results1 = []; | |
for (x = _j = 0; 0 <= k ? _j < k : _j > k; x = 0 <= k ? ++_j : --_j) { | |
_results1.push(0); | |
} | |
return _results1; | |
})()); | |
} | |
return _results; | |
})(); | |
solution = (function () { | |
var _i, _ref, _results; | |
_results = []; | |
for (y = _i = 0, _ref = n - 1; 0 <= _ref ? _i < _ref : _i > _ref; y = 0 <= _ref ? ++_i : --_i) { | |
_results.push((function () { | |
var _j, _ref1, _results1; | |
_results1 = []; | |
for (x = _j = 0, _ref1 = k - 1; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; x = 0 <= _ref1 ? ++_j : --_j) { | |
_results1.push(0); | |
} | |
return _results1; | |
})()); | |
} | |
return _results; | |
})(); | |
for (i = _i = 0; 0 <= n ? _i < n : _i > n; i = 0 <= n ? ++_i : --_i) { | |
table[i][0] = seq[i] + (i ? table[i - 1][0] : 0); | |
} | |
for (j = _j = 0; 0 <= k ? _j < k : _j > k; j = 0 <= k ? ++_j : --_j) { | |
table[0][j] = seq[0]; | |
} | |
for (i = _k = 1; 1 <= n ? _k < n : _k > n; i = 1 <= n ? ++_k : --_k) { | |
for (j = _l = 1; 1 <= k ? _l < k : _l > k; j = 1 <= k ? ++_l : --_l) { | |
m = _.min((function () { | |
var _m, _results; | |
_results = []; | |
for (x = _m = 0; 0 <= i ? _m < i : _m > i; x = 0 <= i ? ++_m : --_m) { | |
_results.push([_.max([table[x][j - 1], table[i][0] - table[x][0]]), x]); | |
} | |
return _results; | |
})(), function (o) { | |
return o[0]; | |
}); | |
table[i][j] = m[0]; | |
solution[i - 1][j - 1] = m[1]; | |
} | |
} | |
n = n - 1; | |
k = k - 2; | |
ans = []; | |
while (k >= 0) { | |
ans = [(function () { | |
var _m, _ref, _ref1, _results; | |
_results = []; | |
for (i = _m = _ref = solution[n - 1][k] + 1, _ref1 = n + 1; _ref <= _ref1 ? _m < _ref1 : _m > _ref1; i = _ref <= _ref1 ? ++_m : --_m) { | |
_results.push(seq[i]); | |
} | |
return _results; | |
})()].concat(ans); | |
n = solution[n - 1][k]; | |
k = k - 1; | |
} | |
return [(function () { | |
var _m, _ref, _results; | |
_results = []; | |
for (i = _m = 0, _ref = n + 1; 0 <= _ref ? _m < _ref : _m > _ref; i = 0 <= _ref ? ++_m : --_m) { | |
_results.push(seq[i]); | |
} | |
return _results; | |
})()].concat(ans); | |
}; | |
}).call(this); | |
function resize(img, max_width, max_height) { | |
var c = document.createElement('canvas'); | |
var context = c.getContext('2d'); | |
var width = img.width; | |
var height = img.height; | |
if (width > height) { | |
if (width > max_width) { | |
height *= max_width / width; | |
width = max_width; | |
} | |
} else { | |
if (height > max_height) { | |
width *= max_height / height; | |
height = max_height; | |
} | |
} | |
width = parseInt(width) | |
height = parseInt(height) | |
c.width = width; | |
c.height = height; | |
context.drawImage(img, 0, 0, width, height); | |
var resized_img = new Image(width, height) | |
resized_img.src = c.toDataURL("image/jpeg", 0.70); | |
return resized_img; | |
} | |
(function () { | |
var __indexOf = [].indexOf || function (item) { | |
for (var i = 0, l = this.length; i < l; i++) { | |
if (i in this && this[i] === item) return i; | |
} | |
return -1; | |
}; | |
this.S3Upload = {}; | |
this.S3Upload.upload = function (data, s3_object_key, success, progress, error) { | |
var form_data, xhr, _this = this; | |
xhr = new XMLHttpRequest; | |
xhr.upload.addEventListener("progress", progress); | |
xhr.addEventListener("load", function (e) { | |
var _i, _ref, _results; | |
if (_ref = e.target.status, __indexOf.call((function () { | |
_results = []; | |
for (_i = 200; _i <= 299; _i++) { | |
_results.push(_i); | |
} | |
return _results; | |
}).apply(this), _ref) >= 0) { | |
return success(); | |
} else { | |
return error(); | |
} | |
}, false); | |
xhr.addEventListener("error", error); | |
form_data = new FormData; | |
form_data.append("key", s3_object_key); | |
form_data.append("AWSAccessKeyId", this.access_key); | |
form_data.append("acl", this.acl); | |
form_data.append("policy", this.policy); | |
form_data.append("signature", this.signature); | |
form_data.append("Content-Type", 'image/jpeg'); | |
form_data.append("Cache-Control", 'max-age=94608000'); | |
form_data.append("file", data); | |
xhr.open("POST", "http://" + this.bucket + ".s3.amazonaws.com", true); | |
return xhr.send(form_data); | |
}; | |
}).call(this); | |
(function (a) { | |
if (typeof exports === "object") { | |
module.exports = a() | |
} else { | |
if (typeof define === "function" && define.amd) { | |
define(a) | |
} else { | |
var c; | |
try { | |
c = window | |
} catch (b) { | |
c = self | |
} | |
c.SparkMD5 = a() | |
} | |
} | |
}(function (c) { | |
var e = function (s, r) { | |
return (s + r) & 4294967295 | |
}, n = function (z, v, u, r, y, w) { | |
v = e(e(v, z), e(r, w)); | |
return e((v << y) | (v >>> (32 - y)), u) | |
}, a = function (v, u, A, z, r, y, w) { | |
return n((u & A) | ((~u) & z), v, u, r, y, w) | |
}, k = function (v, u, A, z, r, y, w) { | |
return n((u & z) | (A & (~z)), v, u, r, y, w) | |
}, f = function (v, u, A, z, r, y, w) { | |
return n(u ^ A ^ z, v, u, r, y, w) | |
}, p = function (v, u, A, z, r, y, w) { | |
return n(A ^ (u | (~z)), v, u, r, y, w) | |
}, d = function (s, u) { | |
var t = s[0], | |
r = s[1], | |
w = s[2], | |
v = s[3]; | |
t = a(t, r, w, v, u[0], 7, -680876936); | |
v = a(v, t, r, w, u[1], 12, -389564586); | |
w = a(w, v, t, r, u[2], 17, 606105819); | |
r = a(r, w, v, t, u[3], 22, -1044525330); | |
t = a(t, r, w, v, u[4], 7, -176418897); | |
v = a(v, t, r, w, u[5], 12, 1200080426); | |
w = a(w, v, t, r, u[6], 17, -1473231341); | |
r = a(r, w, v, t, u[7], 22, -45705983); | |
t = a(t, r, w, v, u[8], 7, 1770035416); | |
v = a(v, t, r, w, u[9], 12, -1958414417); | |
w = a(w, v, t, r, u[10], 17, -42063); | |
r = a(r, w, v, t, u[11], 22, -1990404162); | |
t = a(t, r, w, v, u[12], 7, 1804603682); | |
v = a(v, t, r, w, u[13], 12, -40341101); | |
w = a(w, v, t, r, u[14], 17, -1502002290); | |
r = a(r, w, v, t, u[15], 22, 1236535329); | |
t = k(t, r, w, v, u[1], 5, -165796510); | |
v = k(v, t, r, w, u[6], 9, -1069501632); | |
w = k(w, v, t, r, u[11], 14, 643717713); | |
r = k(r, w, v, t, u[0], 20, -373897302); | |
t = k(t, r, w, v, u[5], 5, -701558691); | |
v = k(v, t, r, w, u[10], 9, 38016083); | |
w = k(w, v, t, r, u[15], 14, -660478335); | |
r = k(r, w, v, t, u[4], 20, -405537848); | |
t = k(t, r, w, v, u[9], 5, 568446438); | |
v = k(v, t, r, w, u[14], 9, -1019803690); | |
w = k(w, v, t, r, u[3], 14, -187363961); | |
r = k(r, w, v, t, u[8], 20, 1163531501); | |
t = k(t, r, w, v, u[13], 5, -1444681467); | |
v = k(v, t, r, w, u[2], 9, -51403784); | |
w = k(w, v, t, r, u[7], 14, 1735328473); | |
r = k(r, w, v, t, u[12], 20, -1926607734); | |
t = f(t, r, w, v, u[5], 4, -378558); | |
v = f(v, t, r, w, u[8], 11, -2022574463); | |
w = f(w, v, t, r, u[11], 16, 1839030562); | |
r = f(r, w, v, t, u[14], 23, -35309556); | |
t = f(t, r, w, v, u[1], 4, -1530992060); | |
v = f(v, t, r, w, u[4], 11, 1272893353); | |
w = f(w, v, t, r, u[7], 16, -155497632); | |
r = f(r, w, v, t, u[10], 23, -1094730640); | |
t = f(t, r, w, v, u[13], 4, 681279174); | |
v = f(v, t, r, w, u[0], 11, -358537222); | |
w = f(w, v, t, r, u[3], 16, -722521979); | |
r = f(r, w, v, t, u[6], 23, 76029189); | |
t = f(t, r, w, v, u[9], 4, -640364487); | |
v = f(v, t, r, w, u[12], 11, -421815835); | |
w = f(w, v, t, r, u[15], 16, 530742520); | |
r = f(r, w, v, t, u[2], 23, -995338651); | |
t = p(t, r, w, v, u[0], 6, -198630844); | |
v = p(v, t, r, w, u[7], 10, 1126891415); | |
w = p(w, v, t, r, u[14], 15, -1416354905); | |
r = p(r, w, v, t, u[5], 21, -57434055); | |
t = p(t, r, w, v, u[12], 6, 1700485571); | |
v = p(v, t, r, w, u[3], 10, -1894986606); | |
w = p(w, v, t, r, u[10], 15, -1051523); | |
r = p(r, w, v, t, u[1], 21, -2054922799); | |
t = p(t, r, w, v, u[8], 6, 1873313359); | |
v = p(v, t, r, w, u[15], 10, -30611744); | |
w = p(w, v, t, r, u[6], 15, -1560198380); | |
r = p(r, w, v, t, u[13], 21, 1309151649); | |
t = p(t, r, w, v, u[4], 6, -145523070); | |
v = p(v, t, r, w, u[11], 10, -1120210379); | |
w = p(w, v, t, r, u[2], 15, 718787259); | |
r = p(r, w, v, t, u[9], 21, -343485551); | |
s[0] = e(t, s[0]); | |
s[1] = e(r, s[1]); | |
s[2] = e(w, s[2]); | |
s[3] = e(v, s[3]) | |
}, q = function (t) { | |
var u = [], | |
r; | |
for (r = 0; r < 64; r += 4) { | |
u[r >> 2] = t.charCodeAt(r) + (t.charCodeAt(r + 1) << 8) + (t.charCodeAt(r + 2) << 16) + (t.charCodeAt(r + 3) << 24) | |
} | |
return u | |
}, m = function (r) { | |
var t = [], | |
s; | |
for (s = 0; s < 64; s += 4) { | |
t[s >> 2] = r[s] + (r[s + 1] << 8) + (r[s + 2] << 16) + (r[s + 3] << 24) | |
} | |
return t | |
}, l = function (A) { | |
var u = A.length, | |
r = [1732584193, -271733879, -1732584194, 271733878], | |
w, t, z, x, y, v; | |
for (w = 64; w <= u; w += 64) { | |
d(r, q(A.substring(w - 64, w))) | |
} | |
A = A.substring(w - 64); | |
t = A.length; | |
z = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
for (w = 0; w < t; w += 1) { | |
z[w >> 2] |= A.charCodeAt(w) << ((w % 4) << 3) | |
} | |
z[w >> 2] |= 128 << ((w % 4) << 3); | |
if (w > 55) { | |
d(r, z); | |
for (w = 0; w < 16; w += 1) { | |
z[w] = 0 | |
} | |
} | |
x = u * 8; | |
x = x.toString(16).match(/(.*?)(.{0,8})$/); | |
y = parseInt(x[2], 16); | |
v = parseInt(x[1], 16) || 0; | |
z[14] = y; | |
z[15] = v; | |
d(r, z); | |
return r | |
}, o = function (z) { | |
var t = z.length, | |
r = [1732584193, -271733879, -1732584194, 271733878], | |
v, s, y, w, x, u; | |
for (v = 64; v <= t; v += 64) { | |
d(r, m(z.subarray(v - 64, v))) | |
} | |
z = (v - 64) < t ? z.subarray(v - 64) : new Uint8Array(0); | |
s = z.length; | |
y = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
for (v = 0; v < s; v += 1) { | |
y[v >> 2] |= z[v] << ((v % 4) << 3) | |
} | |
y[v >> 2] |= 128 << ((v % 4) << 3); | |
if (v > 55) { | |
d(r, y); | |
for (v = 0; v < 16; v += 1) { | |
y[v] = 0 | |
} | |
} | |
w = t * 8; | |
w = w.toString(16).match(/(.*?)(.{0,8})$/); | |
x = parseInt(w[2], 16); | |
u = parseInt(w[1], 16) || 0; | |
y[14] = x; | |
y[15] = u; | |
d(r, y); | |
return r | |
}, j = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"], | |
h = function (u) { | |
var t = "", | |
r; | |
for (r = 0; r < 4; r += 1) { | |
t += j[(u >> (r * 8 + 4)) & 15] + j[(u >> (r * 8)) & 15] | |
} | |
return t | |
}, b = function (r) { | |
var s; | |
for (s = 0; s < r.length; s += 1) { | |
r[s] = h(r[s]) | |
} | |
return r.join("") | |
}, i = function (r) { | |
return b(l(r)) | |
}, g = function () { | |
this.reset() | |
}; | |
if (i("hello") !== "5d41402abc4b2a76b9719d911017c592") { | |
e = function (r, u) { | |
var t = (r & 65535) + (u & 65535), | |
s = (r >> 16) + (u >> 16) + (t >> 16); | |
return (s << 16) | (t & 65535) | |
} | |
} | |
g.prototype.append = function (r) { | |
if (/[\u0080-\uFFFF]/.test(r)) { | |
r = unescape(encodeURIComponent(r)) | |
} | |
this.appendBinary(r); | |
return this | |
}; | |
g.prototype.appendBinary = function (t) { | |
this._buff += t; | |
this._length += t.length; | |
var s = this._buff.length, | |
r; | |
for (r = 64; r <= s; r += 64) { | |
d(this._state, q(this._buff.substring(r - 64, r))) | |
} | |
this._buff = this._buff.substr(r - 64); | |
return this | |
}; | |
g.prototype.end = function (t) { | |
var w = this._buff, | |
v = w.length, | |
u, s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
r; | |
for (u = 0; u < v; u += 1) { | |
s[u >> 2] |= w.charCodeAt(u) << ((u % 4) << 3) | |
} | |
this._finish(s, v); | |
r = !! t ? this._state : b(this._state); | |
this.reset(); | |
return r | |
}; | |
g.prototype._finish = function (s, w) { | |
var u = w, | |
t, v, r; | |
s[u >> 2] |= 128 << ((u % 4) << 3); | |
if (u > 55) { | |
d(this._state, s); | |
for (u = 0; u < 16; u += 1) { | |
s[u] = 0 | |
} | |
} | |
t = this._length * 8; | |
t = t.toString(16).match(/(.*?)(.{0,8})$/); | |
v = parseInt(t[2], 16); | |
r = parseInt(t[1], 16) || 0; | |
s[14] = v; | |
s[15] = r; | |
d(this._state, s) | |
}; | |
g.prototype.reset = function () { | |
this._buff = ""; | |
this._length = 0; | |
this._state = [1732584193, -271733879, -1732584194, 271733878]; | |
return this | |
}; | |
g.prototype.destroy = function () { | |
delete this._state; | |
delete this._buff; | |
delete this._length | |
}; | |
g.hash = function (t, r) { | |
if (/[\u0080-\uFFFF]/.test(t)) { | |
t = unescape(encodeURIComponent(t)) | |
} | |
var s = l(t); | |
return !!r ? s : b(s) | |
}; | |
g.hashBinary = function (s, r) { | |
var t = l(s); | |
return !!r ? t : b(t) | |
}; | |
g.ArrayBuffer = function () { | |
this.reset() | |
}; | |
g.ArrayBuffer.prototype.append = function (r) { | |
var u = this._concatArrayBuffer(this._buff, r), | |
t = u.length, | |
s; | |
this._length += r.byteLength; | |
for (s = 64; s <= t; s += 64) { | |
d(this._state, m(u.subarray(s - 64, s))) | |
} | |
this._buff = (s - 64) < t ? u.subarray(s - 64) : new Uint8Array(0); | |
return this | |
}; | |
g.ArrayBuffer.prototype.end = function (t) { | |
var w = this._buff, | |
v = w.length, | |
s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
u, r; | |
for (u = 0; u < v; u += 1) { | |
s[u >> 2] |= w[u] << ((u % 4) << 3) | |
} | |
this._finish(s, v); | |
r = !! t ? this._state : b(this._state); | |
this.reset(); | |
return r | |
}; | |
g.ArrayBuffer.prototype._finish = g.prototype._finish; | |
g.ArrayBuffer.prototype.reset = function () { | |
this._buff = new Uint8Array(0); | |
this._length = 0; | |
this._state = [1732584193, -271733879, -1732584194, 271733878]; | |
return this | |
}; | |
g.ArrayBuffer.prototype.destroy = g.prototype.destroy; | |
g.ArrayBuffer.prototype._concatArrayBuffer = function (u, s) { | |
var t = u.length, | |
r = new Uint8Array(t + s.byteLength); | |
r.set(u); | |
r.set(new Uint8Array(s), t); | |
return r | |
}; | |
g.ArrayBuffer.hash = function (r, s) { | |
var t = o(new Uint8Array(r)); | |
return !!s ? t : b(t) | |
}; | |
return g | |
})); | |
(function (b, c) { | |
var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), | |
a; | |
$.throttle = a = function (e, f, j, i) { | |
var h, d = 0; | |
if (typeof f !== "boolean") { | |
i = j; | |
j = f; | |
f = c | |
} | |
function g() { | |
var o = this, | |
m = +new Date() - d, | |
n = arguments; | |
function l() { | |
d = +new Date(); | |
j.apply(o, n) | |
} | |
function k() { | |
h = c | |
} | |
if (i && !h) { | |
l() | |
} | |
h && clearTimeout(h); | |
if (i === c && m > e) { | |
l() | |
} else { | |
if (f !== true) { | |
h = setTimeout(i ? k : l, i === c ? e - m : e) | |
} | |
} | |
} | |
if ($.guid) { | |
g.guid = j.guid = j.guid || $.guid++ | |
} | |
return g | |
}; | |
$.debounce = function (d, e, f) { | |
return f === c ? a(d, e, false) : a(d, f, e !== false) | |
} | |
})(this); | |
(function () { | |
var __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.Gallery = (function (_super) { | |
__extends(Gallery, _super); | |
Gallery.prototype.idAttribute = 'slug'; | |
Gallery.prototype.url = function () { | |
if (this.isNew()) { | |
return '/'; | |
} else { | |
return "/" + this.id + ".json"; | |
} | |
}; | |
Gallery.prototype.isOwn = function () { | |
return !!this.get('own'); | |
}; | |
function Gallery() { | |
this.isOwn = __bind(this.isOwn, this); | |
this.url = __bind(this.url, this); | |
this.photos = new Chromatic.PhotosCollection(); | |
Backbone.Model.apply(this, arguments); | |
} | |
Gallery.prototype.parse = function (response) { | |
this.photos.add(response.photos, { | |
merge: true | |
}); | |
delete response.photos; | |
return response; | |
}; | |
return Gallery; | |
})(Backbone.Model); | |
}).call(this); | |
(function () { | |
var UPLOAD_PROGRESS_STEPS, _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}, __indexOf = [].indexOf || function (item) { | |
for (var i = 0, l = this.length; i < l; i++) { | |
if (i in this && this[i] === item) return i; | |
} | |
return -1; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
UPLOAD_PROGRESS_STEPS = [0, 55, 70, 85, 100]; | |
Chromatic.Photo = (function (_super) { | |
__extends(Photo, _super); | |
function Photo() { | |
this.backgroundURL = __bind(this.backgroundURL, this); | |
this.bigURL = __bind(this.bigURL, this); | |
this.smallURL = __bind(this.smallURL, this); | |
this.rootURL = __bind(this.rootURL, this); | |
this.hasUploadFailed = __bind(this.hasUploadFailed, this); | |
this.isUploading = __bind(this.isUploading, this); | |
this.upload = __bind(this.upload, this); | |
_ref = Photo.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
Photo.prototype.toJSON = function () { | |
return _.pick(this.attributes, 's3_object_key', 'aspect_ratio', 'shot_at', 'fingerprint'); | |
}; | |
Photo.prototype.upload = function (callback) { | |
var blob, _this = this; | |
if (this.isUploading() || this.hasUploadFailed()) { | |
return; | |
} | |
this.set('s3_object_key', guid()); | |
this.set('progress', UPLOAD_PROGRESS_STEPS[0]); | |
blob = dataURLtoBlob(this.get('big_data')); | |
return S3Upload.upload(blob, "" + (this.get('s3_object_key')) + "/big.jpg", function () { | |
_this.set('progress', UPLOAD_PROGRESS_STEPS[1]); | |
blob = dataURLtoBlob(_this.get('small_data')); | |
return S3Upload.upload(blob, "" + (_this.get('s3_object_key')) + "/small.jpg", function () { | |
_this.set('progress', UPLOAD_PROGRESS_STEPS[2]); | |
blob = dataURLtoBlob(_this.get('background_data')); | |
return S3Upload.upload(blob, "" + (_this.get('s3_object_key')) + "/background.jpg", function () { | |
_this.set('progress', UPLOAD_PROGRESS_STEPS[3]); | |
return _this.save(null, { | |
success: function () { | |
_this.set('progress', UPLOAD_PROGRESS_STEPS[4]); | |
return callback(); | |
}, | |
error: function () { | |
return _this.set('progress', -1); | |
} | |
}); | |
}, function (e) { | |
return _this.set('progress', parseInt(e.loaded / e.total * (UPLOAD_PROGRESS_STEPS[3] - UPLOAD_PROGRESS_STEPS[2])) + UPLOAD_PROGRESS_STEPS[2]); | |
}, function (e) { | |
return _this.set('progress', -1); | |
}); | |
}, function (e) { | |
return _this.set('progress', parseInt(e.loaded / e.total * (UPLOAD_PROGRESS_STEPS[2] - UPLOAD_PROGRESS_STEPS[1])) + UPLOAD_PROGRESS_STEPS[1]); | |
}, function (e) { | |
return _this.set('progress', -1); | |
}); | |
}, function (e) { | |
return _this.set('progress', parseInt(e.loaded / e.total * UPLOAD_PROGRESS_STEPS[1])); | |
}, function (e) { | |
return _this.set('progress', -1); | |
}); | |
}; | |
Photo.prototype.isUploading = function () { | |
var _i, _ref1, _results; | |
return _ref1 = this.get('progress'), __indexOf.call((function () { | |
_results = []; | |
for (_i = 0; _i <= 99; _i++) { | |
_results.push(_i); | |
} | |
return _results; | |
}).apply(this), _ref1) >= 0; | |
}; | |
Photo.prototype.hasUploadFailed = function () { | |
return this.get('progress') === -1; | |
}; | |
Photo.prototype.rootURL = function () { | |
return "http://img" + (parseInt(this.id.slice(-7, -6), 16) % 4) + ".chromatic.io/" + (this.get("s3_object_key")); | |
}; | |
Photo.prototype.smallURL = function () { | |
return "" + (this.rootURL()) + "/small.jpg"; | |
}; | |
Photo.prototype.bigURL = function () { | |
return "" + (this.rootURL()) + "/big.jpg"; | |
}; | |
Photo.prototype.backgroundURL = function () { | |
return "" + (this.rootURL()) + "/background.jpg"; | |
}; | |
return Photo; | |
})(Backbone.Model); | |
}).call(this); | |
(function () { | |
var _ref, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.GalleriesCollection = (function (_super) { | |
__extends(GalleriesCollection, _super); | |
function GalleriesCollection() { | |
_ref = GalleriesCollection.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
GalleriesCollection.prototype.model = Chromatic.Gallery; | |
GalleriesCollection.prototype.url = '/recent'; | |
GalleriesCollection.prototype.comparator = function (obj) { | |
return new Date(obj.get("created_at")) * -1; | |
}; | |
return GalleriesCollection; | |
})(Backbone.Collection); | |
}).call(this); | |
(function () { | |
var _ref, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.PhotosCollection = (function (_super) { | |
__extends(PhotosCollection, _super); | |
function PhotosCollection() { | |
_ref = PhotosCollection.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
PhotosCollection.prototype.model = Chromatic.Photo; | |
PhotosCollection.prototype.url = function () { | |
return "/" + Chromatic.app.gallery.id + "/photos"; | |
}; | |
PhotosCollection.prototype.initialize = function (models, options) {}; | |
PhotosCollection.prototype.comparator = function (obj) { | |
return new Date(obj.get("shot_at") || obj.get("created_at")) * 1; | |
}; | |
return PhotosCollection; | |
})(Backbone.Collection); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.GalleryView = (function (_super) { | |
__extends(GalleryView, _super); | |
function GalleryView() { | |
this.layout = __bind(this.layout, this); | |
this.lazyLoad = __bind(this.lazyLoad, this); | |
this.renderPhoto = __bind(this.renderPhoto, this); | |
this.photoWasAdded = __bind(this.photoWasAdded, this); | |
this.isUp = __bind(this.isUp, this); | |
this.down = __bind(this.down, this); | |
this.up = __bind(this.up, this); | |
_ref = GalleryView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
GalleryView.prototype.id = 'images'; | |
GalleryView.prototype.initialize = function () { | |
this.$el.hide(); | |
return $(document.body).append(this.$el); | |
}; | |
GalleryView.prototype.up = function (animated, callback) { | |
var _this = this; | |
document.title = "Chromatic – " + (Chromatic.app.gallery.get("slug")); | |
$(document.body).addClass("scroll"); | |
if (this.isUp()) { | |
this.layout(); | |
return typeof callback === "function" ? callback() : void 0; | |
} else { | |
if (animated) { | |
this.$el.fadeIn(500, callback); | |
} else { | |
this.$el.show(); | |
if (typeof callback === "function") { | |
callback(); | |
} | |
} | |
Chromatic.app.gallery.photos.bind("add", this.photoWasAdded); | |
Chromatic.app.gallery.photos.bind("remove", this.layout); | |
Chromatic.app.gallery.photos.each(function (photo) { | |
return _this.renderPhoto(photo); | |
}); | |
this.layout(); | |
$(window).on('resize', $.debounce(100, this.layout)); | |
return $(window).on('scroll', $.debounce(100, this.lazyLoad)); | |
} | |
}; | |
GalleryView.prototype.down = function (animated, callback) { | |
var _this = this; | |
if (!this.isUp()) { | |
return typeof callback === "function" ? callback() : void 0; | |
} | |
if (animated) { | |
this.$el.fadeOut(500, callback); | |
} else { | |
this.$el.hide(); | |
if (typeof callback === "function") { | |
callback(); | |
} | |
} | |
$(document.body).removeClass("scroll"); | |
$(window).off('resize scroll'); | |
if (Chromatic.app.gallery) { | |
Chromatic.app.gallery.photos.unbind("add", this.photoWasAdded); | |
Chromatic.app.gallery.photos.unbind("remove", this.layout); | |
return Chromatic.app.gallery.photos.each(function (photo) { | |
photo.view.remove(); | |
return photo.view = null; | |
}); | |
} | |
}; | |
GalleryView.prototype.isUp = function () { | |
return this.$el.is(':visible'); | |
}; | |
GalleryView.prototype.photoWasAdded = function (photo) { | |
this.renderPhoto(photo); | |
return this.layout(); | |
}; | |
GalleryView.prototype.renderPhoto = function (photo) { | |
var index; | |
photo.view || (photo.view = new Chromatic.GalleryPhotoView({ | |
model: photo | |
})); | |
if ((index = Chromatic.app.gallery.photos.indexOf(photo)) > 0) { | |
return Chromatic.app.gallery.photos.at(index - 1).view.$el.after(photo.view.el); | |
} else { | |
return this.$el.prepend(photo.view.el); | |
} | |
}; | |
GalleryView.prototype.lazyLoad = function () { | |
var container, threshold, viewport_bottom, viewport_top, _this = this; | |
threshold = 1000; | |
container = $(window); | |
viewport_top = container.scrollTop() - threshold; | |
viewport_bottom = container.height() + container.scrollTop() + threshold; | |
return Chromatic.app.gallery.photos.each(function (photo) { | |
if (photo.view.top < viewport_bottom && photo.view.bottom > viewport_top) { | |
return photo.view.load(); | |
} else { | |
return photo.view.unload(); | |
} | |
}); | |
}; | |
GalleryView.prototype.layout = function () { | |
var ideal_height, index, partition, photos, row_buffer, rows, summed_width, viewport_width, weights; | |
photos = Chromatic.app.gallery.photos; | |
if (!(this.isUp() && !photos.isEmpty())) { | |
return; | |
} | |
viewport_width = this.$el.width(); | |
ideal_height = parseInt($(window).height() / 2); | |
summed_width = photos.reduce((function (sum, p) { | |
return sum += p.get('aspect_ratio') * ideal_height; | |
}), 0); | |
rows = Math.round(summed_width / viewport_width); | |
if (rows < 1) { | |
photos.each(function (photo) { | |
return photo.view.resize(parseInt(ideal_height * photo.get('aspect_ratio')), ideal_height); | |
}); | |
} else { | |
weights = photos.map(function (p) { | |
return parseInt(p.get('aspect_ratio') * 100); | |
}); | |
partition = linear_partition(weights, rows); | |
index = 0; | |
row_buffer = new Backbone.Collection; | |
_.each(partition, function (row) { | |
var summed_ars; | |
row_buffer.reset(); | |
_.each(row, function () { | |
return row_buffer.add(photos.at(index++)); | |
}); | |
summed_ars = row_buffer.reduce((function (sum, p) { | |
return sum += p.get('aspect_ratio'); | |
}), 0); | |
return row_buffer.each(function (photo) { | |
return photo.view.resize(parseInt(viewport_width / summed_ars * photo.get('aspect_ratio')), parseInt(viewport_width / summed_ars)); | |
}); | |
}); | |
} | |
return this.lazyLoad(); | |
}; | |
return GalleryView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}, __indexOf = [].indexOf || function (item) { | |
for (var i = 0, l = this.length; i < l; i++) { | |
if (i in this && this[i] === item) return i; | |
} | |
return -1; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.GalleryPhotoView = (function (_super) { | |
__extends(GalleryPhotoView, _super); | |
function GalleryPhotoView() { | |
this.zoom = __bind(this.zoom, this); | |
this["delete"] = __bind(this["delete"], this); | |
this.updateProgress = __bind(this.updateProgress, this); | |
this.unload = __bind(this.unload, this); | |
this.load = __bind(this.load, this); | |
_ref = GalleryPhotoView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
GalleryPhotoView.prototype.className = 'photo'; | |
GalleryPhotoView.prototype.events = { | |
'click .delete': 'delete', | |
'click': 'zoom' | |
}; | |
GalleryPhotoView.prototype.initialize = function (options) { | |
this.model.bind("change:progress", this.updateProgress); | |
return this.render(); | |
}; | |
GalleryPhotoView.prototype.render = function () { | |
if (Chromatic.app.gallery.isOwn()) { | |
this.$el.append("<div class=\"delete\"></div>"); | |
} | |
if (this.model.isNew()) { | |
return this.$el.append("<div class=\"progress\" style=\"display:none\"><div><div></div></div></div>"); | |
} | |
}; | |
GalleryPhotoView.prototype.load = function () { | |
var url; | |
if (this.loaded) { | |
return; | |
} | |
url = this.model.isNew() ? this.model.get('small_data') : this.model.smallURL(); | |
this.$el.css('backgroundImage', "url(" + url + ")"); | |
return this.loaded = true; | |
}; | |
GalleryPhotoView.prototype.unload = function () { | |
this.$el.css('backgroundImage', ""); | |
return this.loaded = false; | |
}; | |
GalleryPhotoView.prototype.updateProgress = function (model, progress) { | |
var _i, _results; | |
if (__indexOf.call((function () { | |
_results = []; | |
for (_i = 0; _i <= 99; _i++) { | |
_results.push(_i); | |
} | |
return _results; | |
}).apply(this), progress) >= 0) { | |
return this.$el.find('.progress').fadeIn().find('div div').css('width', "" + progress + "%"); | |
} else if (progress === 100) { | |
return this.$el.find('.progress').fadeOut().find('div div').css('width', "100%"); | |
} | |
}; | |
GalleryPhotoView.prototype["delete"] = function (e) { | |
e.stopPropagation(); | |
this.remove(); | |
return this.model.destroy(); | |
}; | |
GalleryPhotoView.prototype.zoom = function () { | |
return Chromatic.app.fromGalleryToZoom(this.model); | |
}; | |
GalleryPhotoView.prototype.resize = function (width, height) { | |
this.$el.css({ | |
width: width - parseInt(this.$el.css('marginLeft')) * 2, | |
height: height - parseInt(this.$el.css('marginTop')) * 2 | |
}); | |
this.top = this.$el.offset().top; | |
return this.bottom = this.top + this.$el.height(); | |
}; | |
return GalleryPhotoView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.HomeView = (function (_super) { | |
__extends(HomeView, _super); | |
function HomeView() { | |
this.refreshRecentGalleries = __bind(this.refreshRecentGalleries, this); | |
this.isUp = __bind(this.isUp, this); | |
this.down = __bind(this.down, this); | |
this.up = __bind(this.up, this); | |
this.initialize = __bind(this.initialize, this); | |
_ref = HomeView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
HomeView.prototype.el = '#home'; | |
HomeView.prototype.initialize = function () { | |
return this.$el.hide(); | |
}; | |
HomeView.prototype.up = function (animated, callback) { | |
if (this.isUp()) { | |
return typeof callback === "function" ? callback() : void 0; | |
} | |
if (animated) { | |
this.$el.fadeIn(500, callback); | |
} else { | |
this.$el.show(); | |
if (typeof callback === "function") { | |
callback(); | |
} | |
} | |
document.title = "Chromatic – Instantly create beautiful photo galleries"; | |
Chromatic.app.galleries.bind("remove", this.refreshRecentGalleries); | |
return this.refreshRecentGalleries(); | |
}; | |
HomeView.prototype.down = function (animated, callback) { | |
var _this = this; | |
if (!this.isUp()) { | |
return typeof callback === "function" ? callback() : void 0; | |
} | |
if (animated) { | |
this.$el.fadeOut(500, callback); | |
} else { | |
this.$el.hide(); | |
if (typeof callback === "function") { | |
callback(); | |
} | |
} | |
Chromatic.app.galleries.unbind("remove", this.refreshRecentGalleries); | |
return Chromatic.app.galleries.each(function (gallery) { | |
if (gallery.recent_view) { | |
gallery.recent_view.remove(); | |
} | |
return gallery.recent_view = null; | |
}); | |
}; | |
HomeView.prototype.isUp = function () { | |
return this.$el.is(':visible'); | |
}; | |
HomeView.prototype.refreshRecentGalleries = function () { | |
var _this = this; | |
$('#recent-galleries').empty(); | |
if (Chromatic.app.galleries.any()) { | |
$('#recent-galleries').text("Your recent galleries: "); | |
} | |
return _.each(Chromatic.app.galleries.sort().first(5), function (gallery) { | |
gallery.recent_view = new Chromatic.RecentGalleryView({ | |
model: gallery | |
}); | |
return $('#recent-galleries').append(gallery.recent_view.el); | |
}); | |
}; | |
return HomeView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.RecentGalleryView = (function (_super) { | |
__extends(RecentGalleryView, _super); | |
function RecentGalleryView() { | |
this.open = __bind(this.open, this); | |
this.render = __bind(this.render, this); | |
this.initialize = __bind(this.initialize, this); | |
_ref = RecentGalleryView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
RecentGalleryView.prototype.tagName = 'a'; | |
RecentGalleryView.prototype.events = { | |
'click': 'open' | |
}; | |
RecentGalleryView.prototype.initialize = function () { | |
return this.render(); | |
}; | |
RecentGalleryView.prototype.render = function () { | |
this.$el.attr('href', this.model.get('slug')); | |
return this.$el.html(this.model.get('slug')); | |
}; | |
RecentGalleryView.prototype.open = function (e) { | |
e.stopPropagation(); | |
return Chromatic.app.fromHomeToGallery(this.model); | |
}; | |
return RecentGalleryView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}, __indexOf = [].indexOf || function (item) { | |
for (var i = 0, l = this.length; i < l; i++) { | |
if (i in this && this[i] === item) return i; | |
} | |
return -1; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.UploadView = (function (_super) { | |
__extends(UploadView, _super); | |
function UploadView() { | |
this.processNextFile = __bind(this.processNextFile, this); | |
this.finishProcessingFile = __bind(this.finishProcessingFile, this); | |
this.uploadNextPhoto = __bind(this.uploadNextPhoto, this); | |
this.drop = __bind(this.drop, this); | |
this.dragleave = __bind(this.dragleave, this); | |
this.dragover = __bind(this.dragover, this); | |
this.dragenter = __bind(this.dragenter, this); | |
this.handleFiles = __bind(this.handleFiles, this); | |
this.handleChooserEvent = __bind(this.handleChooserEvent, this); | |
this.stopNativeDragDrop = __bind(this.stopNativeDragDrop, this); | |
this.initialize = __bind(this.initialize, this); | |
_ref = UploadView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
UploadView.prototype.el = 'body'; | |
UploadView.prototype.events = { | |
'dragenter': 'dragenter', | |
'dragover': 'dragover', | |
'dragleave #drop-zone': 'dragleave', | |
'drop': 'drop', | |
'change input[type=file]': 'handleChooserEvent' | |
}; | |
UploadView.prototype.initialize = function () { | |
this.$drop_zone_el = $('#drop-zone'); | |
return this.$drop_zone_el.hide(); | |
}; | |
UploadView.prototype.stopNativeDragDrop = function (e) { | |
e.stopPropagation(); | |
return e.preventDefault(); | |
}; | |
UploadView.prototype.handleChooserEvent = function (e) { | |
var _this = this; | |
if (!e.originalEvent.target.files.length) { | |
return; | |
} | |
return setTimeout((function () { | |
return _this.handleFiles(e.originalEvent.target.files); | |
}), 200); | |
}; | |
UploadView.prototype.handleFiles = function (files) { | |
this.files = _.filter(files, function (file) { | |
return file.type === 'image/jpeg'; | |
}); | |
if (Chromatic.app.gallery) { | |
return this.processNextFile(); | |
} else { | |
return Chromatic.app.fromHomeToCreateGallery(this.processNextFile); | |
} | |
}; | |
UploadView.prototype.dragenter = function (e) { | |
this.stopNativeDragDrop(e); | |
if (Chromatic.app.gallery && !Chromatic.app.gallery.isOwn()) { | |
return e.originalEvent.dataTransfer.dropEffect = 'none'; | |
} | |
this.$drop_zone_el.fadeIn(); | |
return this.$drop_zone_el.find('.caption').text(Chromatic.app.gallery ? 'Drop photos to add them to this gallery' : 'Drop photos here to create a new gallery'); | |
}; | |
UploadView.prototype.dragover = function (e) { | |
this.stopNativeDragDrop(e); | |
if (Chromatic.app.gallery && !Chromatic.app.gallery.isOwn()) { | |
return e.originalEvent.dataTransfer.dropEffect = 'none'; | |
} | |
}; | |
UploadView.prototype.dragleave = function (e) { | |
this.stopNativeDragDrop(e); | |
return this.$drop_zone_el.fadeOut(); | |
}; | |
UploadView.prototype.drop = function (e) { | |
this.stopNativeDragDrop(e); | |
this.$drop_zone_el.hide(); | |
return this.handleFiles(e.originalEvent.dataTransfer.files); | |
}; | |
UploadView.prototype.uploadNextPhoto = function () { | |
var next; | |
if (Chromatic.app.gallery.photos.filter(function (p) { | |
return p.isUploading(); | |
}).length >= 3) { | |
return; | |
} | |
if (next = Chromatic.app.gallery.photos.find(function (p) { | |
return p.isNew() && !p.isUploading(); | |
})) { | |
return next.upload(this.uploadNextPhoto); | |
} | |
}; | |
UploadView.prototype.finishProcessingFile = function () { | |
this.uploadNextPhoto(); | |
return setTimeout(this.processNextFile.bind(this), 100); | |
}; | |
UploadView.prototype.processNextFile = function () { | |
var array_buffer_reader, file, slice, _this = this; | |
if (!(file = this.files.shift())) { | |
return; | |
} | |
if (file.type !== "image/jpeg") { | |
return this.finishProcessingFile(); | |
} | |
if (file.size < 100 * 1000) { | |
return this.finishProcessingFile(); | |
} | |
if (file.size > 20 * 1000 * 1000) { | |
return this.finishProcessingFile(); | |
} | |
array_buffer_reader = new FileReader(); | |
array_buffer_reader.onload = function (array_buffer_reader_event) { | |
var data_url_reader, exif_date, exif_reader, fingerprint, result, shot_at; | |
result = array_buffer_reader_event.target.result; | |
fingerprint = SparkMD5.ArrayBuffer.hash(result); | |
if (__indexOf.call(Chromatic.app.gallery.photos.pluck("fingerprint"), fingerprint) >= 0) { | |
console.log("Photo with same fingerprint already present", fingerprint); | |
return _this.finishProcessingFile(); | |
} | |
try { | |
exif_reader = new ExifReader(); | |
exif_reader.load(result); | |
exif_date = exif_reader.getTagDescription('DateTimeOriginal'); | |
shot_at = new Date(Date.parse("" + (exif_date.split(" ")[0].replace(/:/g, '/')) + " " + (exif_date.split(" ")[1]))); | |
} catch (_error) {} | |
shot_at = shot_at || file.lastModifiedDate; | |
data_url_reader = new FileReader(); | |
data_url_reader.onload = function (data_url_reader_event) { | |
var img; | |
result = data_url_reader_event.target.result; | |
img = new Image(); | |
img.onload = function () { | |
var small; | |
small = resize(img, 800, 800); | |
return small.onload = function () { | |
var background, big; | |
background = blur(small, 180); | |
big = resize(img, 2000, 2000); | |
Chromatic.app.gallery.photos.add({ | |
fingerprint: fingerprint, | |
aspect_ratio: img.width / img.height, | |
shot_at: shot_at, | |
small_data: small.src, | |
big_data: big.src, | |
background_data: background.src | |
}); | |
return _this.finishProcessingFile(); | |
}; | |
}; | |
return img.src = result; | |
}; | |
return data_url_reader.readAsDataURL(file); | |
}; | |
slice = file.slice || file.mozSlice || file.webkitSlice; | |
return array_buffer_reader.readAsArrayBuffer(slice.call(file, 0, 131072)); | |
}; | |
return UploadView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
$.extend($.easing, { | |
easeOutCirc: function (x, t, b, c, d) { | |
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b; | |
} | |
}); | |
jQuery.event.special.swipe.settings.sensitivity = 100; | |
Chromatic.ZoomView = (function (_super) { | |
__extends(ZoomView, _super); | |
function ZoomView() { | |
this.updateRoute = __bind(this.updateRoute, this); | |
this.updatePageTitle = __bind(this.updatePageTitle, this); | |
this.hideArrows = __bind(this.hideArrows, this); | |
this.showArrows = __bind(this.showArrows, this); | |
this.showPrevious = __bind(this.showPrevious, this); | |
this.showNext = __bind(this.showNext, this); | |
this.close = __bind(this.close, this); | |
this.cancel = __bind(this.cancel, this); | |
this.move = __bind(this.move, this); | |
this.layout = __bind(this.layout, this); | |
this.isUp = __bind(this.isUp, this); | |
this.up = __bind(this.up, this); | |
this.down = __bind(this.down, this); | |
this.render = __bind(this.render, this); | |
this.initialize = __bind(this.initialize, this); | |
_ref = ZoomView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
ZoomView.prototype.id = 'zoom'; | |
ZoomView.prototype.events = { | |
'swipeup': 'close', | |
'swiperight': 'showPrevious', | |
'swipeleft': 'showNext', | |
'swipecanceled': 'cancel', | |
'click .left': 'showPrevious', | |
'click .right': 'showNext', | |
'click': 'close', | |
'move': 'move', | |
'mousemove': 'showArrows', | |
'mouseenter': 'showArrows', | |
'mouseleave': 'hideArrows' | |
}; | |
ZoomView.prototype.initialize = function () { | |
this.$el.hide(); | |
return $(document.body).append(this.render().$el); | |
}; | |
ZoomView.prototype.render = function () { | |
this.$el.html("<div class=\"arrow left\"></div><div class=\"arrow right\"></div>"); | |
this.delegateEvents(); | |
return this; | |
}; | |
ZoomView.prototype.down = function (animated, callback) { | |
if (!this.isUp()) { | |
return typeof callback === "function" ? callback() : void 0; | |
} | |
if (animated) { | |
this.$el.fadeOut(500, callback); | |
} else { | |
this.$el.hide(); | |
if (typeof callback === "function") { | |
callback(); | |
} | |
} | |
$(document.body).css('overflowY', 'auto'); | |
this.previous_zoom_photo_view.remove(); | |
this.current_zoom_photo_view.remove(); | |
this.next_zoom_photo_view.remove(); | |
this.previous_zoom_photo_view = null; | |
this.current_zoom_photo_view = null; | |
this.next_zoom_photo_view = null; | |
key.unbind('esc'); | |
key.unbind('enter'); | |
key.unbind('up'); | |
key.unbind('left'); | |
key.unbind('j'); | |
key.unbind('right'); | |
key.unbind('k'); | |
return $(window).off('resize orientationchange'); | |
}; | |
ZoomView.prototype.up = function (animated, photo, callback) { | |
var next, photos, previous, _this = this; | |
if (this.isUp()) { | |
if (this.current === photo) { | |
return callback(); | |
} | |
} else { | |
if (animated) { | |
this.$el.fadeIn(500); | |
} else { | |
this.$el.show(); | |
if (typeof callback === "function") { | |
callback(); | |
} | |
} | |
$(document.body).css('overflowY', 'hidden'); | |
key('esc, enter, up', this.close); | |
key('left, j', $.throttle(500, this.showPrevious)); | |
key('right, k', $.throttle(500, this.showNext)); | |
$(window).on('resize orientationchange', $.debounce(100, function () { | |
return _this.layout(); | |
})); | |
this.hideArrows(false); | |
} | |
photos = Chromatic.app.gallery.photos; | |
if (this.previous_zoom_photo_view) { | |
this.previous_zoom_photo_view.remove(); | |
} | |
if (this.current_zoom_photo_view) { | |
this.current_zoom_photo_view.remove(); | |
} | |
if (this.next_zoom_photo_view) { | |
this.next_zoom_photo_view.remove(); | |
} | |
previous = photos.at(photos.indexOf(photo) - 1) || photos.last(); | |
this.current = photo; | |
next = photos.at(photos.indexOf(photo) + 1) || photos.first(); | |
this.previous_zoom_photo_view = new Chromatic.ZoomPhotoView({ | |
model: previous | |
}); | |
this.current_zoom_photo_view = new Chromatic.ZoomPhotoView({ | |
model: this.current | |
}); | |
this.next_zoom_photo_view = new Chromatic.ZoomPhotoView({ | |
model: next | |
}); | |
this.layout(); | |
return this.updatePageTitle(); | |
}; | |
ZoomView.prototype.isUp = function () { | |
return this.$el.is(':visible'); | |
}; | |
ZoomView.prototype.layout = function (offset, animated) { | |
if (offset == null) { | |
offset = 0; | |
} | |
this.current_zoom_photo_view.layout('current', offset, animated); | |
this.previous_zoom_photo_view.layout('previous', offset, animated); | |
return this.next_zoom_photo_view.layout('next', offset, animated); | |
}; | |
ZoomView.prototype.move = function (e) { | |
return this.layout(e.distX, false); | |
}; | |
ZoomView.prototype.cancel = function (e) { | |
return this.layout(0, true); | |
}; | |
ZoomView.prototype.close = function () { | |
clearTimeout(this.arrows_timer); | |
return Chromatic.app.fromZoomToGallery(); | |
}; | |
ZoomView.prototype.showNext = function (e) { | |
var next, photos; | |
if (e) { | |
e.preventDefault(); | |
} | |
if (e) { | |
e.stopPropagation(); | |
} | |
if (e.type === "keydown") { | |
this.hideArrows(); | |
} else { | |
this.showArrows(); | |
} | |
photos = Chromatic.app.gallery.photos; | |
this.previous_zoom_photo_view.remove(); | |
this.previous_zoom_photo_view = null; | |
this.previous_zoom_photo_view = this.current_zoom_photo_view; | |
this.current_zoom_photo_view = this.next_zoom_photo_view; | |
this.current = photos.at(photos.indexOf(this.current) + 1) || photos.first(); | |
next = photos.at(photos.indexOf(this.current) + 1) || photos.first(); | |
this.next_zoom_photo_view = new Chromatic.ZoomPhotoView({ | |
model: next | |
}); | |
this.previous_zoom_photo_view.layout('previous', 0, true); | |
this.current_zoom_photo_view.layout('current', 0, true); | |
this.next_zoom_photo_view.layout('next', 0, false); | |
this.updatePageTitle(); | |
return this.updateRoute(); | |
}; | |
ZoomView.prototype.showPrevious = function (e) { | |
var photos, previous; | |
if (e) { | |
e.preventDefault(); | |
} | |
if (e) { | |
e.stopPropagation(); | |
} | |
if (e.type === "keydown") { | |
this.hideArrows(); | |
} else { | |
this.showArrows(); | |
} | |
photos = Chromatic.app.gallery.photos; | |
this.next_zoom_photo_view.remove(); | |
this.next_zoom_photo_view = null; | |
this.next_zoom_photo_view = this.current_zoom_photo_view; | |
this.current_zoom_photo_view = this.previous_zoom_photo_view; | |
this.current = photos.at(photos.indexOf(this.current) - 1) || photos.last(); | |
previous = photos.at(photos.indexOf(this.current) - 1) || photos.last(); | |
this.previous_zoom_photo_view = new Chromatic.ZoomPhotoView({ | |
model: previous | |
}); | |
this.next_zoom_photo_view.layout('next', 0, true); | |
this.current_zoom_photo_view.layout('current', 0, true); | |
this.previous_zoom_photo_view.layout('previous', 0, false); | |
this.updatePageTitle(); | |
return this.updateRoute(); | |
}; | |
ZoomView.prototype.showArrows = function () { | |
var _this = this; | |
this.$el.find(".arrow").stop().animate({ | |
opacity: 1 | |
}, 200); | |
clearTimeout(this.arrows_timer); | |
return this.arrows_timer = window.setTimeout((function () { | |
return _this.hideArrows(true); | |
}), 3000); | |
}; | |
ZoomView.prototype.hideArrows = function (animated) { | |
return this.$el.find(".arrow").animate({ | |
opacity: 0.01 | |
}, animated != null ? animated : { | |
1000: 0 | |
}); | |
}; | |
ZoomView.prototype.updatePageTitle = function () { | |
var gallery; | |
gallery = Chromatic.app.gallery; | |
return document.title = "" + (gallery.photos.indexOf(this.current) + 1) + "/" + gallery.photos.length + " – Chromatic – " + (gallery.get("slug")); | |
}; | |
ZoomView.prototype.updateRoute = function () { | |
var gallery; | |
gallery = Chromatic.app.gallery; | |
return Backbone.history.navigate("" + gallery.id + "/" + (gallery.photos.indexOf(this.current) + 1)); | |
}; | |
return ZoomView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.ZoomPhotoView = (function (_super) { | |
__extends(ZoomPhotoView, _super); | |
function ZoomPhotoView() { | |
this.layout = __bind(this.layout, this); | |
_ref = ZoomPhotoView.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
ZoomPhotoView.prototype.initialize = function (options) { | |
this.render(); | |
return $('#zoom').append(this.el); | |
}; | |
ZoomPhotoView.prototype.render = function () { | |
var big_img, _this = this; | |
this.$photo_el = $('<div class="photo"></div>'); | |
this.$background_el = $('<div class="background"></div>'); | |
if (this.model.isNew()) { | |
this.$photo_el.css('backgroundImage', "url(" + (this.model.get('big_data')) + ")"); | |
this.$background_el.css('backgroundImage', "url(" + (this.model.get('background_data')) + ")"); | |
} else { | |
big_img = new Image(); | |
big_img.onload = function () { | |
return _this.$photo_el.css('backgroundImage', "url(" + (_this.model.bigURL()) + ")"); | |
}; | |
big_img.src = this.model.bigURL(); | |
this.$photo_el.css('backgroundImage', "url(" + (this.model.smallURL()) + ")"); | |
this.$background_el.css('backgroundImage', "url(" + (this.model.backgroundURL()) + ")"); | |
} | |
this.$el.append(this.$photo_el, this.$background_el); | |
return this; | |
}; | |
ZoomPhotoView.prototype.layout = function (pos, offset, animated) { | |
var container, height, left, opacity, width; | |
if (offset == null) { | |
offset = 0; | |
} | |
container = $('#zoom'); | |
if (container.width() / container.height() > this.model.get("aspect_ratio")) { | |
height = container.height(); | |
width = container.height() * this.model.get("aspect_ratio"); | |
} else { | |
height = container.width() / this.model.get("aspect_ratio"); | |
width = container.width(); | |
} | |
this.$photo_el.css({ | |
height: height, | |
width: width, | |
top: (container.height() - height) / 2 | |
}); | |
left = (function () { | |
switch (pos) { | |
case 'previous': | |
return -width - 20 + offset; | |
case 'current': | |
return (container.width() - width) / 2 + offset; | |
case 'next': | |
return container.width() + 20 + offset; | |
} | |
})(); | |
opacity = (function () { | |
switch (pos) { | |
case 'current': | |
return 1 - Math.abs(offset) / container.width() * 2; | |
case 'previous': | |
return 0 + offset / container.width() * 2; | |
case 'next': | |
return 0 - offset / container.width() * 2; | |
} | |
})(); | |
if (animated) { | |
this.$photo_el.stop().animate({ | |
left: left | |
}, 600, 'easeOutCirc'); | |
return this.$background_el.stop().animate({ | |
opacity: opacity | |
}, 600, 'easeOutCirc'); | |
} else { | |
this.$photo_el.css('left', left); | |
return this.$background_el.css('opacity', opacity); | |
} | |
}; | |
return ZoomPhotoView; | |
})(Backbone.View); | |
}).call(this); | |
(function () { | |
var _ref, __bind = function (fn, me) { | |
return function () { | |
return fn.apply(me, arguments); | |
}; | |
}, __hasProp = {}.hasOwnProperty, | |
__extends = function (child, parent) { | |
for (var key in parent) { | |
if (__hasProp.call(parent, key)) child[key] = parent[key]; | |
} | |
function ctor() { | |
this.constructor = child; | |
} | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
this.Chromatic = this.Chromatic || {}; | |
Chromatic.App = (function (_super) { | |
__extends(App, _super); | |
function App() { | |
this.fromHomeToCreateGallery = __bind(this.fromHomeToCreateGallery, this); | |
_ref = App.__super__.constructor.apply(this, arguments); | |
return _ref; | |
} | |
App.prototype.initialize = function (options) { | |
this.galleries = new Chromatic.GalleriesCollection(options.recent_galleries); | |
if (options.gallery) { | |
this.galleries.add(options.gallery, { | |
merge: true | |
}); | |
this.galleries.get(options.gallery.slug).photos.add(options.gallery.photos); | |
} | |
this.home_view = new Chromatic.HomeView(); | |
this.gallery_view = new Chromatic.GalleryView(); | |
this.upload_view = new Chromatic.UploadView(); | |
this.zoom_view = new Chromatic.ZoomView(); | |
return Backbone.history.options = { | |
pushState: true, | |
hashChange: false | |
}; | |
}; | |
App.prototype.routes = { | |
"": "home", | |
":id": "gallery", | |
":id/:pos": "zoom" | |
}; | |
App.prototype.home = function () { | |
this.home_view.up(); | |
this.gallery_view.down(); | |
this.zoom_view.down(); | |
return this.gallery = null; | |
}; | |
App.prototype.gallery = function (id) { | |
this.gallery = this.galleries.get(id); | |
this.gallery_view.up(); | |
this.home_view.down(); | |
return this.zoom_view.down(); | |
}; | |
App.prototype.zoom = function (id, pos) { | |
this.gallery = this.galleries.get(id); | |
this.gallery_view.up(); | |
this.zoom_view.up(false, this.gallery.photos.at(pos - 1)); | |
return this.home_view.down(); | |
}; | |
App.prototype.fromHomeToGallery = function (gallery) { | |
var both_completed, _this = this; | |
this.gallery = gallery; | |
both_completed = _.after(2, function () { | |
return _this.gallery_view.up(true); | |
}); | |
this.home_view.down(true, both_completed); | |
this.gallery.fetch({ | |
success: both_completed | |
}); | |
return Backbone.history.navigate(this.gallery.id); | |
}; | |
App.prototype.fromHomeToCreateGallery = function (callback) { | |
var both_completed, _this = this; | |
both_completed = _.after(2, function () { | |
Backbone.history.navigate(_this.gallery.id); | |
_this.gallery_view.up(true); | |
return callback(); | |
}); | |
this.home_view.down(true, both_completed); | |
return this.gallery = this.galleries.create({ | |
own: true | |
}, { | |
success: both_completed | |
}); | |
}; | |
App.prototype.fromZoomToGallery = function () { | |
this.zoom_view.down(true); | |
this.gallery_view.up(); | |
return Backbone.history.navigate(this.gallery.id); | |
}; | |
App.prototype.fromGalleryToZoom = function (photo) { | |
this.zoom_view.up(true, photo); | |
return Backbone.history.navigate("" + this.gallery.id + "/" + (this.gallery.photos.indexOf(photo) + 1)); | |
}; | |
return App; | |
})(Backbone.Router); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment