Created
October 6, 2012 19:42
-
-
Save MACSkeptic/3845896 to your computer and use it in GitHub Desktop.
radar plotting shenanigans
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
.DS_Store | |
GTAGS | |
GRTAGS | |
GPATH | |
*.swp* | |
*.swo* |
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
rvm_install_on_use_flag=1 | |
rvm use --create 1.9.3@radar_madness |
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
# The static content rooted in the current working directory | |
# Dir.pwd => http://0.0.0.0:3000/ | |
# thin -R static.ru start | |
root=Dir.pwd | |
puts ">>> Serving: #{root}" | |
run Rack::Directory.new("#{root}") |
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() { | |
function d3_class(ctor, properties) { | |
try { | |
for (var key in properties) { | |
Object.defineProperty(ctor.prototype, key, { | |
value: properties[key], | |
enumerable: false | |
}); | |
} | |
} catch (e) { | |
ctor.prototype = properties; | |
} | |
} | |
function d3_arrayCopy(pseudoarray) { | |
var i = -1, n = pseudoarray.length, array = []; | |
while (++i < n) array.push(pseudoarray[i]); | |
return array; | |
} | |
function d3_arraySlice(pseudoarray) { | |
return Array.prototype.slice.call(pseudoarray); | |
} | |
function d3_Map() {} | |
function d3_identity(d) { | |
return d; | |
} | |
function d3_this() { | |
return this; | |
} | |
function d3_true() { | |
return true; | |
} | |
function d3_functor(v) { | |
return typeof v === "function" ? v : function() { | |
return v; | |
}; | |
} | |
function d3_rebind(target, source, method) { | |
return function() { | |
var value = method.apply(source, arguments); | |
return arguments.length ? target : value; | |
}; | |
} | |
function d3_number(x) { | |
return x != null && !isNaN(x); | |
} | |
function d3_zipLength(d) { | |
return d.length; | |
} | |
function d3_splitter(d) { | |
return d == null; | |
} | |
function d3_collapse(s) { | |
return s.trim().replace(/\s+/g, " "); | |
} | |
function d3_range_integerScale(x) { | |
var k = 1; | |
while (x * k % 1) k *= 10; | |
return k; | |
} | |
function d3_dispatch() {} | |
function d3_dispatch_event(dispatch) { | |
function event() { | |
var z = listeners, i = -1, n = z.length, l; | |
while (++i < n) if (l = z[i].on) l.apply(this, arguments); | |
return dispatch; | |
} | |
var listeners = [], listenerByName = new d3_Map; | |
event.on = function(name, listener) { | |
var l = listenerByName.get(name), i; | |
if (arguments.length < 2) return l && l.on; | |
if (l) { | |
l.on = null; | |
listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); | |
listenerByName.remove(name); | |
} | |
if (listener) listeners.push(listenerByName.set(name, { | |
on: listener | |
})); | |
return dispatch; | |
}; | |
return event; | |
} | |
function d3_format_precision(x, p) { | |
return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1); | |
} | |
function d3_format_typeDefault(x) { | |
return x + ""; | |
} | |
function d3_format_group(value) { | |
var i = value.lastIndexOf("."), f = i >= 0 ? value.substring(i) : (i = value.length, ""), t = []; | |
while (i > 0) t.push(value.substring(i -= 3, i + 3)); | |
return t.reverse().join(",") + f; | |
} | |
function d3_formatPrefix(d, i) { | |
var k = Math.pow(10, Math.abs(8 - i) * 3); | |
return { | |
scale: i > 8 ? function(d) { | |
return d / k; | |
} : function(d) { | |
return d * k; | |
}, | |
symbol: d | |
}; | |
} | |
function d3_ease_clamp(f) { | |
return function(t) { | |
return t <= 0 ? 0 : t >= 1 ? 1 : f(t); | |
}; | |
} | |
function d3_ease_reverse(f) { | |
return function(t) { | |
return 1 - f(1 - t); | |
}; | |
} | |
function d3_ease_reflect(f) { | |
return function(t) { | |
return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); | |
}; | |
} | |
function d3_ease_identity(t) { | |
return t; | |
} | |
function d3_ease_poly(e) { | |
return function(t) { | |
return Math.pow(t, e); | |
}; | |
} | |
function d3_ease_sin(t) { | |
return 1 - Math.cos(t * Math.PI / 2); | |
} | |
function d3_ease_exp(t) { | |
return Math.pow(2, 10 * (t - 1)); | |
} | |
function d3_ease_circle(t) { | |
return 1 - Math.sqrt(1 - t * t); | |
} | |
function d3_ease_elastic(a, p) { | |
var s; | |
if (arguments.length < 2) p = .45; | |
if (arguments.length < 1) { | |
a = 1; | |
s = p / 4; | |
} else s = p / (2 * Math.PI) * Math.asin(1 / a); | |
return function(t) { | |
return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * Math.PI / p); | |
}; | |
} | |
function d3_ease_back(s) { | |
if (!s) s = 1.70158; | |
return function(t) { | |
return t * t * ((s + 1) * t - s); | |
}; | |
} | |
function d3_ease_bounce(t) { | |
return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; | |
} | |
function d3_eventCancel() { | |
d3.event.stopPropagation(); | |
d3.event.preventDefault(); | |
} | |
function d3_eventSource() { | |
var e = d3.event, s; | |
while (s = e.sourceEvent) e = s; | |
return e; | |
} | |
function d3_eventDispatch(target) { | |
var dispatch = new d3_dispatch, i = 0, n = arguments.length; | |
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); | |
dispatch.of = function(thiz, argumentz) { | |
return function(e1) { | |
try { | |
var e0 = e1.sourceEvent = d3.event; | |
e1.target = target; | |
d3.event = e1; | |
dispatch[e1.type].apply(thiz, argumentz); | |
} finally { | |
d3.event = e0; | |
} | |
}; | |
}; | |
return dispatch; | |
} | |
function d3_transform(m) { | |
var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; | |
if (r0[0] * r1[1] < r1[0] * r0[1]) { | |
r0[0] *= -1; | |
r0[1] *= -1; | |
kx *= -1; | |
kz *= -1; | |
} | |
this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_transformDegrees; | |
this.translate = [ m.e, m.f ]; | |
this.scale = [ kx, ky ]; | |
this.skew = ky ? Math.atan2(kz, ky) * d3_transformDegrees : 0; | |
} | |
function d3_transformDot(a, b) { | |
return a[0] * b[0] + a[1] * b[1]; | |
} | |
function d3_transformNormalize(a) { | |
var k = Math.sqrt(d3_transformDot(a, a)); | |
if (k) { | |
a[0] /= k; | |
a[1] /= k; | |
} | |
return k; | |
} | |
function d3_transformCombine(a, b, k) { | |
a[0] += k * b[0]; | |
a[1] += k * b[1]; | |
return a; | |
} | |
function d3_interpolateByName(name) { | |
return name == "transform" ? d3.interpolateTransform : d3.interpolate; | |
} | |
function d3_uninterpolateNumber(a, b) { | |
b = b - (a = +a) ? 1 / (b - a) : 0; | |
return function(x) { | |
return (x - a) * b; | |
}; | |
} | |
function d3_uninterpolateClamp(a, b) { | |
b = b - (a = +a) ? 1 / (b - a) : 0; | |
return function(x) { | |
return Math.max(0, Math.min(1, (x - a) * b)); | |
}; | |
} | |
function d3_rgb(r, g, b) { | |
return new d3_Rgb(r, g, b); | |
} | |
function d3_Rgb(r, g, b) { | |
this.r = r; | |
this.g = g; | |
this.b = b; | |
} | |
function d3_rgb_hex(v) { | |
return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); | |
} | |
function d3_rgb_parse(format, rgb, hsl) { | |
var r = 0, g = 0, b = 0, m1, m2, name; | |
m1 = /([a-z]+)\((.*)\)/i.exec(format); | |
if (m1) { | |
m2 = m1[2].split(","); | |
switch (m1[1]) { | |
case "hsl": | |
{ | |
return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); | |
} | |
case "rgb": | |
{ | |
return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); | |
} | |
} | |
} | |
if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); | |
if (format != null && format.charAt(0) === "#") { | |
if (format.length === 4) { | |
r = format.charAt(1); | |
r += r; | |
g = format.charAt(2); | |
g += g; | |
b = format.charAt(3); | |
b += b; | |
} else if (format.length === 7) { | |
r = format.substring(1, 3); | |
g = format.substring(3, 5); | |
b = format.substring(5, 7); | |
} | |
r = parseInt(r, 16); | |
g = parseInt(g, 16); | |
b = parseInt(b, 16); | |
} | |
return rgb(r, g, b); | |
} | |
function d3_rgb_hsl(r, g, b) { | |
var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; | |
if (d) { | |
s = l < .5 ? d / (max + min) : d / (2 - max - min); | |
if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; | |
h *= 60; | |
} else { | |
s = h = 0; | |
} | |
return d3_hsl(h, s, l); | |
} | |
function d3_rgb_lab(r, g, b) { | |
r = d3_rgb_xyz(r); | |
g = d3_rgb_xyz(g); | |
b = d3_rgb_xyz(b); | |
var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); | |
return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); | |
} | |
function d3_rgb_xyz(r) { | |
return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); | |
} | |
function d3_rgb_parseNumber(c) { | |
var f = parseFloat(c); | |
return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; | |
} | |
function d3_hsl(h, s, l) { | |
return new d3_Hsl(h, s, l); | |
} | |
function d3_Hsl(h, s, l) { | |
this.h = h; | |
this.s = s; | |
this.l = l; | |
} | |
function d3_hsl_rgb(h, s, l) { | |
function v(h) { | |
if (h > 360) h -= 360; else if (h < 0) h += 360; | |
if (h < 60) return m1 + (m2 - m1) * h / 60; | |
if (h < 180) return m2; | |
if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; | |
return m1; | |
} | |
function vv(h) { | |
return Math.round(v(h) * 255); | |
} | |
var m1, m2; | |
h = h % 360; | |
if (h < 0) h += 360; | |
s = s < 0 ? 0 : s > 1 ? 1 : s; | |
l = l < 0 ? 0 : l > 1 ? 1 : l; | |
m2 = l <= .5 ? l * (1 + s) : l + s - l * s; | |
m1 = 2 * l - m2; | |
return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); | |
} | |
function d3_hcl(h, c, l) { | |
return new d3_Hcl(h, c, l); | |
} | |
function d3_Hcl(h, c, l) { | |
this.h = h; | |
this.c = c; | |
this.l = l; | |
} | |
function d3_hcl_lab(h, c, l) { | |
return d3_lab(l, Math.cos(h *= Math.PI / 180) * c, Math.sin(h) * c); | |
} | |
function d3_lab(l, a, b) { | |
return new d3_Lab(l, a, b); | |
} | |
function d3_Lab(l, a, b) { | |
this.l = l; | |
this.a = a; | |
this.b = b; | |
} | |
function d3_lab_rgb(l, a, b) { | |
var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; | |
x = d3_lab_xyz(x) * d3_lab_X; | |
y = d3_lab_xyz(y) * d3_lab_Y; | |
z = d3_lab_xyz(z) * d3_lab_Z; | |
return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); | |
} | |
function d3_lab_hcl(l, a, b) { | |
return d3_hcl(Math.atan2(b, a) / Math.PI * 180, Math.sqrt(a * a + b * b), l); | |
} | |
function d3_lab_xyz(x) { | |
return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; | |
} | |
function d3_xyz_lab(x) { | |
return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; | |
} | |
function d3_xyz_rgb(r) { | |
return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); | |
} | |
function d3_selection(groups) { | |
d3_arraySubclass(groups, d3_selectionPrototype); | |
return groups; | |
} | |
function d3_selection_selector(selector) { | |
return function() { | |
return d3_select(selector, this); | |
}; | |
} | |
function d3_selection_selectorAll(selector) { | |
return function() { | |
return d3_selectAll(selector, this); | |
}; | |
} | |
function d3_selection_attr(name, value) { | |
function attrNull() { | |
this.removeAttribute(name); | |
} | |
function attrNullNS() { | |
this.removeAttributeNS(name.space, name.local); | |
} | |
function attrConstant() { | |
this.setAttribute(name, value); | |
} | |
function attrConstantNS() { | |
this.setAttributeNS(name.space, name.local, value); | |
} | |
function attrFunction() { | |
var x = value.apply(this, arguments); | |
if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); | |
} | |
function attrFunctionNS() { | |
var x = value.apply(this, arguments); | |
if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); | |
} | |
name = d3.ns.qualify(name); | |
return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; | |
} | |
function d3_selection_classedRe(name) { | |
return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); | |
} | |
function d3_selection_classed(name, value) { | |
function classedConstant() { | |
var i = -1; | |
while (++i < n) name[i](this, value); | |
} | |
function classedFunction() { | |
var i = -1, x = value.apply(this, arguments); | |
while (++i < n) name[i](this, x); | |
} | |
name = name.trim().split(/\s+/).map(d3_selection_classedName); | |
var n = name.length; | |
return typeof value === "function" ? classedFunction : classedConstant; | |
} | |
function d3_selection_classedName(name) { | |
var re = d3_selection_classedRe(name); | |
return function(node, value) { | |
if (c = node.classList) return value ? c.add(name) : c.remove(name); | |
var c = node.className, cb = c.baseVal != null, cv = cb ? c.baseVal : c; | |
if (value) { | |
re.lastIndex = 0; | |
if (!re.test(cv)) { | |
cv = d3_collapse(cv + " " + name); | |
if (cb) c.baseVal = cv; else node.className = cv; | |
} | |
} else if (cv) { | |
cv = d3_collapse(cv.replace(re, " ")); | |
if (cb) c.baseVal = cv; else node.className = cv; | |
} | |
}; | |
} | |
function d3_selection_style(name, value, priority) { | |
function styleNull() { | |
this.style.removeProperty(name); | |
} | |
function styleConstant() { | |
this.style.setProperty(name, value, priority); | |
} | |
function styleFunction() { | |
var x = value.apply(this, arguments); | |
if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); | |
} | |
return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; | |
} | |
function d3_selection_property(name, value) { | |
function propertyNull() { | |
delete this[name]; | |
} | |
function propertyConstant() { | |
this[name] = value; | |
} | |
function propertyFunction() { | |
var x = value.apply(this, arguments); | |
if (x == null) delete this[name]; else this[name] = x; | |
} | |
return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; | |
} | |
function d3_selection_dataNode(data) { | |
return { | |
__data__: data | |
}; | |
} | |
function d3_selection_filter(selector) { | |
return function() { | |
return d3_selectMatches(this, selector); | |
}; | |
} | |
function d3_selection_sortComparator(comparator) { | |
if (!arguments.length) comparator = d3.ascending; | |
return function(a, b) { | |
return comparator(a && a.__data__, b && b.__data__); | |
}; | |
} | |
function d3_selection_on(type, listener, capture) { | |
function onRemove() { | |
var wrapper = this[name]; | |
if (wrapper) { | |
this.removeEventListener(type, wrapper, wrapper.$); | |
delete this[name]; | |
} | |
} | |
function onAdd() { | |
function wrapper(e) { | |
var o = d3.event; | |
d3.event = e; | |
args[0] = node.__data__; | |
try { | |
listener.apply(node, args); | |
} finally { | |
d3.event = o; | |
} | |
} | |
var node = this, args = arguments; | |
onRemove.call(this); | |
this.addEventListener(type, this[name] = wrapper, wrapper.$ = capture); | |
wrapper._ = listener; | |
} | |
var name = "__on" + type, i = type.indexOf("."); | |
if (i > 0) type = type.substring(0, i); | |
return listener ? onAdd : onRemove; | |
} | |
function d3_selection_each(groups, callback) { | |
for (var j = 0, m = groups.length; j < m; j++) { | |
for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { | |
if (node = group[i]) callback(node, i, j); | |
} | |
} | |
return groups; | |
} | |
function d3_selection_enter(selection) { | |
d3_arraySubclass(selection, d3_selection_enterPrototype); | |
return selection; | |
} | |
function d3_transition(groups, id, time) { | |
d3_arraySubclass(groups, d3_transitionPrototype); | |
var tweens = new d3_Map, event = d3.dispatch("start", "end"), ease = d3_transitionEase; | |
groups.id = id; | |
groups.time = time; | |
groups.tween = function(name, tween) { | |
if (arguments.length < 2) return tweens.get(name); | |
if (tween == null) tweens.remove(name); else tweens.set(name, tween); | |
return groups; | |
}; | |
groups.ease = function(value) { | |
if (!arguments.length) return ease; | |
ease = typeof value === "function" ? value : d3.ease.apply(d3, arguments); | |
return groups; | |
}; | |
groups.each = function(type, listener) { | |
if (arguments.length < 2) return d3_transition_each.call(groups, type); | |
event.on(type, listener); | |
return groups; | |
}; | |
d3.timer(function(elapsed) { | |
return d3_selection_each(groups, function(node, i, j) { | |
function start(elapsed) { | |
if (lock.active > id) return stop(); | |
lock.active = id; | |
tweens.forEach(function(key, value) { | |
if (value = value.call(node, d, i)) { | |
tweened.push(value); | |
} | |
}); | |
event.start.call(node, d, i); | |
if (!tick(elapsed)) d3.timer(tick, 0, time); | |
return 1; | |
} | |
function tick(elapsed) { | |
if (lock.active !== id) return stop(); | |
var t = (elapsed - delay) / duration, e = ease(t), n = tweened.length; | |
while (n > 0) { | |
tweened[--n].call(node, e); | |
} | |
if (t >= 1) { | |
stop(); | |
d3_transitionId = id; | |
event.end.call(node, d, i); | |
d3_transitionId = 0; | |
return 1; | |
} | |
} | |
function stop() { | |
if (!--lock.count) delete node.__transition__; | |
return 1; | |
} | |
var tweened = [], delay = node.delay, duration = node.duration, lock = (node = node.node).__transition__ || (node.__transition__ = { | |
active: 0, | |
count: 0 | |
}), d = node.__data__; | |
++lock.count; | |
delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time); | |
}); | |
}, 0, time); | |
return groups; | |
} | |
function d3_transition_each(callback) { | |
var id = d3_transitionId, ease = d3_transitionEase, delay = d3_transitionDelay, duration = d3_transitionDuration; | |
d3_transitionId = this.id; | |
d3_transitionEase = this.ease(); | |
d3_selection_each(this, function(node, i, j) { | |
d3_transitionDelay = node.delay; | |
d3_transitionDuration = node.duration; | |
callback.call(node = node.node, node.__data__, i, j); | |
}); | |
d3_transitionId = id; | |
d3_transitionEase = ease; | |
d3_transitionDelay = delay; | |
d3_transitionDuration = duration; | |
return this; | |
} | |
function d3_tweenNull(d, i, a) { | |
return a != "" && d3_tweenRemove; | |
} | |
function d3_tweenByName(b, name) { | |
return d3.tween(b, d3_interpolateByName(name)); | |
} | |
function d3_timer_step() { | |
var elapsed, now = Date.now(), t1 = d3_timer_queue; | |
while (t1) { | |
elapsed = now - t1.then; | |
if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed); | |
t1 = t1.next; | |
} | |
var delay = d3_timer_flush() - now; | |
if (delay > 24) { | |
if (isFinite(delay)) { | |
clearTimeout(d3_timer_timeout); | |
d3_timer_timeout = setTimeout(d3_timer_step, delay); | |
} | |
d3_timer_interval = 0; | |
} else { | |
d3_timer_interval = 1; | |
d3_timer_frame(d3_timer_step); | |
} | |
} | |
function d3_timer_flush() { | |
var t0 = null, t1 = d3_timer_queue, then = Infinity; | |
while (t1) { | |
if (t1.flush) { | |
t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next; | |
} else { | |
then = Math.min(then, t1.then + t1.delay); | |
t1 = (t0 = t1).next; | |
} | |
} | |
return then; | |
} | |
function d3_mousePoint(container, e) { | |
var svg = container.ownerSVGElement || container; | |
if (svg.createSVGPoint) { | |
var point = svg.createSVGPoint(); | |
if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) { | |
svg = d3.select(document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0); | |
var ctm = svg[0][0].getScreenCTM(); | |
d3_mouse_bug44083 = !(ctm.f || ctm.e); | |
svg.remove(); | |
} | |
if (d3_mouse_bug44083) { | |
point.x = e.pageX; | |
point.y = e.pageY; | |
} else { | |
point.x = e.clientX; | |
point.y = e.clientY; | |
} | |
point = point.matrixTransform(container.getScreenCTM().inverse()); | |
return [ point.x, point.y ]; | |
} | |
var rect = container.getBoundingClientRect(); | |
return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; | |
} | |
function d3_noop() {} | |
function d3_scaleExtent(domain) { | |
var start = domain[0], stop = domain[domain.length - 1]; | |
return start < stop ? [ start, stop ] : [ stop, start ]; | |
} | |
function d3_scaleRange(scale) { | |
return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); | |
} | |
function d3_scale_nice(domain, nice) { | |
var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; | |
if (x1 < x0) { | |
dx = i0, i0 = i1, i1 = dx; | |
dx = x0, x0 = x1, x1 = dx; | |
} | |
if (nice = nice(x1 - x0)) { | |
domain[i0] = nice.floor(x0); | |
domain[i1] = nice.ceil(x1); | |
} | |
return domain; | |
} | |
function d3_scale_niceDefault() { | |
return Math; | |
} | |
function d3_scale_linear(domain, range, interpolate, clamp) { | |
function rescale() { | |
var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; | |
output = linear(domain, range, uninterpolate, interpolate); | |
input = linear(range, domain, uninterpolate, d3.interpolate); | |
return scale; | |
} | |
function scale(x) { | |
return output(x); | |
} | |
var output, input; | |
scale.invert = function(y) { | |
return input(y); | |
}; | |
scale.domain = function(x) { | |
if (!arguments.length) return domain; | |
domain = x.map(Number); | |
return rescale(); | |
}; | |
scale.range = function(x) { | |
if (!arguments.length) return range; | |
range = x; | |
return rescale(); | |
}; | |
scale.rangeRound = function(x) { | |
return scale.range(x).interpolate(d3.interpolateRound); | |
}; | |
scale.clamp = function(x) { | |
if (!arguments.length) return clamp; | |
clamp = x; | |
return rescale(); | |
}; | |
scale.interpolate = function(x) { | |
if (!arguments.length) return interpolate; | |
interpolate = x; | |
return rescale(); | |
}; | |
scale.ticks = function(m) { | |
return d3_scale_linearTicks(domain, m); | |
}; | |
scale.tickFormat = function(m) { | |
return d3_scale_linearTickFormat(domain, m); | |
}; | |
scale.nice = function() { | |
d3_scale_nice(domain, d3_scale_linearNice); | |
return rescale(); | |
}; | |
scale.copy = function() { | |
return d3_scale_linear(domain, range, interpolate, clamp); | |
}; | |
return rescale(); | |
} | |
function d3_scale_linearRebind(scale, linear) { | |
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); | |
} | |
function d3_scale_linearNice(dx) { | |
dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1); | |
return dx && { | |
floor: function(x) { | |
return Math.floor(x / dx) * dx; | |
}, | |
ceil: function(x) { | |
return Math.ceil(x / dx) * dx; | |
} | |
}; | |
} | |
function d3_scale_linearTickRange(domain, m) { | |
var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; | |
if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; | |
extent[0] = Math.ceil(extent[0] / step) * step; | |
extent[1] = Math.floor(extent[1] / step) * step + step * .5; | |
extent[2] = step; | |
return extent; | |
} | |
function d3_scale_linearTicks(domain, m) { | |
return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); | |
} | |
function d3_scale_linearTickFormat(domain, m) { | |
return d3.format(",." + Math.max(0, -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01)) + "f"); | |
} | |
function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { | |
var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); | |
return function(x) { | |
return i(u(x)); | |
}; | |
} | |
function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { | |
var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; | |
if (domain[k] < domain[0]) { | |
domain = domain.slice().reverse(); | |
range = range.slice().reverse(); | |
} | |
while (++j <= k) { | |
u.push(uninterpolate(domain[j - 1], domain[j])); | |
i.push(interpolate(range[j - 1], range[j])); | |
} | |
return function(x) { | |
var j = d3.bisect(domain, x, 1, k) - 1; | |
return i[j](u[j](x)); | |
}; | |
} | |
function d3_scale_log(linear, log) { | |
function scale(x) { | |
return linear(log(x)); | |
} | |
var pow = log.pow; | |
scale.invert = function(x) { | |
return pow(linear.invert(x)); | |
}; | |
scale.domain = function(x) { | |
if (!arguments.length) return linear.domain().map(pow); | |
log = x[0] < 0 ? d3_scale_logn : d3_scale_logp; | |
pow = log.pow; | |
linear.domain(x.map(log)); | |
return scale; | |
}; | |
scale.nice = function() { | |
linear.domain(d3_scale_nice(linear.domain(), d3_scale_niceDefault)); | |
return scale; | |
}; | |
scale.ticks = function() { | |
var extent = d3_scaleExtent(linear.domain()), ticks = []; | |
if (extent.every(isFinite)) { | |
var i = Math.floor(extent[0]), j = Math.ceil(extent[1]), u = pow(extent[0]), v = pow(extent[1]); | |
if (log === d3_scale_logn) { | |
ticks.push(pow(i)); | |
for (; i++ < j; ) for (var k = 9; k > 0; k--) ticks.push(pow(i) * k); | |
} else { | |
for (; i < j; i++) for (var k = 1; k < 10; k++) ticks.push(pow(i) * k); | |
ticks.push(pow(i)); | |
} | |
for (i = 0; ticks[i] < u; i++) {} | |
for (j = ticks.length; ticks[j - 1] > v; j--) {} | |
ticks = ticks.slice(i, j); | |
} | |
return ticks; | |
}; | |
scale.tickFormat = function(n, format) { | |
if (arguments.length < 2) format = d3_scale_logFormat; | |
if (arguments.length < 1) return format; | |
var k = Math.max(.1, n / scale.ticks().length), f = log === d3_scale_logn ? (e = -1e-12, Math.floor) : (e = 1e-12, Math.ceil), e; | |
return function(d) { | |
return d / pow(f(log(d) + e)) <= k ? format(d) : ""; | |
}; | |
}; | |
scale.copy = function() { | |
return d3_scale_log(linear.copy(), log); | |
}; | |
return d3_scale_linearRebind(scale, linear); | |
} | |
function d3_scale_logp(x) { | |
return Math.log(x < 0 ? 0 : x) / Math.LN10; | |
} | |
function d3_scale_logn(x) { | |
return -Math.log(x > 0 ? 0 : -x) / Math.LN10; | |
} | |
function d3_scale_pow(linear, exponent) { | |
function scale(x) { | |
return linear(powp(x)); | |
} | |
var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); | |
scale.invert = function(x) { | |
return powb(linear.invert(x)); | |
}; | |
scale.domain = function(x) { | |
if (!arguments.length) return linear.domain().map(powb); | |
linear.domain(x.map(powp)); | |
return scale; | |
}; | |
scale.ticks = function(m) { | |
return d3_scale_linearTicks(scale.domain(), m); | |
}; | |
scale.tickFormat = function(m) { | |
return d3_scale_linearTickFormat(scale.domain(), m); | |
}; | |
scale.nice = function() { | |
return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice)); | |
}; | |
scale.exponent = function(x) { | |
if (!arguments.length) return exponent; | |
var domain = scale.domain(); | |
powp = d3_scale_powPow(exponent = x); | |
powb = d3_scale_powPow(1 / exponent); | |
return scale.domain(domain); | |
}; | |
scale.copy = function() { | |
return d3_scale_pow(linear.copy(), exponent); | |
}; | |
return d3_scale_linearRebind(scale, linear); | |
} | |
function d3_scale_powPow(e) { | |
return function(x) { | |
return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); | |
}; | |
} | |
function d3_scale_ordinal(domain, ranger) { | |
function scale(x) { | |
return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length]; | |
} | |
function steps(start, step) { | |
return d3.range(domain.length).map(function(i) { | |
return start + step * i; | |
}); | |
} | |
var index, range, rangeBand; | |
scale.domain = function(x) { | |
if (!arguments.length) return domain; | |
domain = []; | |
index = new d3_Map; | |
var i = -1, n = x.length, xi; | |
while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); | |
return scale[ranger.t].apply(scale, ranger.a); | |
}; | |
scale.range = function(x) { | |
if (!arguments.length) return range; | |
range = x; | |
rangeBand = 0; | |
ranger = { | |
t: "range", | |
a: arguments | |
}; | |
return scale; | |
}; | |
scale.rangePoints = function(x, padding) { | |
if (arguments.length < 2) padding = 0; | |
var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); | |
range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); | |
rangeBand = 0; | |
ranger = { | |
t: "rangePoints", | |
a: arguments | |
}; | |
return scale; | |
}; | |
scale.rangeBands = function(x, padding, outerPadding) { | |
if (arguments.length < 2) padding = 0; | |
if (arguments.length < 3) outerPadding = padding; | |
var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); | |
range = steps(start + step * outerPadding, step); | |
if (reverse) range.reverse(); | |
rangeBand = step * (1 - padding); | |
ranger = { | |
t: "rangeBands", | |
a: arguments | |
}; | |
return scale; | |
}; | |
scale.rangeRoundBands = function(x, padding, outerPadding) { | |
if (arguments.length < 2) padding = 0; | |
if (arguments.length < 3) outerPadding = padding; | |
var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), error = stop - start - (domain.length - padding) * step; | |
range = steps(start + Math.round(error / 2), step); | |
if (reverse) range.reverse(); | |
rangeBand = Math.round(step * (1 - padding)); | |
ranger = { | |
t: "rangeRoundBands", | |
a: arguments | |
}; | |
return scale; | |
}; | |
scale.rangeBand = function() { | |
return rangeBand; | |
}; | |
scale.rangeExtent = function() { | |
return d3_scaleExtent(ranger.a[0]); | |
}; | |
scale.copy = function() { | |
return d3_scale_ordinal(domain, ranger); | |
}; | |
return scale.domain(domain); | |
} | |
function d3_scale_quantile(domain, range) { | |
function rescale() { | |
var k = 0, n = domain.length, q = range.length; | |
thresholds = []; | |
while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); | |
return scale; | |
} | |
function scale(x) { | |
if (isNaN(x = +x)) return NaN; | |
return range[d3.bisect(thresholds, x)]; | |
} | |
var thresholds; | |
scale.domain = function(x) { | |
if (!arguments.length) return domain; | |
domain = x.filter(function(d) { | |
return !isNaN(d); | |
}).sort(d3.ascending); | |
return rescale(); | |
}; | |
scale.range = function(x) { | |
if (!arguments.length) return range; | |
range = x; | |
return rescale(); | |
}; | |
scale.quantiles = function() { | |
return thresholds; | |
}; | |
scale.copy = function() { | |
return d3_scale_quantile(domain, range); | |
}; | |
return rescale(); | |
} | |
function d3_scale_quantize(x0, x1, range) { | |
function scale(x) { | |
return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; | |
} | |
function rescale() { | |
kx = range.length / (x1 - x0); | |
i = range.length - 1; | |
return scale; | |
} | |
var kx, i; | |
scale.domain = function(x) { | |
if (!arguments.length) return [ x0, x1 ]; | |
x0 = +x[0]; | |
x1 = +x[x.length - 1]; | |
return rescale(); | |
}; | |
scale.range = function(x) { | |
if (!arguments.length) return range; | |
range = x; | |
return rescale(); | |
}; | |
scale.copy = function() { | |
return d3_scale_quantize(x0, x1, range); | |
}; | |
return rescale(); | |
} | |
function d3_scale_threshold(domain, range) { | |
function scale(x) { | |
return range[d3.bisect(domain, x)]; | |
} | |
scale.domain = function(_) { | |
if (!arguments.length) return domain; | |
domain = _; | |
return scale; | |
}; | |
scale.range = function(_) { | |
if (!arguments.length) return range; | |
range = _; | |
return scale; | |
}; | |
scale.copy = function() { | |
return d3_scale_threshold(domain, range); | |
}; | |
return scale; | |
} | |
function d3_scale_identity(domain) { | |
function identity(x) { | |
return +x; | |
} | |
identity.invert = identity; | |
identity.domain = identity.range = function(x) { | |
if (!arguments.length) return domain; | |
domain = x.map(identity); | |
return identity; | |
}; | |
identity.ticks = function(m) { | |
return d3_scale_linearTicks(domain, m); | |
}; | |
identity.tickFormat = function(m) { | |
return d3_scale_linearTickFormat(domain, m); | |
}; | |
identity.copy = function() { | |
return d3_scale_identity(domain); | |
}; | |
return identity; | |
} | |
function d3_svg_arcInnerRadius(d) { | |
return d.innerRadius; | |
} | |
function d3_svg_arcOuterRadius(d) { | |
return d.outerRadius; | |
} | |
function d3_svg_arcStartAngle(d) { | |
return d.startAngle; | |
} | |
function d3_svg_arcEndAngle(d) { | |
return d.endAngle; | |
} | |
function d3_svg_line(projection) { | |
function line(data) { | |
function segment() { | |
segments.push("M", interpolate(projection(points), tension)); | |
} | |
var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); | |
while (++i < n) { | |
if (defined.call(this, d = data[i], i)) { | |
points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); | |
} else if (points.length) { | |
segment(); | |
points = []; | |
} | |
} | |
if (points.length) segment(); | |
return segments.length ? segments.join("") : null; | |
} | |
var x = d3_svg_lineX, y = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; | |
line.x = function(_) { | |
if (!arguments.length) return x; | |
x = _; | |
return line; | |
}; | |
line.y = function(_) { | |
if (!arguments.length) return y; | |
y = _; | |
return line; | |
}; | |
line.defined = function(_) { | |
if (!arguments.length) return defined; | |
defined = _; | |
return line; | |
}; | |
line.interpolate = function(_) { | |
if (!arguments.length) return interpolateKey; | |
if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; | |
return line; | |
}; | |
line.tension = function(_) { | |
if (!arguments.length) return tension; | |
tension = _; | |
return line; | |
}; | |
return line; | |
} | |
function d3_svg_lineX(d) { | |
return d[0]; | |
} | |
function d3_svg_lineY(d) { | |
return d[1]; | |
} | |
function d3_svg_lineLinear(points) { | |
return points.join("L"); | |
} | |
function d3_svg_lineLinearClosed(points) { | |
return d3_svg_lineLinear(points) + "Z"; | |
} | |
function d3_svg_lineStepBefore(points) { | |
var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; | |
while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); | |
return path.join(""); | |
} | |
function d3_svg_lineStepAfter(points) { | |
var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; | |
while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); | |
return path.join(""); | |
} | |
function d3_svg_lineCardinalOpen(points, tension) { | |
return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension)); | |
} | |
function d3_svg_lineCardinalClosed(points, tension) { | |
return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); | |
} | |
function d3_svg_lineCardinal(points, tension, closed) { | |
return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); | |
} | |
function d3_svg_lineHermite(points, tangents) { | |
if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { | |
return d3_svg_lineLinear(points); | |
} | |
var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; | |
if (quad) { | |
path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; | |
p0 = points[1]; | |
pi = 2; | |
} | |
if (tangents.length > 1) { | |
t = tangents[1]; | |
p = points[pi]; | |
pi++; | |
path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; | |
for (var i = 2; i < tangents.length; i++, pi++) { | |
p = points[pi]; | |
t = tangents[i]; | |
path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; | |
} | |
} | |
if (quad) { | |
var lp = points[pi]; | |
path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; | |
} | |
return path; | |
} | |
function d3_svg_lineCardinalTangents(points, tension) { | |
var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; | |
while (++i < n) { | |
p0 = p1; | |
p1 = p2; | |
p2 = points[i]; | |
tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); | |
} | |
return tangents; | |
} | |
function d3_svg_lineBasis(points) { | |
if (points.length < 3) return d3_svg_lineLinear(points); | |
var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0 ]; | |
d3_svg_lineBasisBezier(path, px, py); | |
while (++i < n) { | |
pi = points[i]; | |
px.shift(); | |
px.push(pi[0]); | |
py.shift(); | |
py.push(pi[1]); | |
d3_svg_lineBasisBezier(path, px, py); | |
} | |
i = -1; | |
while (++i < 2) { | |
px.shift(); | |
px.push(pi[0]); | |
py.shift(); | |
py.push(pi[1]); | |
d3_svg_lineBasisBezier(path, px, py); | |
} | |
return path.join(""); | |
} | |
function d3_svg_lineBasisOpen(points) { | |
if (points.length < 4) return d3_svg_lineLinear(points); | |
var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; | |
while (++i < 3) { | |
pi = points[i]; | |
px.push(pi[0]); | |
py.push(pi[1]); | |
} | |
path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); | |
--i; | |
while (++i < n) { | |
pi = points[i]; | |
px.shift(); | |
px.push(pi[0]); | |
py.shift(); | |
py.push(pi[1]); | |
d3_svg_lineBasisBezier(path, px, py); | |
} | |
return path.join(""); | |
} | |
function d3_svg_lineBasisClosed(points) { | |
var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; | |
while (++i < 4) { | |
pi = points[i % n]; | |
px.push(pi[0]); | |
py.push(pi[1]); | |
} | |
path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; | |
--i; | |
while (++i < m) { | |
pi = points[i % n]; | |
px.shift(); | |
px.push(pi[0]); | |
py.shift(); | |
py.push(pi[1]); | |
d3_svg_lineBasisBezier(path, px, py); | |
} | |
return path.join(""); | |
} | |
function d3_svg_lineBundle(points, tension) { | |
var n = points.length - 1; | |
if (n) { | |
var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; | |
while (++i <= n) { | |
p = points[i]; | |
t = i / n; | |
p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); | |
p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); | |
} | |
} | |
return d3_svg_lineBasis(points); | |
} | |
function d3_svg_lineDot4(a, b) { | |
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; | |
} | |
function d3_svg_lineBasisBezier(path, x, y) { | |
path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); | |
} | |
function d3_svg_lineSlope(p0, p1) { | |
return (p1[1] - p0[1]) / (p1[0] - p0[0]); | |
} | |
function d3_svg_lineFiniteDifferences(points) { | |
var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); | |
while (++i < j) { | |
m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; | |
} | |
m[i] = d; | |
return m; | |
} | |
function d3_svg_lineMonotoneTangents(points) { | |
var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; | |
while (++i < j) { | |
d = d3_svg_lineSlope(points[i], points[i + 1]); | |
if (Math.abs(d) < 1e-6) { | |
m[i] = m[i + 1] = 0; | |
} else { | |
a = m[i] / d; | |
b = m[i + 1] / d; | |
s = a * a + b * b; | |
if (s > 9) { | |
s = d * 3 / Math.sqrt(s); | |
m[i] = s * a; | |
m[i + 1] = s * b; | |
} | |
} | |
} | |
i = -1; | |
while (++i <= j) { | |
s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); | |
tangents.push([ s || 0, m[i] * s || 0 ]); | |
} | |
return tangents; | |
} | |
function d3_svg_lineMonotone(points) { | |
return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); | |
} | |
function d3_svg_lineRadial(points) { | |
var point, i = -1, n = points.length, r, a; | |
while (++i < n) { | |
point = points[i]; | |
r = point[0]; | |
a = point[1] + d3_svg_arcOffset; | |
point[0] = r * Math.cos(a); | |
point[1] = r * Math.sin(a); | |
} | |
return points; | |
} | |
function d3_svg_area(projection) { | |
function area(data) { | |
function segment() { | |
segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); | |
} | |
var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { | |
return x; | |
} : d3_functor(x1), fy1 = y0 === y1 ? function() { | |
return y; | |
} : d3_functor(y1), x, y; | |
while (++i < n) { | |
if (defined.call(this, d = data[i], i)) { | |
points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); | |
points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); | |
} else if (points0.length) { | |
segment(); | |
points0 = []; | |
points1 = []; | |
} | |
} | |
if (points0.length) segment(); | |
return segments.length ? segments.join("") : null; | |
} | |
var x0 = d3_svg_lineX, x1 = d3_svg_lineX, y0 = 0, y1 = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; | |
area.x = function(_) { | |
if (!arguments.length) return x1; | |
x0 = x1 = _; | |
return area; | |
}; | |
area.x0 = function(_) { | |
if (!arguments.length) return x0; | |
x0 = _; | |
return area; | |
}; | |
area.x1 = function(_) { | |
if (!arguments.length) return x1; | |
x1 = _; | |
return area; | |
}; | |
area.y = function(_) { | |
if (!arguments.length) return y1; | |
y0 = y1 = _; | |
return area; | |
}; | |
area.y0 = function(_) { | |
if (!arguments.length) return y0; | |
y0 = _; | |
return area; | |
}; | |
area.y1 = function(_) { | |
if (!arguments.length) return y1; | |
y1 = _; | |
return area; | |
}; | |
area.defined = function(_) { | |
if (!arguments.length) return defined; | |
defined = _; | |
return area; | |
}; | |
area.interpolate = function(_) { | |
if (!arguments.length) return interpolateKey; | |
if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; | |
interpolateReverse = interpolate.reverse || interpolate; | |
L = interpolate.closed ? "M" : "L"; | |
return area; | |
}; | |
area.tension = function(_) { | |
if (!arguments.length) return tension; | |
tension = _; | |
return area; | |
}; | |
return area; | |
} | |
function d3_svg_chordSource(d) { | |
return d.source; | |
} | |
function d3_svg_chordTarget(d) { | |
return d.target; | |
} | |
function d3_svg_chordRadius(d) { | |
return d.radius; | |
} | |
function d3_svg_chordStartAngle(d) { | |
return d.startAngle; | |
} | |
function d3_svg_chordEndAngle(d) { | |
return d.endAngle; | |
} | |
function d3_svg_diagonalProjection(d) { | |
return [ d.x, d.y ]; | |
} | |
function d3_svg_diagonalRadialProjection(projection) { | |
return function() { | |
var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset; | |
return [ r * Math.cos(a), r * Math.sin(a) ]; | |
}; | |
} | |
function d3_svg_symbolSize() { | |
return 64; | |
} | |
function d3_svg_symbolType() { | |
return "circle"; | |
} | |
function d3_svg_symbolCircle(size) { | |
var r = Math.sqrt(size / Math.PI); | |
return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; | |
} | |
function d3_svg_axisX(selection, x) { | |
selection.attr("transform", function(d) { | |
return "translate(" + x(d) + ",0)"; | |
}); | |
} | |
function d3_svg_axisY(selection, y) { | |
selection.attr("transform", function(d) { | |
return "translate(0," + y(d) + ")"; | |
}); | |
} | |
function d3_svg_axisSubdivide(scale, ticks, m) { | |
subticks = []; | |
if (m && ticks.length > 1) { | |
var extent = d3_scaleExtent(scale.domain()), subticks, i = -1, n = ticks.length, d = (ticks[1] - ticks[0]) / ++m, j, v; | |
while (++i < n) { | |
for (j = m; --j > 0; ) { | |
if ((v = +ticks[i] - j * d) >= extent[0]) { | |
subticks.push(v); | |
} | |
} | |
} | |
for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1]; ) { | |
subticks.push(v); | |
} | |
} | |
return subticks; | |
} | |
function d3_behavior_zoomDelta() { | |
if (!d3_behavior_zoomDiv) { | |
d3_behavior_zoomDiv = d3.select("body").append("div").style("visibility", "hidden").style("top", 0).style("height", 0).style("width", 0).style("overflow-y", "scroll").append("div").style("height", "2000px").node().parentNode; | |
} | |
var e = d3.event, delta; | |
try { | |
d3_behavior_zoomDiv.scrollTop = 1e3; | |
d3_behavior_zoomDiv.dispatchEvent(e); | |
delta = 1e3 - d3_behavior_zoomDiv.scrollTop; | |
} catch (error) { | |
delta = e.wheelDelta || -e.detail * 5; | |
} | |
return delta; | |
} | |
function d3_layout_bundlePath(link) { | |
var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; | |
while (start !== lca) { | |
start = start.parent; | |
points.push(start); | |
} | |
var k = points.length; | |
while (end !== lca) { | |
points.splice(k, 0, end); | |
end = end.parent; | |
} | |
return points; | |
} | |
function d3_layout_bundleAncestors(node) { | |
var ancestors = [], parent = node.parent; | |
while (parent != null) { | |
ancestors.push(node); | |
node = parent; | |
parent = parent.parent; | |
} | |
ancestors.push(node); | |
return ancestors; | |
} | |
function d3_layout_bundleLeastCommonAncestor(a, b) { | |
if (a === b) return a; | |
var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; | |
while (aNode === bNode) { | |
sharedNode = aNode; | |
aNode = aNodes.pop(); | |
bNode = bNodes.pop(); | |
} | |
return sharedNode; | |
} | |
function d3_layout_forceDragstart(d) { | |
d.fixed |= 2; | |
} | |
function d3_layout_forceDragend(d) { | |
d.fixed &= 1; | |
} | |
function d3_layout_forceMouseover(d) { | |
d.fixed |= 4; | |
} | |
function d3_layout_forceMouseout(d) { | |
d.fixed &= 3; | |
} | |
function d3_layout_forceAccumulate(quad, alpha, charges) { | |
var cx = 0, cy = 0; | |
quad.charge = 0; | |
if (!quad.leaf) { | |
var nodes = quad.nodes, n = nodes.length, i = -1, c; | |
while (++i < n) { | |
c = nodes[i]; | |
if (c == null) continue; | |
d3_layout_forceAccumulate(c, alpha, charges); | |
quad.charge += c.charge; | |
cx += c.charge * c.cx; | |
cy += c.charge * c.cy; | |
} | |
} | |
if (quad.point) { | |
if (!quad.leaf) { | |
quad.point.x += Math.random() - .5; | |
quad.point.y += Math.random() - .5; | |
} | |
var k = alpha * charges[quad.point.index]; | |
quad.charge += quad.pointCharge = k; | |
cx += k * quad.point.x; | |
cy += k * quad.point.y; | |
} | |
quad.cx = cx / quad.charge; | |
quad.cy = cy / quad.charge; | |
} | |
function d3_layout_forceLinkDistance(link) { | |
return 20; | |
} | |
function d3_layout_forceLinkStrength(link) { | |
return 1; | |
} | |
function d3_layout_stackX(d) { | |
return d.x; | |
} | |
function d3_layout_stackY(d) { | |
return d.y; | |
} | |
function d3_layout_stackOut(d, y0, y) { | |
d.y0 = y0; | |
d.y = y; | |
} | |
function d3_layout_stackOrderDefault(data) { | |
return d3.range(data.length); | |
} | |
function d3_layout_stackOffsetZero(data) { | |
var j = -1, m = data[0].length, y0 = []; | |
while (++j < m) y0[j] = 0; | |
return y0; | |
} | |
function d3_layout_stackMaxIndex(array) { | |
var i = 1, j = 0, v = array[0][1], k, n = array.length; | |
for (; i < n; ++i) { | |
if ((k = array[i][1]) > v) { | |
j = i; | |
v = k; | |
} | |
} | |
return j; | |
} | |
function d3_layout_stackReduceSum(d) { | |
return d.reduce(d3_layout_stackSum, 0); | |
} | |
function d3_layout_stackSum(p, d) { | |
return p + d[1]; | |
} | |
function d3_layout_histogramBinSturges(range, values) { | |
return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); | |
} | |
function d3_layout_histogramBinFixed(range, n) { | |
var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; | |
while (++x <= n) f[x] = m * x + b; | |
return f; | |
} | |
function d3_layout_histogramRange(values) { | |
return [ d3.min(values), d3.max(values) ]; | |
} | |
function d3_layout_hierarchyRebind(object, hierarchy) { | |
d3.rebind(object, hierarchy, "sort", "children", "value"); | |
object.links = d3_layout_hierarchyLinks; | |
object.nodes = function(d) { | |
d3_layout_hierarchyInline = true; | |
return (object.nodes = object)(d); | |
}; | |
return object; | |
} | |
function d3_layout_hierarchyChildren(d) { | |
return d.children; | |
} | |
function d3_layout_hierarchyValue(d) { | |
return d.value; | |
} | |
function d3_layout_hierarchySort(a, b) { | |
return b.value - a.value; | |
} | |
function d3_layout_hierarchyLinks(nodes) { | |
return d3.merge(nodes.map(function(parent) { | |
return (parent.children || []).map(function(child) { | |
return { | |
source: parent, | |
target: child | |
}; | |
}); | |
})); | |
} | |
function d3_layout_packSort(a, b) { | |
return a.value - b.value; | |
} | |
function d3_layout_packInsert(a, b) { | |
var c = a._pack_next; | |
a._pack_next = b; | |
b._pack_prev = a; | |
b._pack_next = c; | |
c._pack_prev = b; | |
} | |
function d3_layout_packSplice(a, b) { | |
a._pack_next = b; | |
b._pack_prev = a; | |
} | |
function d3_layout_packIntersects(a, b) { | |
var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; | |
return dr * dr - dx * dx - dy * dy > .001; | |
} | |
function d3_layout_packSiblings(node) { | |
function bound(node) { | |
xMin = Math.min(node.x - node.r, xMin); | |
xMax = Math.max(node.x + node.r, xMax); | |
yMin = Math.min(node.y - node.r, yMin); | |
yMax = Math.max(node.y + node.r, yMax); | |
} | |
if (!(nodes = node.children) || !(n = nodes.length)) return; | |
var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; | |
nodes.forEach(d3_layout_packLink); | |
a = nodes[0]; | |
a.x = -a.r; | |
a.y = 0; | |
bound(a); | |
if (n > 1) { | |
b = nodes[1]; | |
b.x = b.r; | |
b.y = 0; | |
bound(b); | |
if (n > 2) { | |
c = nodes[2]; | |
d3_layout_packPlace(a, b, c); | |
bound(c); | |
d3_layout_packInsert(a, c); | |
a._pack_prev = c; | |
d3_layout_packInsert(c, b); | |
b = a._pack_next; | |
for (i = 3; i < n; i++) { | |
d3_layout_packPlace(a, b, c = nodes[i]); | |
var isect = 0, s1 = 1, s2 = 1; | |
for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { | |
if (d3_layout_packIntersects(j, c)) { | |
isect = 1; | |
break; | |
} | |
} | |
if (isect == 1) { | |
for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { | |
if (d3_layout_packIntersects(k, c)) { | |
break; | |
} | |
} | |
} | |
if (isect) { | |
if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); | |
i--; | |
} else { | |
d3_layout_packInsert(a, c); | |
b = c; | |
bound(c); | |
} | |
} | |
} | |
} | |
var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; | |
for (i = 0; i < n; i++) { | |
c = nodes[i]; | |
c.x -= cx; | |
c.y -= cy; | |
cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); | |
} | |
node.r = cr; | |
nodes.forEach(d3_layout_packUnlink); | |
} | |
function d3_layout_packLink(node) { | |
node._pack_next = node._pack_prev = node; | |
} | |
function d3_layout_packUnlink(node) { | |
delete node._pack_next; | |
delete node._pack_prev; | |
} | |
function d3_layout_packTransform(node, x, y, k) { | |
var children = node.children; | |
node.x = x += k * node.x; | |
node.y = y += k * node.y; | |
node.r *= k; | |
if (children) { | |
var i = -1, n = children.length; | |
while (++i < n) d3_layout_packTransform(children[i], x, y, k); | |
} | |
} | |
function d3_layout_packPlace(a, b, c) { | |
var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; | |
if (db && (dx || dy)) { | |
var da = b.r + c.r, dc = dx * dx + dy * dy; | |
da *= da; | |
db *= db; | |
var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); | |
c.x = a.x + x * dx + y * dy; | |
c.y = a.y + x * dy - y * dx; | |
} else { | |
c.x = a.x + db; | |
c.y = a.y; | |
} | |
} | |
function d3_layout_clusterY(children) { | |
return 1 + d3.max(children, function(child) { | |
return child.y; | |
}); | |
} | |
function d3_layout_clusterX(children) { | |
return children.reduce(function(x, child) { | |
return x + child.x; | |
}, 0) / children.length; | |
} | |
function d3_layout_clusterLeft(node) { | |
var children = node.children; | |
return children && children.length ? d3_layout_clusterLeft(children[0]) : node; | |
} | |
function d3_layout_clusterRight(node) { | |
var children = node.children, n; | |
return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; | |
} | |
function d3_layout_treeSeparation(a, b) { | |
return a.parent == b.parent ? 1 : 2; | |
} | |
function d3_layout_treeLeft(node) { | |
var children = node.children; | |
return children && children.length ? children[0] : node._tree.thread; | |
} | |
function d3_layout_treeRight(node) { | |
var children = node.children, n; | |
return children && (n = children.length) ? children[n - 1] : node._tree.thread; | |
} | |
function d3_layout_treeSearch(node, compare) { | |
var children = node.children; | |
if (children && (n = children.length)) { | |
var child, n, i = -1; | |
while (++i < n) { | |
if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) { | |
node = child; | |
} | |
} | |
} | |
return node; | |
} | |
function d3_layout_treeRightmost(a, b) { | |
return a.x - b.x; | |
} | |
function d3_layout_treeLeftmost(a, b) { | |
return b.x - a.x; | |
} | |
function d3_layout_treeDeepest(a, b) { | |
return a.depth - b.depth; | |
} | |
function d3_layout_treeVisitAfter(node, callback) { | |
function visit(node, previousSibling) { | |
var children = node.children; | |
if (children && (n = children.length)) { | |
var child, previousChild = null, i = -1, n; | |
while (++i < n) { | |
child = children[i]; | |
visit(child, previousChild); | |
previousChild = child; | |
} | |
} | |
callback(node, previousSibling); | |
} | |
visit(node, null); | |
} | |
function d3_layout_treeShift(node) { | |
var shift = 0, change = 0, children = node.children, i = children.length, child; | |
while (--i >= 0) { | |
child = children[i]._tree; | |
child.prelim += shift; | |
child.mod += shift; | |
shift += child.shift + (change += child.change); | |
} | |
} | |
function d3_layout_treeMove(ancestor, node, shift) { | |
ancestor = ancestor._tree; | |
node = node._tree; | |
var change = shift / (node.number - ancestor.number); | |
ancestor.change += change; | |
node.change -= change; | |
node.shift += shift; | |
node.prelim += shift; | |
node.mod += shift; | |
} | |
function d3_layout_treeAncestor(vim, node, ancestor) { | |
return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor; | |
} | |
function d3_layout_treemapPadNull(node) { | |
return { | |
x: node.x, | |
y: node.y, | |
dx: node.dx, | |
dy: node.dy | |
}; | |
} | |
function d3_layout_treemapPad(node, padding) { | |
var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; | |
if (dx < 0) { | |
x += dx / 2; | |
dx = 0; | |
} | |
if (dy < 0) { | |
y += dy / 2; | |
dy = 0; | |
} | |
return { | |
x: x, | |
y: y, | |
dx: dx, | |
dy: dy | |
}; | |
} | |
function d3_dsv(delimiter, mimeType) { | |
function dsv(url, callback) { | |
d3.text(url, mimeType, function(text) { | |
callback(text && dsv.parse(text)); | |
}); | |
} | |
function formatRow(row) { | |
return row.map(formatValue).join(delimiter); | |
} | |
function formatValue(text) { | |
return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; | |
} | |
var reParse = new RegExp("\r\n|[" + delimiter + "\r\n]", "g"), reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); | |
dsv.parse = function(text) { | |
var header; | |
return dsv.parseRows(text, function(row, i) { | |
if (i) { | |
var o = {}, j = -1, m = header.length; | |
while (++j < m) o[header[j]] = row[j]; | |
return o; | |
} else { | |
header = row; | |
return null; | |
} | |
}); | |
}; | |
dsv.parseRows = function(text, f) { | |
function token() { | |
if (reParse.lastIndex >= text.length) return EOF; | |
if (eol) { | |
eol = false; | |
return EOL; | |
} | |
var j = reParse.lastIndex; | |
if (text.charCodeAt(j) === 34) { | |
var i = j; | |
while (i++ < text.length) { | |
if (text.charCodeAt(i) === 34) { | |
if (text.charCodeAt(i + 1) !== 34) break; | |
i++; | |
} | |
} | |
reParse.lastIndex = i + 2; | |
var c = text.charCodeAt(i + 1); | |
if (c === 13) { | |
eol = true; | |
if (text.charCodeAt(i + 2) === 10) reParse.lastIndex++; | |
} else if (c === 10) { | |
eol = true; | |
} | |
return text.substring(j + 1, i).replace(/""/g, '"'); | |
} | |
var m = reParse.exec(text); | |
if (m) { | |
eol = m[0].charCodeAt(0) !== delimiterCode; | |
return text.substring(j, m.index); | |
} | |
reParse.lastIndex = text.length; | |
return text.substring(j); | |
} | |
var EOL = {}, EOF = {}, rows = [], n = 0, t, eol; | |
reParse.lastIndex = 0; | |
while ((t = token()) !== EOF) { | |
var a = []; | |
while (t !== EOL && t !== EOF) { | |
a.push(t); | |
t = token(); | |
} | |
if (f && !(a = f(a, n++))) continue; | |
rows.push(a); | |
} | |
return rows; | |
}; | |
dsv.format = function(rows) { | |
return rows.map(formatRow).join("\n"); | |
}; | |
return dsv; | |
} | |
function d3_geo_type(types, defaultValue) { | |
return function(object) { | |
return object && types.hasOwnProperty(object.type) ? types[object.type](object) : defaultValue; | |
}; | |
} | |
function d3_path_circle(radius) { | |
return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + +2 * radius + "z"; | |
} | |
function d3_geo_bounds(o, f) { | |
if (d3_geo_boundsTypes.hasOwnProperty(o.type)) d3_geo_boundsTypes[o.type](o, f); | |
} | |
function d3_geo_boundsFeature(o, f) { | |
d3_geo_bounds(o.geometry, f); | |
} | |
function d3_geo_boundsFeatureCollection(o, f) { | |
for (var a = o.features, i = 0, n = a.length; i < n; i++) { | |
d3_geo_bounds(a[i].geometry, f); | |
} | |
} | |
function d3_geo_boundsGeometryCollection(o, f) { | |
for (var a = o.geometries, i = 0, n = a.length; i < n; i++) { | |
d3_geo_bounds(a[i], f); | |
} | |
} | |
function d3_geo_boundsLineString(o, f) { | |
for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { | |
f.apply(null, a[i]); | |
} | |
} | |
function d3_geo_boundsMultiLineString(o, f) { | |
for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { | |
for (var b = a[i], j = 0, m = b.length; j < m; j++) { | |
f.apply(null, b[j]); | |
} | |
} | |
} | |
function d3_geo_boundsMultiPolygon(o, f) { | |
for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { | |
for (var b = a[i][0], j = 0, m = b.length; j < m; j++) { | |
f.apply(null, b[j]); | |
} | |
} | |
} | |
function d3_geo_boundsPoint(o, f) { | |
f.apply(null, o.coordinates); | |
} | |
function d3_geo_boundsPolygon(o, f) { | |
for (var a = o.coordinates[0], i = 0, n = a.length; i < n; i++) { | |
f.apply(null, a[i]); | |
} | |
} | |
function d3_geo_greatArcSource(d) { | |
return d.source; | |
} | |
function d3_geo_greatArcTarget(d) { | |
return d.target; | |
} | |
function d3_geo_greatArcInterpolator() { | |
function interpolate(t) { | |
var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; | |
return [ Math.atan2(y, x) / d3_geo_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians ]; | |
} | |
var x0, y0, cy0, sy0, kx0, ky0, x1, y1, cy1, sy1, kx1, ky1, d, k; | |
interpolate.distance = function() { | |
if (d == null) k = 1 / Math.sin(d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0))))); | |
return d; | |
}; | |
interpolate.source = function(_) { | |
var cx0 = Math.cos(x0 = _[0] * d3_geo_radians), sx0 = Math.sin(x0); | |
cy0 = Math.cos(y0 = _[1] * d3_geo_radians); | |
sy0 = Math.sin(y0); | |
kx0 = cy0 * cx0; | |
ky0 = cy0 * sx0; | |
d = null; | |
return interpolate; | |
}; | |
interpolate.target = function(_) { | |
var cx1 = Math.cos(x1 = _[0] * d3_geo_radians), sx1 = Math.sin(x1); | |
cy1 = Math.cos(y1 = _[1] * d3_geo_radians); | |
sy1 = Math.sin(y1); | |
kx1 = cy1 * cx1; | |
ky1 = cy1 * sx1; | |
d = null; | |
return interpolate; | |
}; | |
return interpolate; | |
} | |
function d3_geo_greatArcInterpolate(a, b) { | |
var i = d3_geo_greatArcInterpolator().source(a).target(b); | |
i.distance(); | |
return i; | |
} | |
function d3_geom_contourStart(grid) { | |
var x = 0, y = 0; | |
while (true) { | |
if (grid(x, y)) { | |
return [ x, y ]; | |
} | |
if (x === 0) { | |
x = y + 1; | |
y = 0; | |
} else { | |
x = x - 1; | |
y = y + 1; | |
} | |
} | |
} | |
function d3_geom_hullCCW(i1, i2, i3, v) { | |
var t, a, b, c, d, e, f; | |
t = v[i1]; | |
a = t[0]; | |
b = t[1]; | |
t = v[i2]; | |
c = t[0]; | |
d = t[1]; | |
t = v[i3]; | |
e = t[0]; | |
f = t[1]; | |
return (f - b) * (c - a) - (d - b) * (e - a) > 0; | |
} | |
function d3_geom_polygonInside(p, a, b) { | |
return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); | |
} | |
function d3_geom_polygonIntersect(c, d, a, b) { | |
var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0], y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1], x13 = x1 - x3, x21 = x2 - x1, x43 = x4 - x3, y13 = y1 - y3, y21 = y2 - y1, y43 = y4 - y3, ua = (x43 * y13 - y43 * x13) / (y43 * x21 - x43 * y21); | |
return [ x1 + ua * x21, y1 + ua * y21 ]; | |
} | |
function d3_voronoi_tessellate(vertices, callback) { | |
var Sites = { | |
list: vertices.map(function(v, i) { | |
return { | |
index: i, | |
x: v[0], | |
y: v[1] | |
}; | |
}).sort(function(a, b) { | |
return a.y < b.y ? -1 : a.y > b.y ? 1 : a.x < b.x ? -1 : a.x > b.x ? 1 : 0; | |
}), | |
bottomSite: null | |
}; | |
var EdgeList = { | |
list: [], | |
leftEnd: null, | |
rightEnd: null, | |
init: function() { | |
EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l"); | |
EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l"); | |
EdgeList.leftEnd.r = EdgeList.rightEnd; | |
EdgeList.rightEnd.l = EdgeList.leftEnd; | |
EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd); | |
}, | |
createHalfEdge: function(edge, side) { | |
return { | |
edge: edge, | |
side: side, | |
vertex: null, | |
l: null, | |
r: null | |
}; | |
}, | |
insert: function(lb, he) { | |
he.l = lb; | |
he.r = lb.r; | |
lb.r.l = he; | |
lb.r = he; | |
}, | |
leftBound: function(p) { | |
var he = EdgeList.leftEnd; | |
do { | |
he = he.r; | |
} while (he != EdgeList.rightEnd && Geom.rightOf(he, p)); | |
he = he.l; | |
return he; | |
}, | |
del: function(he) { | |
he.l.r = he.r; | |
he.r.l = he.l; | |
he.edge = null; | |
}, | |
right: function(he) { | |
return he.r; | |
}, | |
left: function(he) { | |
return he.l; | |
}, | |
leftRegion: function(he) { | |
return he.edge == null ? Sites.bottomSite : he.edge.region[he.side]; | |
}, | |
rightRegion: function(he) { | |
return he.edge == null ? Sites.bottomSite : he.edge.region[d3_voronoi_opposite[he.side]]; | |
} | |
}; | |
var Geom = { | |
bisect: function(s1, s2) { | |
var newEdge = { | |
region: { | |
l: s1, | |
r: s2 | |
}, | |
ep: { | |
l: null, | |
r: null | |
} | |
}; | |
var dx = s2.x - s1.x, dy = s2.y - s1.y, adx = dx > 0 ? dx : -dx, ady = dy > 0 ? dy : -dy; | |
newEdge.c = s1.x * dx + s1.y * dy + (dx * dx + dy * dy) * .5; | |
if (adx > ady) { | |
newEdge.a = 1; | |
newEdge.b = dy / dx; | |
newEdge.c /= dx; | |
} else { | |
newEdge.b = 1; | |
newEdge.a = dx / dy; | |
newEdge.c /= dy; | |
} | |
return newEdge; | |
}, | |
intersect: function(el1, el2) { | |
var e1 = el1.edge, e2 = el2.edge; | |
if (!e1 || !e2 || e1.region.r == e2.region.r) { | |
return null; | |
} | |
var d = e1.a * e2.b - e1.b * e2.a; | |
if (Math.abs(d) < 1e-10) { | |
return null; | |
} | |
var xint = (e1.c * e2.b - e2.c * e1.b) / d, yint = (e2.c * e1.a - e1.c * e2.a) / d, e1r = e1.region.r, e2r = e2.region.r, el, e; | |
if (e1r.y < e2r.y || e1r.y == e2r.y && e1r.x < e2r.x) { | |
el = el1; | |
e = e1; | |
} else { | |
el = el2; | |
e = e2; | |
} | |
var rightOfSite = xint >= e.region.r.x; | |
if (rightOfSite && el.side === "l" || !rightOfSite && el.side === "r") { | |
return null; | |
} | |
return { | |
x: xint, | |
y: yint | |
}; | |
}, | |
rightOf: function(he, p) { | |
var e = he.edge, topsite = e.region.r, rightOfSite = p.x > topsite.x; | |
if (rightOfSite && he.side === "l") { | |
return 1; | |
} | |
if (!rightOfSite && he.side === "r") { | |
return 0; | |
} | |
if (e.a === 1) { | |
var dyp = p.y - topsite.y, dxp = p.x - topsite.x, fast = 0, above = 0; | |
if (!rightOfSite && e.b < 0 || rightOfSite && e.b >= 0) { | |
above = fast = dyp >= e.b * dxp; | |
} else { | |
above = p.x + p.y * e.b > e.c; | |
if (e.b < 0) { | |
above = !above; | |
} | |
if (!above) { | |
fast = 1; | |
} | |
} | |
if (!fast) { | |
var dxs = topsite.x - e.region.l.x; | |
above = e.b * (dxp * dxp - dyp * dyp) < dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b); | |
if (e.b < 0) { | |
above = !above; | |
} | |
} | |
} else { | |
var yl = e.c - e.a * p.x, t1 = p.y - yl, t2 = p.x - topsite.x, t3 = yl - topsite.y; | |
above = t1 * t1 > t2 * t2 + t3 * t3; | |
} | |
return he.side === "l" ? above : !above; | |
}, | |
endPoint: function(edge, side, site) { | |
edge.ep[side] = site; | |
if (!edge.ep[d3_voronoi_opposite[side]]) return; | |
callback(edge); | |
}, | |
distance: function(s, t) { | |
var dx = s.x - t.x, dy = s.y - t.y; | |
return Math.sqrt(dx * dx + dy * dy); | |
} | |
}; | |
var EventQueue = { | |
list: [], | |
insert: function(he, site, offset) { | |
he.vertex = site; | |
he.ystar = site.y + offset; | |
for (var i = 0, list = EventQueue.list, l = list.length; i < l; i++) { | |
var next = list[i]; | |
if (he.ystar > next.ystar || he.ystar == next.ystar && site.x > next.vertex.x) { | |
continue; | |
} else { | |
break; | |
} | |
} | |
list.splice(i, 0, he); | |
}, | |
del: function(he) { | |
for (var i = 0, ls = EventQueue.list, l = ls.length; i < l && ls[i] != he; ++i) {} | |
ls.splice(i, 1); | |
}, | |
empty: function() { | |
return EventQueue.list.length === 0; | |
}, | |
nextEvent: function(he) { | |
for (var i = 0, ls = EventQueue.list, l = ls.length; i < l; ++i) { | |
if (ls[i] == he) return ls[i + 1]; | |
} | |
return null; | |
}, | |
min: function() { | |
var elem = EventQueue.list[0]; | |
return { | |
x: elem.vertex.x, | |
y: elem.ystar | |
}; | |
}, | |
extractMin: function() { | |
return EventQueue.list.shift(); | |
} | |
}; | |
EdgeList.init(); | |
Sites.bottomSite = Sites.list.shift(); | |
var newSite = Sites.list.shift(), newIntStar; | |
var lbnd, rbnd, llbnd, rrbnd, bisector; | |
var bot, top, temp, p, v; | |
var e, pm; | |
while (true) { | |
if (!EventQueue.empty()) { | |
newIntStar = EventQueue.min(); | |
} | |
if (newSite && (EventQueue.empty() || newSite.y < newIntStar.y || newSite.y == newIntStar.y && newSite.x < newIntStar.x)) { | |
lbnd = EdgeList.leftBound(newSite); | |
rbnd = EdgeList.right(lbnd); | |
bot = EdgeList.rightRegion(lbnd); | |
e = Geom.bisect(bot, newSite); | |
bisector = EdgeList.createHalfEdge(e, "l"); | |
EdgeList.insert(lbnd, bisector); | |
p = Geom.intersect(lbnd, bisector); | |
if (p) { | |
EventQueue.del(lbnd); | |
EventQueue.insert(lbnd, p, Geom.distance(p, newSite)); | |
} | |
lbnd = bisector; | |
bisector = EdgeList.createHalfEdge(e, "r"); | |
EdgeList.insert(lbnd, bisector); | |
p = Geom.intersect(bisector, rbnd); | |
if (p) { | |
EventQueue.insert(bisector, p, Geom.distance(p, newSite)); | |
} | |
newSite = Sites.list.shift(); | |
} else if (!EventQueue.empty()) { | |
lbnd = EventQueue.extractMin(); | |
llbnd = EdgeList.left(lbnd); | |
rbnd = EdgeList.right(lbnd); | |
rrbnd = EdgeList.right(rbnd); | |
bot = EdgeList.leftRegion(lbnd); | |
top = EdgeList.rightRegion(rbnd); | |
v = lbnd.vertex; | |
Geom.endPoint(lbnd.edge, lbnd.side, v); | |
Geom.endPoint(rbnd.edge, rbnd.side, v); | |
EdgeList.del(lbnd); | |
EventQueue.del(rbnd); | |
EdgeList.del(rbnd); | |
pm = "l"; | |
if (bot.y > top.y) { | |
temp = bot; | |
bot = top; | |
top = temp; | |
pm = "r"; | |
} | |
e = Geom.bisect(bot, top); | |
bisector = EdgeList.createHalfEdge(e, pm); | |
EdgeList.insert(llbnd, bisector); | |
Geom.endPoint(e, d3_voronoi_opposite[pm], v); | |
p = Geom.intersect(llbnd, bisector); | |
if (p) { | |
EventQueue.del(llbnd); | |
EventQueue.insert(llbnd, p, Geom.distance(p, bot)); | |
} | |
p = Geom.intersect(bisector, rrbnd); | |
if (p) { | |
EventQueue.insert(bisector, p, Geom.distance(p, bot)); | |
} | |
} else { | |
break; | |
} | |
} | |
for (lbnd = EdgeList.right(EdgeList.leftEnd); lbnd != EdgeList.rightEnd; lbnd = EdgeList.right(lbnd)) { | |
callback(lbnd.edge); | |
} | |
} | |
function d3_geom_quadtreeNode() { | |
return { | |
leaf: true, | |
nodes: [], | |
point: null | |
}; | |
} | |
function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { | |
if (!f(node, x1, y1, x2, y2)) { | |
var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; | |
if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); | |
if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); | |
if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); | |
if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); | |
} | |
} | |
function d3_geom_quadtreePoint(p) { | |
return { | |
x: p[0], | |
y: p[1] | |
}; | |
} | |
function d3_time_utc() { | |
this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); | |
} | |
function d3_time_formatAbbreviate(name) { | |
return name.substring(0, 3); | |
} | |
function d3_time_parse(date, template, string, j) { | |
var c, p, i = 0, n = template.length, m = string.length; | |
while (i < n) { | |
if (j >= m) return -1; | |
c = template.charCodeAt(i++); | |
if (c == 37) { | |
p = d3_time_parsers[template.charAt(i++)]; | |
if (!p || (j = p(date, string, j)) < 0) return -1; | |
} else if (c != string.charCodeAt(j++)) { | |
return -1; | |
} | |
} | |
return j; | |
} | |
function d3_time_formatRe(names) { | |
return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); | |
} | |
function d3_time_formatLookup(names) { | |
var map = new d3_Map, i = -1, n = names.length; | |
while (++i < n) map.set(names[i].toLowerCase(), i); | |
return map; | |
} | |
function d3_time_parseWeekdayAbbrev(date, string, i) { | |
d3_time_dayAbbrevRe.lastIndex = 0; | |
var n = d3_time_dayAbbrevRe.exec(string.substring(i)); | |
return n ? i += n[0].length : -1; | |
} | |
function d3_time_parseWeekday(date, string, i) { | |
d3_time_dayRe.lastIndex = 0; | |
var n = d3_time_dayRe.exec(string.substring(i)); | |
return n ? i += n[0].length : -1; | |
} | |
function d3_time_parseMonthAbbrev(date, string, i) { | |
d3_time_monthAbbrevRe.lastIndex = 0; | |
var n = d3_time_monthAbbrevRe.exec(string.substring(i)); | |
return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; | |
} | |
function d3_time_parseMonth(date, string, i) { | |
d3_time_monthRe.lastIndex = 0; | |
var n = d3_time_monthRe.exec(string.substring(i)); | |
return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; | |
} | |
function d3_time_parseLocaleFull(date, string, i) { | |
return d3_time_parse(date, d3_time_formats.c.toString(), string, i); | |
} | |
function d3_time_parseLocaleDate(date, string, i) { | |
return d3_time_parse(date, d3_time_formats.x.toString(), string, i); | |
} | |
function d3_time_parseLocaleTime(date, string, i) { | |
return d3_time_parse(date, d3_time_formats.X.toString(), string, i); | |
} | |
function d3_time_parseFullYear(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 4)); | |
return n ? (date.y = +n[0], i += n[0].length) : -1; | |
} | |
function d3_time_parseYear(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | |
return n ? (date.y = d3_time_expandYear(+n[0]), i += n[0].length) : -1; | |
} | |
function d3_time_expandYear(d) { | |
return d + (d > 68 ? 1900 : 2e3); | |
} | |
function d3_time_parseMonthNumber(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | |
return n ? (date.m = n[0] - 1, i += n[0].length) : -1; | |
} | |
function d3_time_parseDay(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | |
return n ? (date.d = +n[0], i += n[0].length) : -1; | |
} | |
function d3_time_parseHour24(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | |
return n ? (date.H = +n[0], i += n[0].length) : -1; | |
} | |
function d3_time_parseMinutes(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | |
return n ? (date.M = +n[0], i += n[0].length) : -1; | |
} | |
function d3_time_parseSeconds(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | |
return n ? (date.S = +n[0], i += n[0].length) : -1; | |
} | |
function d3_time_parseMilliseconds(date, string, i) { | |
d3_time_numberRe.lastIndex = 0; | |
var n = d3_time_numberRe.exec(string.substring(i, i + 3)); | |
return n ? (date.L = +n[0], i += n[0].length) : -1; | |
} | |
function d3_time_parseAmPm(date, string, i) { | |
var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase()); | |
return n == null ? -1 : (date.p = n, i); | |
} | |
function d3_time_zone(d) { | |
var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(Math.abs(z) / 60), zm = Math.abs(z) % 60; | |
return zs + d3_time_zfill2(zh) + d3_time_zfill2(zm); | |
} | |
function d3_time_formatIsoNative(date) { | |
return date.toISOString(); | |
} | |
function d3_time_interval(local, step, number) { | |
function round(date) { | |
var d0 = local(date), d1 = offset(d0, 1); | |
return date - d0 < d1 - date ? d0 : d1; | |
} | |
function ceil(date) { | |
step(date = local(new d3_time(date - 1)), 1); | |
return date; | |
} | |
function offset(date, k) { | |
step(date = new d3_time(+date), k); | |
return date; | |
} | |
function range(t0, t1, dt) { | |
var time = ceil(t0), times = []; | |
if (dt > 1) { | |
while (time < t1) { | |
if (!(number(time) % dt)) times.push(new Date(+time)); | |
step(time, 1); | |
} | |
} else { | |
while (time < t1) times.push(new Date(+time)), step(time, 1); | |
} | |
return times; | |
} | |
function range_utc(t0, t1, dt) { | |
try { | |
d3_time = d3_time_utc; | |
var utc = new d3_time_utc; | |
utc._ = t0; | |
return range(utc, t1, dt); | |
} finally { | |
d3_time = Date; | |
} | |
} | |
local.floor = local; | |
local.round = round; | |
local.ceil = ceil; | |
local.offset = offset; | |
local.range = range; | |
var utc = local.utc = d3_time_interval_utc(local); | |
utc.floor = utc; | |
utc.round = d3_time_interval_utc(round); | |
utc.ceil = d3_time_interval_utc(ceil); | |
utc.offset = d3_time_interval_utc(offset); | |
utc.range = range_utc; | |
return local; | |
} | |
function d3_time_interval_utc(method) { | |
return function(date, k) { | |
try { | |
d3_time = d3_time_utc; | |
var utc = new d3_time_utc; | |
utc._ = date; | |
return method(utc, k)._; | |
} finally { | |
d3_time = Date; | |
} | |
}; | |
} | |
function d3_time_scale(linear, methods, format) { | |
function scale(x) { | |
return linear(x); | |
} | |
scale.invert = function(x) { | |
return d3_time_scaleDate(linear.invert(x)); | |
}; | |
scale.domain = function(x) { | |
if (!arguments.length) return linear.domain().map(d3_time_scaleDate); | |
linear.domain(x); | |
return scale; | |
}; | |
scale.nice = function(m) { | |
return scale.domain(d3_scale_nice(scale.domain(), function() { | |
return m; | |
})); | |
}; | |
scale.ticks = function(m, k) { | |
var extent = d3_time_scaleExtent(scale.domain()); | |
if (typeof m !== "function") { | |
var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target); | |
if (i == d3_time_scaleSteps.length) return methods.year(extent, m); | |
if (!i) return linear.ticks(m).map(d3_time_scaleDate); | |
if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i; | |
m = methods[i]; | |
k = m[1]; | |
m = m[0].range; | |
} | |
return m(extent[0], new Date(+extent[1] + 1), k); | |
}; | |
scale.tickFormat = function() { | |
return format; | |
}; | |
scale.copy = function() { | |
return d3_time_scale(linear.copy(), methods, format); | |
}; | |
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); | |
} | |
function d3_time_scaleExtent(domain) { | |
var start = domain[0], stop = domain[domain.length - 1]; | |
return start < stop ? [ start, stop ] : [ stop, start ]; | |
} | |
function d3_time_scaleDate(t) { | |
return new Date(t); | |
} | |
function d3_time_scaleFormat(formats) { | |
return function(date) { | |
var i = formats.length - 1, f = formats[i]; | |
while (!f[1](date)) f = formats[--i]; | |
return f[0](date); | |
}; | |
} | |
function d3_time_scaleSetYear(y) { | |
var d = new Date(y, 0, 1); | |
d.setFullYear(y); | |
return d; | |
} | |
function d3_time_scaleGetYear(d) { | |
var y = d.getFullYear(), d0 = d3_time_scaleSetYear(y), d1 = d3_time_scaleSetYear(y + 1); | |
return y + (d - d0) / (d1 - d0); | |
} | |
function d3_time_scaleUTCSetYear(y) { | |
var d = new Date(Date.UTC(y, 0, 1)); | |
d.setUTCFullYear(y); | |
return d; | |
} | |
function d3_time_scaleUTCGetYear(d) { | |
var y = d.getUTCFullYear(), d0 = d3_time_scaleUTCSetYear(y), d1 = d3_time_scaleUTCSetYear(y + 1); | |
return y + (d - d0) / (d1 - d0); | |
} | |
if (!Date.now) Date.now = function() { | |
return +(new Date); | |
}; | |
try { | |
document.createElement("div").style.setProperty("opacity", 0, ""); | |
} catch (error) { | |
var d3_style_prototype = CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty; | |
d3_style_prototype.setProperty = function(name, value, priority) { | |
d3_style_setProperty.call(this, name, value + "", priority); | |
}; | |
} | |
d3 = { | |
version: "2.10.2" | |
}; | |
var d3_array = d3_arraySlice; | |
try { | |
d3_array(document.documentElement.childNodes)[0].nodeType; | |
} catch (e) { | |
d3_array = d3_arrayCopy; | |
} | |
var d3_arraySubclass = [].__proto__ ? function(array, prototype) { | |
array.__proto__ = prototype; | |
} : function(array, prototype) { | |
for (var property in prototype) array[property] = prototype[property]; | |
}; | |
d3.map = function(object) { | |
var map = new d3_Map; | |
for (var key in object) map.set(key, object[key]); | |
return map; | |
}; | |
d3_class(d3_Map, { | |
has: function(key) { | |
return d3_map_prefix + key in this; | |
}, | |
get: function(key) { | |
return this[d3_map_prefix + key]; | |
}, | |
set: function(key, value) { | |
return this[d3_map_prefix + key] = value; | |
}, | |
remove: function(key) { | |
key = d3_map_prefix + key; | |
return key in this && delete this[key]; | |
}, | |
keys: function() { | |
var keys = []; | |
this.forEach(function(key) { | |
keys.push(key); | |
}); | |
return keys; | |
}, | |
values: function() { | |
var values = []; | |
this.forEach(function(key, value) { | |
values.push(value); | |
}); | |
return values; | |
}, | |
entries: function() { | |
var entries = []; | |
this.forEach(function(key, value) { | |
entries.push({ | |
key: key, | |
value: value | |
}); | |
}); | |
return entries; | |
}, | |
forEach: function(f) { | |
for (var key in this) { | |
if (key.charCodeAt(0) === d3_map_prefixCode) { | |
f.call(this, key.substring(1), this[key]); | |
} | |
} | |
} | |
}); | |
var d3_map_prefix = "\0", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); | |
d3.functor = d3_functor; | |
d3.rebind = function(target, source) { | |
var i = 1, n = arguments.length, method; | |
while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); | |
return target; | |
}; | |
d3.ascending = function(a, b) { | |
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; | |
}; | |
d3.descending = function(a, b) { | |
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; | |
}; | |
d3.mean = function(array, f) { | |
var n = array.length, a, m = 0, i = -1, j = 0; | |
if (arguments.length === 1) { | |
while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j; | |
} else { | |
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j; | |
} | |
return j ? m : undefined; | |
}; | |
d3.median = function(array, f) { | |
if (arguments.length > 1) array = array.map(f); | |
array = array.filter(d3_number); | |
return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined; | |
}; | |
d3.min = function(array, f) { | |
var i = -1, n = array.length, a, b; | |
if (arguments.length === 1) { | |
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined; | |
while (++i < n) if ((b = array[i]) != null && a > b) a = b; | |
} else { | |
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined; | |
while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; | |
} | |
return a; | |
}; | |
d3.max = function(array, f) { | |
var i = -1, n = array.length, a, b; | |
if (arguments.length === 1) { | |
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined; | |
while (++i < n) if ((b = array[i]) != null && b > a) a = b; | |
} else { | |
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined; | |
while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; | |
} | |
return a; | |
}; | |
d3.extent = function(array, f) { | |
var i = -1, n = array.length, a, b, c; | |
if (arguments.length === 1) { | |
while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined; | |
while (++i < n) if ((b = array[i]) != null) { | |
if (a > b) a = b; | |
if (c < b) c = b; | |
} | |
} else { | |
while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined; | |
while (++i < n) if ((b = f.call(array, array[i], i)) != null) { | |
if (a > b) a = b; | |
if (c < b) c = b; | |
} | |
} | |
return [ a, c ]; | |
}; | |
d3.random = { | |
normal: function(µ, σ) { | |
var n = arguments.length; | |
if (n < 2) σ = 1; | |
if (n < 1) µ = 0; | |
return function() { | |
var x, y, r; | |
do { | |
x = Math.random() * 2 - 1; | |
y = Math.random() * 2 - 1; | |
r = x * x + y * y; | |
} while (!r || r > 1); | |
return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); | |
}; | |
}, | |
logNormal: function(µ, σ) { | |
var n = arguments.length; | |
if (n < 2) σ = 1; | |
if (n < 1) µ = 0; | |
var random = d3.random.normal(); | |
return function() { | |
return Math.exp(µ + σ * random()); | |
}; | |
}, | |
irwinHall: function(m) { | |
return function() { | |
for (var s = 0, j = 0; j < m; j++) s += Math.random(); | |
return s / m; | |
}; | |
} | |
}; | |
d3.sum = function(array, f) { | |
var s = 0, n = array.length, a, i = -1; | |
if (arguments.length === 1) { | |
while (++i < n) if (!isNaN(a = +array[i])) s += a; | |
} else { | |
while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; | |
} | |
return s; | |
}; | |
d3.quantile = function(values, p) { | |
var H = (values.length - 1) * p + 1, h = Math.floor(H), v = values[h - 1], e = H - h; | |
return e ? v + e * (values[h] - v) : v; | |
}; | |
d3.transpose = function(matrix) { | |
return d3.zip.apply(d3, matrix); | |
}; | |
d3.zip = function() { | |
if (!(n = arguments.length)) return []; | |
for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) { | |
for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) { | |
zip[j] = arguments[j][i]; | |
} | |
} | |
return zips; | |
}; | |
d3.bisector = function(f) { | |
return { | |
left: function(a, x, lo, hi) { | |
if (arguments.length < 3) lo = 0; | |
if (arguments.length < 4) hi = a.length; | |
while (lo < hi) { | |
var mid = lo + hi >>> 1; | |
if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid; | |
} | |
return lo; | |
}, | |
right: function(a, x, lo, hi) { | |
if (arguments.length < 3) lo = 0; | |
if (arguments.length < 4) hi = a.length; | |
while (lo < hi) { | |
var mid = lo + hi >>> 1; | |
if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1; | |
} | |
return lo; | |
} | |
}; | |
}; | |
var d3_bisector = d3.bisector(function(d) { | |
return d; | |
}); | |
d3.bisectLeft = d3_bisector.left; | |
d3.bisect = d3.bisectRight = d3_bisector.right; | |
d3.first = function(array, f) { | |
var i = 0, n = array.length, a = array[0], b; | |
if (arguments.length === 1) f = d3.ascending; | |
while (++i < n) { | |
if (f.call(array, a, b = array[i]) > 0) { | |
a = b; | |
} | |
} | |
return a; | |
}; | |
d3.last = function(array, f) { | |
var i = 0, n = array.length, a = array[0], b; | |
if (arguments.length === 1) f = d3.ascending; | |
while (++i < n) { | |
if (f.call(array, a, b = array[i]) <= 0) { | |
a = b; | |
} | |
} | |
return a; | |
}; | |
d3.nest = function() { | |
function map(array, depth) { | |
if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; | |
var i = -1, n = array.length, key = keys[depth++], keyValue, object, valuesByKey = new d3_Map, values, o = {}; | |
while (++i < n) { | |
if (values = valuesByKey.get(keyValue = key(object = array[i]))) { | |
values.push(object); | |
} else { | |
valuesByKey.set(keyValue, [ object ]); | |
} | |
} | |
valuesByKey.forEach(function(keyValue, values) { | |
o[keyValue] = map(values, depth); | |
}); | |
return o; | |
} | |
function entries(map, depth) { | |
if (depth >= keys.length) return map; | |
var a = [], sortKey = sortKeys[depth++], key; | |
for (key in map) { | |
a.push({ | |
key: key, | |
values: entries(map[key], depth) | |
}); | |
} | |
if (sortKey) a.sort(function(a, b) { | |
return sortKey(a.key, b.key); | |
}); | |
return a; | |
} | |
var nest = {}, keys = [], sortKeys = [], sortValues, rollup; | |
nest.map = function(array) { | |
return map(array, 0); | |
}; | |
nest.entries = function(array) { | |
return entries(map(array, 0), 0); | |
}; | |
nest.key = function(d) { | |
keys.push(d); | |
return nest; | |
}; | |
nest.sortKeys = function(order) { | |
sortKeys[keys.length - 1] = order; | |
return nest; | |
}; | |
nest.sortValues = function(order) { | |
sortValues = order; | |
return nest; | |
}; | |
nest.rollup = function(f) { | |
rollup = f; | |
return nest; | |
}; | |
return nest; | |
}; | |
d3.keys = function(map) { | |
var keys = []; | |
for (var key in map) keys.push(key); | |
return keys; | |
}; | |
d3.values = function(map) { | |
var values = []; | |
for (var key in map) values.push(map[key]); | |
return values; | |
}; | |
d3.entries = function(map) { | |
var entries = []; | |
for (var key in map) entries.push({ | |
key: key, | |
value: map[key] | |
}); | |
return entries; | |
}; | |
d3.permute = function(array, indexes) { | |
var permutes = [], i = -1, n = indexes.length; | |
while (++i < n) permutes[i] = array[indexes[i]]; | |
return permutes; | |
}; | |
d3.merge = function(arrays) { | |
return Array.prototype.concat.apply([], arrays); | |
}; | |
d3.split = function(array, f) { | |
var arrays = [], values = [], value, i = -1, n = array.length; | |
if (arguments.length < 2) f = d3_splitter; | |
while (++i < n) { | |
if (f.call(values, value = array[i], i)) { | |
values = []; | |
} else { | |
if (!values.length) arrays.push(values); | |
values.push(value); | |
} | |
} | |
return arrays; | |
}; | |
d3.range = function(start, stop, step) { | |
if (arguments.length < 3) { | |
step = 1; | |
if (arguments.length < 2) { | |
stop = start; | |
start = 0; | |
} | |
} | |
if ((stop - start) / step === Infinity) throw new Error("infinite range"); | |
var range = [], k = d3_range_integerScale(Math.abs(step)), i = -1, j; | |
start *= k, stop *= k, step *= k; | |
if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); | |
return range; | |
}; | |
d3.requote = function(s) { | |
return s.replace(d3_requote_re, "\\$&"); | |
}; | |
var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; | |
d3.round = function(x, n) { | |
return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); | |
}; | |
d3.xhr = function(url, mime, callback) { | |
var req = new XMLHttpRequest; | |
if (arguments.length < 3) callback = mime, mime = null; else if (mime && req.overrideMimeType) req.overrideMimeType(mime); | |
req.open("GET", url, true); | |
if (mime) req.setRequestHeader("Accept", mime); | |
req.onreadystatechange = function() { | |
if (req.readyState === 4) { | |
var s = req.status; | |
callback(!s && req.response || s >= 200 && s < 300 || s === 304 ? req : null); | |
} | |
}; | |
req.send(null); | |
}; | |
d3.text = function(url, mime, callback) { | |
function ready(req) { | |
callback(req && req.responseText); | |
} | |
if (arguments.length < 3) { | |
callback = mime; | |
mime = null; | |
} | |
d3.xhr(url, mime, ready); | |
}; | |
d3.json = function(url, callback) { | |
d3.text(url, "application/json", function(text) { | |
callback(text ? JSON.parse(text) : null); | |
}); | |
}; | |
d3.html = function(url, callback) { | |
d3.text(url, "text/html", function(text) { | |
if (text != null) { | |
var range = document.createRange(); | |
range.selectNode(document.body); | |
text = range.createContextualFragment(text); | |
} | |
callback(text); | |
}); | |
}; | |
d3.xml = function(url, mime, callback) { | |
function ready(req) { | |
callback(req && req.responseXML); | |
} | |
if (arguments.length < 3) { | |
callback = mime; | |
mime = null; | |
} | |
d3.xhr(url, mime, ready); | |
}; | |
var d3_nsPrefix = { | |
svg: "http://www.w3.org/2000/svg", | |
xhtml: "http://www.w3.org/1999/xhtml", | |
xlink: "http://www.w3.org/1999/xlink", | |
xml: "http://www.w3.org/XML/1998/namespace", | |
xmlns: "http://www.w3.org/2000/xmlns/" | |
}; | |
d3.ns = { | |
prefix: d3_nsPrefix, | |
qualify: function(name) { | |
var i = name.indexOf(":"), prefix = name; | |
if (i >= 0) { | |
prefix = name.substring(0, i); | |
name = name.substring(i + 1); | |
} | |
return d3_nsPrefix.hasOwnProperty(prefix) ? { | |
space: d3_nsPrefix[prefix], | |
local: name | |
} : name; | |
} | |
}; | |
d3.dispatch = function() { | |
var dispatch = new d3_dispatch, i = -1, n = arguments.length; | |
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); | |
return dispatch; | |
}; | |
d3_dispatch.prototype.on = function(type, listener) { | |
var i = type.indexOf("."), name = ""; | |
if (i > 0) { | |
name = type.substring(i + 1); | |
type = type.substring(0, i); | |
} | |
return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); | |
}; | |
d3.format = function(specifier) { | |
var match = d3_format_re.exec(specifier), fill = match[1] || " ", sign = match[3] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, suffix = "", integer = false; | |
if (precision) precision = +precision.substring(1); | |
if (zfill) { | |
fill = "0"; | |
if (comma) width -= Math.floor((width - 1) / 4); | |
} | |
switch (type) { | |
case "n": | |
comma = true; | |
type = "g"; | |
break; | |
case "%": | |
scale = 100; | |
suffix = "%"; | |
type = "f"; | |
break; | |
case "p": | |
scale = 100; | |
suffix = "%"; | |
type = "r"; | |
break; | |
case "d": | |
integer = true; | |
precision = 0; | |
break; | |
case "s": | |
scale = -1; | |
type = "r"; | |
break; | |
} | |
if (type == "r" && !precision) type = "g"; | |
type = d3_format_types.get(type) || d3_format_typeDefault; | |
return function(value) { | |
if (integer && value % 1) return ""; | |
var negative = value < 0 && (value = -value) ? "-" : sign; | |
if (scale < 0) { | |
var prefix = d3.formatPrefix(value, precision); | |
value = prefix.scale(value); | |
suffix = prefix.symbol; | |
} else { | |
value *= scale; | |
} | |
value = type(value, precision); | |
if (zfill) { | |
var length = value.length + negative.length; | |
if (length < width) value = (new Array(width - length + 1)).join(fill) + value; | |
if (comma) value = d3_format_group(value); | |
value = negative + value; | |
} else { | |
if (comma) value = d3_format_group(value); | |
value = negative + value; | |
var length = value.length; | |
if (length < width) value = (new Array(width - length + 1)).join(fill) + value; | |
} | |
return value + suffix; | |
}; | |
}; | |
var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/; | |
var d3_format_types = d3.map({ | |
g: function(x, p) { | |
return x.toPrecision(p); | |
}, | |
e: function(x, p) { | |
return x.toExponential(p); | |
}, | |
f: function(x, p) { | |
return x.toFixed(p); | |
}, | |
r: function(x, p) { | |
return d3.round(x, p = d3_format_precision(x, p)).toFixed(Math.max(0, Math.min(20, p))); | |
} | |
}); | |
var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "μ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); | |
d3.formatPrefix = function(value, precision) { | |
var i = 0; | |
if (value) { | |
if (value < 0) value *= -1; | |
if (precision) value = d3.round(value, d3_format_precision(value, precision)); | |
i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); | |
i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3)); | |
} | |
return d3_formatPrefixes[8 + i / 3]; | |
}; | |
var d3_ease_quad = d3_ease_poly(2), d3_ease_cubic = d3_ease_poly(3), d3_ease_default = function() { | |
return d3_ease_identity; | |
}; | |
var d3_ease = d3.map({ | |
linear: d3_ease_default, | |
poly: d3_ease_poly, | |
quad: function() { | |
return d3_ease_quad; | |
}, | |
cubic: function() { | |
return d3_ease_cubic; | |
}, | |
sin: function() { | |
return d3_ease_sin; | |
}, | |
exp: function() { | |
return d3_ease_exp; | |
}, | |
circle: function() { | |
return d3_ease_circle; | |
}, | |
elastic: d3_ease_elastic, | |
back: d3_ease_back, | |
bounce: function() { | |
return d3_ease_bounce; | |
} | |
}); | |
var d3_ease_mode = d3.map({ | |
"in": d3_ease_identity, | |
out: d3_ease_reverse, | |
"in-out": d3_ease_reflect, | |
"out-in": function(f) { | |
return d3_ease_reflect(d3_ease_reverse(f)); | |
} | |
}); | |
d3.ease = function(name) { | |
var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in"; | |
t = d3_ease.get(t) || d3_ease_default; | |
m = d3_ease_mode.get(m) || d3_ease_identity; | |
return d3_ease_clamp(m(t.apply(null, Array.prototype.slice.call(arguments, 1)))); | |
}; | |
d3.event = null; | |
d3.transform = function(string) { | |
var g = document.createElementNS(d3.ns.prefix.svg, "g"); | |
return (d3.transform = function(string) { | |
g.setAttribute("transform", string); | |
var t = g.transform.baseVal.consolidate(); | |
return new d3_transform(t ? t.matrix : d3_transformIdentity); | |
})(string); | |
}; | |
d3_transform.prototype.toString = function() { | |
return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; | |
}; | |
var d3_transformDegrees = 180 / Math.PI, d3_transformIdentity = { | |
a: 1, | |
b: 0, | |
c: 0, | |
d: 1, | |
e: 0, | |
f: 0 | |
}; | |
d3.interpolate = function(a, b) { | |
var i = d3.interpolators.length, f; | |
while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; | |
return f; | |
}; | |
d3.interpolateNumber = function(a, b) { | |
b -= a; | |
return function(t) { | |
return a + b * t; | |
}; | |
}; | |
d3.interpolateRound = function(a, b) { | |
b -= a; | |
return function(t) { | |
return Math.round(a + b * t); | |
}; | |
}; | |
d3.interpolateString = function(a, b) { | |
var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; | |
d3_interpolate_number.lastIndex = 0; | |
for (i = 0; m = d3_interpolate_number.exec(b); ++i) { | |
if (m.index) s.push(b.substring(s0, s1 = m.index)); | |
q.push({ | |
i: s.length, | |
x: m[0] | |
}); | |
s.push(null); | |
s0 = d3_interpolate_number.lastIndex; | |
} | |
if (s0 < b.length) s.push(b.substring(s0)); | |
for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { | |
o = q[i]; | |
if (o.x == m[0]) { | |
if (o.i) { | |
if (s[o.i + 1] == null) { | |
s[o.i - 1] += o.x; | |
s.splice(o.i, 1); | |
for (j = i + 1; j < n; ++j) q[j].i--; | |
} else { | |
s[o.i - 1] += o.x + s[o.i + 1]; | |
s.splice(o.i, 2); | |
for (j = i + 1; j < n; ++j) q[j].i -= 2; | |
} | |
} else { | |
if (s[o.i + 1] == null) { | |
s[o.i] = o.x; | |
} else { | |
s[o.i] = o.x + s[o.i + 1]; | |
s.splice(o.i + 1, 1); | |
for (j = i + 1; j < n; ++j) q[j].i--; | |
} | |
} | |
q.splice(i, 1); | |
n--; | |
i--; | |
} else { | |
o.x = d3.interpolateNumber(parseFloat(m[0]), parseFloat(o.x)); | |
} | |
} | |
while (i < n) { | |
o = q.pop(); | |
if (s[o.i + 1] == null) { | |
s[o.i] = o.x; | |
} else { | |
s[o.i] = o.x + s[o.i + 1]; | |
s.splice(o.i + 1, 1); | |
} | |
n--; | |
} | |
if (s.length === 1) { | |
return s[0] == null ? q[0].x : function() { | |
return b; | |
}; | |
} | |
return function(t) { | |
for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); | |
return s.join(""); | |
}; | |
}; | |
d3.interpolateTransform = function(a, b) { | |
var s = [], q = [], n, A = d3.transform(a), B = d3.transform(b), ta = A.translate, tb = B.translate, ra = A.rotate, rb = B.rotate, wa = A.skew, wb = B.skew, ka = A.scale, kb = B.scale; | |
if (ta[0] != tb[0] || ta[1] != tb[1]) { | |
s.push("translate(", null, ",", null, ")"); | |
q.push({ | |
i: 1, | |
x: d3.interpolateNumber(ta[0], tb[0]) | |
}, { | |
i: 3, | |
x: d3.interpolateNumber(ta[1], tb[1]) | |
}); | |
} else if (tb[0] || tb[1]) { | |
s.push("translate(" + tb + ")"); | |
} else { | |
s.push(""); | |
} | |
if (ra != rb) { | |
if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; | |
q.push({ | |
i: s.push(s.pop() + "rotate(", null, ")") - 2, | |
x: d3.interpolateNumber(ra, rb) | |
}); | |
} else if (rb) { | |
s.push(s.pop() + "rotate(" + rb + ")"); | |
} | |
if (wa != wb) { | |
q.push({ | |
i: s.push(s.pop() + "skewX(", null, ")") - 2, | |
x: d3.interpolateNumber(wa, wb) | |
}); | |
} else if (wb) { | |
s.push(s.pop() + "skewX(" + wb + ")"); | |
} | |
if (ka[0] != kb[0] || ka[1] != kb[1]) { | |
n = s.push(s.pop() + "scale(", null, ",", null, ")"); | |
q.push({ | |
i: n - 4, | |
x: d3.interpolateNumber(ka[0], kb[0]) | |
}, { | |
i: n - 2, | |
x: d3.interpolateNumber(ka[1], kb[1]) | |
}); | |
} else if (kb[0] != 1 || kb[1] != 1) { | |
s.push(s.pop() + "scale(" + kb + ")"); | |
} | |
n = q.length; | |
return function(t) { | |
var i = -1, o; | |
while (++i < n) s[(o = q[i]).i] = o.x(t); | |
return s.join(""); | |
}; | |
}; | |
d3.interpolateRgb = function(a, b) { | |
a = d3.rgb(a); | |
b = d3.rgb(b); | |
var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; | |
return function(t) { | |
return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); | |
}; | |
}; | |
d3.interpolateHsl = function(a, b) { | |
a = d3.hsl(a); | |
b = d3.hsl(b); | |
var h0 = a.h, s0 = a.s, l0 = a.l, h1 = b.h - h0, s1 = b.s - s0, l1 = b.l - l0; | |
if (h1 > 180) h1 -= 360; else if (h1 < -180) h1 += 360; | |
return function(t) { | |
return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t) + ""; | |
}; | |
}; | |
d3.interpolateLab = function(a, b) { | |
a = d3.lab(a); | |
b = d3.lab(b); | |
var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; | |
return function(t) { | |
return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; | |
}; | |
}; | |
d3.interpolateHcl = function(a, b) { | |
a = d3.hcl(a); | |
b = d3.hcl(b); | |
var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; | |
if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; | |
return function(t) { | |
return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; | |
}; | |
}; | |
d3.interpolateArray = function(a, b) { | |
var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; | |
for (i = 0; i < n0; ++i) x.push(d3.interpolate(a[i], b[i])); | |
for (; i < na; ++i) c[i] = a[i]; | |
for (; i < nb; ++i) c[i] = b[i]; | |
return function(t) { | |
for (i = 0; i < n0; ++i) c[i] = x[i](t); | |
return c; | |
}; | |
}; | |
d3.interpolateObject = function(a, b) { | |
var i = {}, c = {}, k; | |
for (k in a) { | |
if (k in b) { | |
i[k] = d3_interpolateByName(k)(a[k], b[k]); | |
} else { | |
c[k] = a[k]; | |
} | |
} | |
for (k in b) { | |
if (!(k in a)) { | |
c[k] = b[k]; | |
} | |
} | |
return function(t) { | |
for (k in i) c[k] = i[k](t); | |
return c; | |
}; | |
}; | |
var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; | |
d3.interpolators = [ d3.interpolateObject, function(a, b) { | |
return b instanceof Array && d3.interpolateArray(a, b); | |
}, function(a, b) { | |
return (typeof a === "string" || typeof b === "string") && d3.interpolateString(a + "", b + ""); | |
}, function(a, b) { | |
return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(a, b); | |
}, function(a, b) { | |
return !isNaN(a = +a) && !isNaN(b = +b) && d3.interpolateNumber(a, b); | |
} ]; | |
d3.rgb = function(r, g, b) { | |
return arguments.length === 1 ? r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : d3_rgb(~~r, ~~g, ~~b); | |
}; | |
d3_Rgb.prototype.brighter = function(k) { | |
k = Math.pow(.7, arguments.length ? k : 1); | |
var r = this.r, g = this.g, b = this.b, i = 30; | |
if (!r && !g && !b) return d3_rgb(i, i, i); | |
if (r && r < i) r = i; | |
if (g && g < i) g = i; | |
if (b && b < i) b = i; | |
return d3_rgb(Math.min(255, Math.floor(r / k)), Math.min(255, Math.floor(g / k)), Math.min(255, Math.floor(b / k))); | |
}; | |
d3_Rgb.prototype.darker = function(k) { | |
k = Math.pow(.7, arguments.length ? k : 1); | |
return d3_rgb(Math.floor(k * this.r), Math.floor(k * this.g), Math.floor(k * this.b)); | |
}; | |
d3_Rgb.prototype.hsl = function() { | |
return d3_rgb_hsl(this.r, this.g, this.b); | |
}; | |
d3_Rgb.prototype.toString = function() { | |
return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); | |
}; | |
var d3_rgb_names = d3.map({ | |
aliceblue: "#f0f8ff", | |
antiquewhite: "#faebd7", | |
aqua: "#00ffff", | |
aquamarine: "#7fffd4", | |
azure: "#f0ffff", | |
beige: "#f5f5dc", | |
bisque: "#ffe4c4", | |
black: "#000000", | |
blanchedalmond: "#ffebcd", | |
blue: "#0000ff", | |
blueviolet: "#8a2be2", | |
brown: "#a52a2a", | |
burlywood: "#deb887", | |
cadetblue: "#5f9ea0", | |
chartreuse: "#7fff00", | |
chocolate: "#d2691e", | |
coral: "#ff7f50", | |
cornflowerblue: "#6495ed", | |
cornsilk: "#fff8dc", | |
crimson: "#dc143c", | |
cyan: "#00ffff", | |
darkblue: "#00008b", | |
darkcyan: "#008b8b", | |
darkgoldenrod: "#b8860b", | |
darkgray: "#a9a9a9", | |
darkgreen: "#006400", | |
darkgrey: "#a9a9a9", | |
darkkhaki: "#bdb76b", | |
darkmagenta: "#8b008b", | |
darkolivegreen: "#556b2f", | |
darkorange: "#ff8c00", | |
darkorchid: "#9932cc", | |
darkred: "#8b0000", | |
darksalmon: "#e9967a", | |
darkseagreen: "#8fbc8f", | |
darkslateblue: "#483d8b", | |
darkslategray: "#2f4f4f", | |
darkslategrey: "#2f4f4f", | |
darkturquoise: "#00ced1", | |
darkviolet: "#9400d3", | |
deeppink: "#ff1493", | |
deepskyblue: "#00bfff", | |
dimgray: "#696969", | |
dimgrey: "#696969", | |
dodgerblue: "#1e90ff", | |
firebrick: "#b22222", | |
floralwhite: "#fffaf0", | |
forestgreen: "#228b22", | |
fuchsia: "#ff00ff", | |
gainsboro: "#dcdcdc", | |
ghostwhite: "#f8f8ff", | |
gold: "#ffd700", | |
goldenrod: "#daa520", | |
gray: "#808080", | |
green: "#008000", | |
greenyellow: "#adff2f", | |
grey: "#808080", | |
honeydew: "#f0fff0", | |
hotpink: "#ff69b4", | |
indianred: "#cd5c5c", | |
indigo: "#4b0082", | |
ivory: "#fffff0", | |
khaki: "#f0e68c", | |
lavender: "#e6e6fa", | |
lavenderblush: "#fff0f5", | |
lawngreen: "#7cfc00", | |
lemonchiffon: "#fffacd", | |
lightblue: "#add8e6", | |
lightcoral: "#f08080", | |
lightcyan: "#e0ffff", | |
lightgoldenrodyellow: "#fafad2", | |
lightgray: "#d3d3d3", | |
lightgreen: "#90ee90", | |
lightgrey: "#d3d3d3", | |
lightpink: "#ffb6c1", | |
lightsalmon: "#ffa07a", | |
lightseagreen: "#20b2aa", | |
lightskyblue: "#87cefa", | |
lightslategray: "#778899", | |
lightslategrey: "#778899", | |
lightsteelblue: "#b0c4de", | |
lightyellow: "#ffffe0", | |
lime: "#00ff00", | |
limegreen: "#32cd32", | |
linen: "#faf0e6", | |
magenta: "#ff00ff", | |
maroon: "#800000", | |
mediumaquamarine: "#66cdaa", | |
mediumblue: "#0000cd", | |
mediumorchid: "#ba55d3", | |
mediumpurple: "#9370db", | |
mediumseagreen: "#3cb371", | |
mediumslateblue: "#7b68ee", | |
mediumspringgreen: "#00fa9a", | |
mediumturquoise: "#48d1cc", | |
mediumvioletred: "#c71585", | |
midnightblue: "#191970", | |
mintcream: "#f5fffa", | |
mistyrose: "#ffe4e1", | |
moccasin: "#ffe4b5", | |
navajowhite: "#ffdead", | |
navy: "#000080", | |
oldlace: "#fdf5e6", | |
olive: "#808000", | |
olivedrab: "#6b8e23", | |
orange: "#ffa500", | |
orangered: "#ff4500", | |
orchid: "#da70d6", | |
palegoldenrod: "#eee8aa", | |
palegreen: "#98fb98", | |
paleturquoise: "#afeeee", | |
palevioletred: "#db7093", | |
papayawhip: "#ffefd5", | |
peachpuff: "#ffdab9", | |
peru: "#cd853f", | |
pink: "#ffc0cb", | |
plum: "#dda0dd", | |
powderblue: "#b0e0e6", | |
purple: "#800080", | |
red: "#ff0000", | |
rosybrown: "#bc8f8f", | |
royalblue: "#4169e1", | |
saddlebrown: "#8b4513", | |
salmon: "#fa8072", | |
sandybrown: "#f4a460", | |
seagreen: "#2e8b57", | |
seashell: "#fff5ee", | |
sienna: "#a0522d", | |
silver: "#c0c0c0", | |
skyblue: "#87ceeb", | |
slateblue: "#6a5acd", | |
slategray: "#708090", | |
slategrey: "#708090", | |
snow: "#fffafa", | |
springgreen: "#00ff7f", | |
steelblue: "#4682b4", | |
tan: "#d2b48c", | |
teal: "#008080", | |
thistle: "#d8bfd8", | |
tomato: "#ff6347", | |
turquoise: "#40e0d0", | |
violet: "#ee82ee", | |
wheat: "#f5deb3", | |
white: "#ffffff", | |
whitesmoke: "#f5f5f5", | |
yellow: "#ffff00", | |
yellowgreen: "#9acd32" | |
}); | |
d3_rgb_names.forEach(function(key, value) { | |
d3_rgb_names.set(key, d3_rgb_parse(value, d3_rgb, d3_hsl_rgb)); | |
}); | |
d3.hsl = function(h, s, l) { | |
return arguments.length === 1 ? h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : d3_hsl(+h, +s, +l); | |
}; | |
d3_Hsl.prototype.brighter = function(k) { | |
k = Math.pow(.7, arguments.length ? k : 1); | |
return d3_hsl(this.h, this.s, this.l / k); | |
}; | |
d3_Hsl.prototype.darker = function(k) { | |
k = Math.pow(.7, arguments.length ? k : 1); | |
return d3_hsl(this.h, this.s, k * this.l); | |
}; | |
d3_Hsl.prototype.rgb = function() { | |
return d3_hsl_rgb(this.h, this.s, this.l); | |
}; | |
d3_Hsl.prototype.toString = function() { | |
return this.rgb().toString(); | |
}; | |
d3.hcl = function(h, c, l) { | |
return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); | |
}; | |
d3_Hcl.prototype.brighter = function(k) { | |
return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); | |
}; | |
d3_Hcl.prototype.darker = function(k) { | |
return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); | |
}; | |
d3_Hcl.prototype.rgb = function() { | |
return d3_hcl_lab(this.h, this.c, this.l).rgb(); | |
}; | |
d3_Hcl.prototype.toString = function() { | |
return this.rgb() + ""; | |
}; | |
d3.lab = function(l, a, b) { | |
return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); | |
}; | |
var d3_lab_K = 18; | |
var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; | |
d3_Lab.prototype.brighter = function(k) { | |
return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); | |
}; | |
d3_Lab.prototype.darker = function(k) { | |
return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); | |
}; | |
d3_Lab.prototype.rgb = function() { | |
return d3_lab_rgb(this.l, this.a, this.b); | |
}; | |
d3_Lab.prototype.toString = function() { | |
return this.rgb() + ""; | |
}; | |
var d3_select = function(s, n) { | |
return n.querySelector(s); | |
}, d3_selectAll = function(s, n) { | |
return n.querySelectorAll(s); | |
}, d3_selectRoot = document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) { | |
return d3_selectMatcher.call(n, s); | |
}; | |
if (typeof Sizzle === "function") { | |
d3_select = function(s, n) { | |
return Sizzle(s, n)[0] || null; | |
}; | |
d3_selectAll = function(s, n) { | |
return Sizzle.uniqueSort(Sizzle(s, n)); | |
}; | |
d3_selectMatches = Sizzle.matchesSelector; | |
} | |
var d3_selectionPrototype = []; | |
d3.selection = function() { | |
return d3_selectionRoot; | |
}; | |
d3.selection.prototype = d3_selectionPrototype; | |
d3_selectionPrototype.select = function(selector) { | |
var subgroups = [], subgroup, subnode, group, node; | |
if (typeof selector !== "function") selector = d3_selection_selector(selector); | |
for (var j = -1, m = this.length; ++j < m; ) { | |
subgroups.push(subgroup = []); | |
subgroup.parentNode = (group = this[j]).parentNode; | |
for (var i = -1, n = group.length; ++i < n; ) { | |
if (node = group[i]) { | |
subgroup.push(subnode = selector.call(node, node.__data__, i)); | |
if (subnode && "__data__" in node) subnode.__data__ = node.__data__; | |
} else { | |
subgroup.push(null); | |
} | |
} | |
} | |
return d3_selection(subgroups); | |
}; | |
d3_selectionPrototype.selectAll = function(selector) { | |
var subgroups = [], subgroup, node; | |
if (typeof selector !== "function") selector = d3_selection_selectorAll(selector); | |
for (var j = -1, m = this.length; ++j < m; ) { | |
for (var group = this[j], i = -1, n = group.length; ++i < n; ) { | |
if (node = group[i]) { | |
subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i))); | |
subgroup.parentNode = node; | |
} | |
} | |
} | |
return d3_selection(subgroups); | |
}; | |
d3_selectionPrototype.attr = function(name, value) { | |
if (arguments.length < 2) { | |
if (typeof name === "string") { | |
var node = this.node(); | |
name = d3.ns.qualify(name); | |
return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); | |
} | |
for (value in name) this.each(d3_selection_attr(value, name[value])); | |
return this; | |
} | |
return this.each(d3_selection_attr(name, value)); | |
}; | |
d3_selectionPrototype.classed = function(name, value) { | |
if (arguments.length < 2) { | |
if (typeof name === "string") { | |
var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1; | |
if (value = node.classList) { | |
while (++i < n) if (!value.contains(name[i])) return false; | |
} else { | |
value = node.className; | |
if (value.baseVal != null) value = value.baseVal; | |
while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; | |
} | |
return true; | |
} | |
for (value in name) this.each(d3_selection_classed(value, name[value])); | |
return this; | |
} | |
return this.each(d3_selection_classed(name, value)); | |
}; | |
d3_selectionPrototype.style = function(name, value, priority) { | |
var n = arguments.length; | |
if (n < 3) { | |
if (typeof name !== "string") { | |
if (n < 2) value = ""; | |
for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); | |
return this; | |
} | |
if (n < 2) return window.getComputedStyle(this.node(), null).getPropertyValue(name); | |
priority = ""; | |
} | |
return this.each(d3_selection_style(name, value, priority)); | |
}; | |
d3_selectionPrototype.property = function(name, value) { | |
if (arguments.length < 2) { | |
if (typeof name === "string") return this.node()[name]; | |
for (value in name) this.each(d3_selection_property(value, name[value])); | |
return this; | |
} | |
return this.each(d3_selection_property(name, value)); | |
}; | |
d3_selectionPrototype.text = function(value) { | |
return arguments.length < 1 ? this.node().textContent : this.each(typeof value === "function" ? function() { | |
var v = value.apply(this, arguments); | |
this.textContent = v == null ? "" : v; | |
} : value == null ? function() { | |
this.textContent = ""; | |
} : function() { | |
this.textContent = value; | |
}); | |
}; | |
d3_selectionPrototype.html = function(value) { | |
return arguments.length < 1 ? this.node().innerHTML : this.each(typeof value === "function" ? function() { | |
var v = value.apply(this, arguments); | |
this.innerHTML = v == null ? "" : v; | |
} : value == null ? function() { | |
this.innerHTML = ""; | |
} : function() { | |
this.innerHTML = value; | |
}); | |
}; | |
d3_selectionPrototype.append = function(name) { | |
function append() { | |
return this.appendChild(document.createElementNS(this.namespaceURI, name)); | |
} | |
function appendNS() { | |
return this.appendChild(document.createElementNS(name.space, name.local)); | |
} | |
name = d3.ns.qualify(name); | |
return this.select(name.local ? appendNS : append); | |
}; | |
d3_selectionPrototype.insert = function(name, before) { | |
function insert() { | |
return this.insertBefore(document.createElementNS(this.namespaceURI, name), d3_select(before, this)); | |
} | |
function insertNS() { | |
return this.insertBefore(document.createElementNS(name.space, name.local), d3_select(before, this)); | |
} | |
name = d3.ns.qualify(name); | |
return this.select(name.local ? insertNS : insert); | |
}; | |
d3_selectionPrototype.remove = function() { | |
return this.each(function() { | |
var parent = this.parentNode; | |
if (parent) parent.removeChild(this); | |
}); | |
}; | |
d3_selectionPrototype.data = function(value, key) { | |
function bind(group, groupData) { | |
var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), n1 = Math.max(n, m), updateNodes = [], enterNodes = [], exitNodes = [], node, nodeData; | |
if (key) { | |
var nodeByKeyValue = new d3_Map, keyValues = [], keyValue, j = groupData.length; | |
for (i = -1; ++i < n; ) { | |
keyValue = key.call(node = group[i], node.__data__, i); | |
if (nodeByKeyValue.has(keyValue)) { | |
exitNodes[j++] = node; | |
} else { | |
nodeByKeyValue.set(keyValue, node); | |
} | |
keyValues.push(keyValue); | |
} | |
for (i = -1; ++i < m; ) { | |
keyValue = key.call(groupData, nodeData = groupData[i], i); | |
if (nodeByKeyValue.has(keyValue)) { | |
updateNodes[i] = node = nodeByKeyValue.get(keyValue); | |
node.__data__ = nodeData; | |
enterNodes[i] = exitNodes[i] = null; | |
} else { | |
enterNodes[i] = d3_selection_dataNode(nodeData); | |
updateNodes[i] = exitNodes[i] = null; | |
} | |
nodeByKeyValue.remove(keyValue); | |
} | |
for (i = -1; ++i < n; ) { | |
if (nodeByKeyValue.has(keyValues[i])) { | |
exitNodes[i] = group[i]; | |
} | |
} | |
} else { | |
for (i = -1; ++i < n0; ) { | |
node = group[i]; | |
nodeData = groupData[i]; | |
if (node) { | |
node.__data__ = nodeData; | |
updateNodes[i] = node; | |
enterNodes[i] = exitNodes[i] = null; | |
} else { | |
enterNodes[i] = d3_selection_dataNode(nodeData); | |
updateNodes[i] = exitNodes[i] = null; | |
} | |
} | |
for (; i < m; ++i) { | |
enterNodes[i] = d3_selection_dataNode(groupData[i]); | |
updateNodes[i] = exitNodes[i] = null; | |
} | |
for (; i < n1; ++i) { | |
exitNodes[i] = group[i]; | |
enterNodes[i] = updateNodes[i] = null; | |
} | |
} | |
enterNodes.update = updateNodes; | |
enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; | |
enter.push(enterNodes); | |
update.push(updateNodes); | |
exit.push(exitNodes); | |
} | |
var i = -1, n = this.length, group, node; | |
if (!arguments.length) { | |
value = new Array(n = (group = this[0]).length); | |
while (++i < n) { | |
if (node = group[i]) { | |
value[i] = node.__data__; | |
} | |
} | |
return value; | |
} | |
var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); | |
if (typeof value === "function") { | |
while (++i < n) { | |
bind(group = this[i], value.call(group, group.parentNode.__data__, i)); | |
} | |
} else { | |
while (++i < n) { | |
bind(group = this[i], value); | |
} | |
} | |
update.enter = function() { | |
return enter; | |
}; | |
update.exit = function() { | |
return exit; | |
}; | |
return update; | |
}; | |
d3_selectionPrototype.datum = d3_selectionPrototype.map = function(value) { | |
return arguments.length < 1 ? this.property("__data__") : this.property("__data__", value); | |
}; | |
d3_selectionPrototype.filter = function(filter) { | |
var subgroups = [], subgroup, group, node; | |
if (typeof filter !== "function") filter = d3_selection_filter(filter); | |
for (var j = 0, m = this.length; j < m; j++) { | |
subgroups.push(subgroup = []); | |
subgroup.parentNode = (group = this[j]).parentNode; | |
for (var i = 0, n = group.length; i < n; i++) { | |
if ((node = group[i]) && filter.call(node, node.__data__, i)) { | |
subgroup.push(node); | |
} | |
} | |
} | |
return d3_selection(subgroups); | |
}; | |
d3_selectionPrototype.order = function() { | |
for (var j = -1, m = this.length; ++j < m; ) { | |
for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { | |
if (node = group[i]) { | |
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); | |
next = node; | |
} | |
} | |
} | |
return this; | |
}; | |
d3_selectionPrototype.sort = function(comparator) { | |
comparator = d3_selection_sortComparator.apply(this, arguments); | |
for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); | |
return this.order(); | |
}; | |
d3_selectionPrototype.on = function(type, listener, capture) { | |
var n = arguments.length; | |
if (n < 3) { | |
if (typeof type !== "string") { | |
if (n < 2) listener = false; | |
for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); | |
return this; | |
} | |
if (n < 2) return (n = this.node()["__on" + type]) && n._; | |
capture = false; | |
} | |
return this.each(d3_selection_on(type, listener, capture)); | |
}; | |
d3_selectionPrototype.each = function(callback) { | |
return d3_selection_each(this, function(node, i, j) { | |
callback.call(node, node.__data__, i, j); | |
}); | |
}; | |
d3_selectionPrototype.call = function(callback) { | |
callback.apply(this, (arguments[0] = this, arguments)); | |
return this; | |
}; | |
d3_selectionPrototype.empty = function() { | |
return !this.node(); | |
}; | |
d3_selectionPrototype.node = function(callback) { | |
for (var j = 0, m = this.length; j < m; j++) { | |
for (var group = this[j], i = 0, n = group.length; i < n; i++) { | |
var node = group[i]; | |
if (node) return node; | |
} | |
} | |
return null; | |
}; | |
d3_selectionPrototype.transition = function() { | |
var subgroups = [], subgroup, node; | |
for (var j = -1, m = this.length; ++j < m; ) { | |
subgroups.push(subgroup = []); | |
for (var group = this[j], i = -1, n = group.length; ++i < n; ) { | |
subgroup.push((node = group[i]) ? { | |
node: node, | |
delay: d3_transitionDelay, | |
duration: d3_transitionDuration | |
} : null); | |
} | |
} | |
return d3_transition(subgroups, d3_transitionId || ++d3_transitionNextId, Date.now()); | |
}; | |
var d3_selectionRoot = d3_selection([ [ document ] ]); | |
d3_selectionRoot[0].parentNode = d3_selectRoot; | |
d3.select = function(selector) { | |
return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]); | |
}; | |
d3.selectAll = function(selector) { | |
return typeof selector === "string" ? d3_selectionRoot.selectAll(selector) : d3_selection([ d3_array(selector) ]); | |
}; | |
var d3_selection_enterPrototype = []; | |
d3.selection.enter = d3_selection_enter; | |
d3.selection.enter.prototype = d3_selection_enterPrototype; | |
d3_selection_enterPrototype.append = d3_selectionPrototype.append; | |
d3_selection_enterPrototype.insert = d3_selectionPrototype.insert; | |
d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; | |
d3_selection_enterPrototype.node = d3_selectionPrototype.node; | |
d3_selection_enterPrototype.select = function(selector) { | |
var subgroups = [], subgroup, subnode, upgroup, group, node; | |
for (var j = -1, m = this.length; ++j < m; ) { | |
upgroup = (group = this[j]).update; | |
subgroups.push(subgroup = []); | |
subgroup.parentNode = group.parentNode; | |
for (var i = -1, n = group.length; ++i < n; ) { | |
if (node = group[i]) { | |
subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i)); | |
subnode.__data__ = node.__data__; | |
} else { | |
subgroup.push(null); | |
} | |
} | |
} | |
return d3_selection(subgroups); | |
}; | |
var d3_transitionPrototype = [], d3_transitionNextId = 0, d3_transitionId = 0, d3_transitionDefaultDelay = 0, d3_transitionDefaultDuration = 250, d3_transitionDefaultEase = d3.ease("cubic-in-out"), d3_transitionDelay = d3_transitionDefaultDelay, d3_transitionDuration = d3_transitionDefaultDuration, d3_transitionEase = d3_transitionDefaultEase; | |
d3_transitionPrototype.call = d3_selectionPrototype.call; | |
d3.transition = function(selection) { | |
return arguments.length ? d3_transitionId ? selection.transition() : selection : d3_selectionRoot.transition(); | |
}; | |
d3.transition.prototype = d3_transitionPrototype; | |
d3_transitionPrototype.select = function(selector) { | |
var subgroups = [], subgroup, subnode, node; | |
if (typeof selector !== "function") selector = d3_selection_selector(selector); | |
for (var j = -1, m = this.length; ++j < m; ) { | |
subgroups.push(subgroup = []); | |
for (var group = this[j], i = -1, n = group.length; ++i < n; ) { | |
if ((node = group[i]) && (subnode = selector.call(node.node, node.node.__data__, i))) { | |
if ("__data__" in node.node) subnode.__data__ = node.node.__data__; | |
subgroup.push({ | |
node: subnode, | |
delay: node.delay, | |
duration: node.duration | |
}); | |
} else { | |
subgroup.push(null); | |
} | |
} | |
} | |
return d3_transition(subgroups, this.id, this.time).ease(this.ease()); | |
}; | |
d3_transitionPrototype.selectAll = function(selector) { | |
var subgroups = [], subgroup, subnodes, node; | |
if (typeof selector !== "function") selector = d3_selection_selectorAll(selector); | |
for (var j = -1, m = this.length; ++j < m; ) { | |
for (var group = this[j], i = -1, n = group.length; ++i < n; ) { | |
if (node = group[i]) { | |
subnodes = selector.call(node.node, node.node.__data__, i); | |
subgroups.push(subgroup = []); | |
for (var k = -1, o = subnodes.length; ++k < o; ) { | |
subgroup.push({ | |
node: subnodes[k], | |
delay: node.delay, | |
duration: node.duration | |
}); | |
} | |
} | |
} | |
} | |
return d3_transition(subgroups, this.id, this.time).ease(this.ease()); | |
}; | |
d3_transitionPrototype.filter = function(filter) { | |
var subgroups = [], subgroup, group, node; | |
if (typeof filter !== "function") filter = d3_selection_filter(filter); | |
for (var j = 0, m = this.length; j < m; j++) { | |
subgroups.push(subgroup = []); | |
for (var group = this[j], i = 0, n = group.length; i < n; i++) { | |
if ((node = group[i]) && filter.call(node.node, node.node.__data__, i)) { | |
subgroup.push(node); | |
} | |
} | |
} | |
return d3_transition(subgroups, this.id, this.time).ease(this.ease()); | |
}; | |
d3_transitionPrototype.attr = function(name, value) { | |
if (arguments.length < 2) { | |
for (value in name) this.attrTween(value, d3_tweenByName(name[value], value)); | |
return this; | |
} | |
return this.attrTween(name, d3_tweenByName(value, name)); | |
}; | |
d3_transitionPrototype.attrTween = function(nameNS, tween) { | |
function attrTween(d, i) { | |
var f = tween.call(this, d, i, this.getAttribute(name)); | |
return f === d3_tweenRemove ? (this.removeAttribute(name), null) : f && function(t) { | |
this.setAttribute(name, f(t)); | |
}; | |
} | |
function attrTweenNS(d, i) { | |
var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); | |
return f === d3_tweenRemove ? (this.removeAttributeNS(name.space, name.local), null) : f && function(t) { | |
this.setAttributeNS(name.space, name.local, f(t)); | |
}; | |
} | |
var name = d3.ns.qualify(nameNS); | |
return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); | |
}; | |
d3_transitionPrototype.style = function(name, value, priority) { | |
var n = arguments.length; | |
if (n < 3) { | |
if (typeof name !== "string") { | |
if (n < 2) value = ""; | |
for (priority in name) this.styleTween(priority, d3_tweenByName(name[priority], priority), value); | |
return this; | |
} | |
priority = ""; | |
} | |
return this.styleTween(name, d3_tweenByName(value, name), priority); | |
}; | |
d3_transitionPrototype.styleTween = function(name, tween, priority) { | |
if (arguments.length < 3) priority = ""; | |
return this.tween("style." + name, function(d, i) { | |
var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name)); | |
return f === d3_tweenRemove ? (this.style.removeProperty(name), null) : f && function(t) { | |
this.style.setProperty(name, f(t), priority); | |
}; | |
}); | |
}; | |
d3_transitionPrototype.text = function(value) { | |
return this.tween("text", function(d, i) { | |
this.textContent = typeof value === "function" ? value.call(this, d, i) : value; | |
}); | |
}; | |
d3_transitionPrototype.remove = function() { | |
return this.each("end.transition", function() { | |
var p; | |
if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this); | |
}); | |
}; | |
d3_transitionPrototype.delay = function(value) { | |
return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { | |
node.delay = value.call(node = node.node, node.__data__, i, j) | 0; | |
} : (value = value | 0, function(node) { | |
node.delay = value; | |
})); | |
}; | |
d3_transitionPrototype.duration = function(value) { | |
return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { | |
node.duration = Math.max(1, value.call(node = node.node, node.__data__, i, j) | 0); | |
} : (value = Math.max(1, value | 0), function(node) { | |
node.duration = value; | |
})); | |
}; | |
d3_transitionPrototype.transition = function() { | |
return this.select(d3_this); | |
}; | |
d3.tween = function(b, interpolate) { | |
function tweenFunction(d, i, a) { | |
var v = b.call(this, d, i); | |
return v == null ? a != "" && d3_tweenRemove : a != v && interpolate(a, v); | |
} | |
function tweenString(d, i, a) { | |
return a != b && interpolate(a, b); | |
} | |
return typeof b === "function" ? tweenFunction : b == null ? d3_tweenNull : (b += "", tweenString); | |
}; | |
var d3_tweenRemove = {}; | |
var d3_timer_queue = null, d3_timer_interval, d3_timer_timeout; | |
d3.timer = function(callback, delay, then) { | |
var found = false, t0, t1 = d3_timer_queue; | |
if (arguments.length < 3) { | |
if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return; | |
then = Date.now(); | |
} | |
while (t1) { | |
if (t1.callback === callback) { | |
t1.then = then; | |
t1.delay = delay; | |
found = true; | |
break; | |
} | |
t0 = t1; | |
t1 = t1.next; | |
} | |
if (!found) d3_timer_queue = { | |
callback: callback, | |
then: then, | |
delay: delay, | |
next: d3_timer_queue | |
}; | |
if (!d3_timer_interval) { | |
d3_timer_timeout = clearTimeout(d3_timer_timeout); | |
d3_timer_interval = 1; | |
d3_timer_frame(d3_timer_step); | |
} | |
}; | |
d3.timer.flush = function() { | |
var elapsed, now = Date.now(), t1 = d3_timer_queue; | |
while (t1) { | |
elapsed = now - t1.then; | |
if (!t1.delay) t1.flush = t1.callback(elapsed); | |
t1 = t1.next; | |
} | |
d3_timer_flush(); | |
}; | |
var d3_timer_frame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) { | |
setTimeout(callback, 17); | |
}; | |
d3.mouse = function(container) { | |
return d3_mousePoint(container, d3_eventSource()); | |
}; | |
var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0; | |
d3.touches = function(container, touches) { | |
if (arguments.length < 2) touches = d3_eventSource().touches; | |
return touches ? d3_array(touches).map(function(touch) { | |
var point = d3_mousePoint(container, touch); | |
point.identifier = touch.identifier; | |
return point; | |
}) : []; | |
}; | |
d3.scale = {}; | |
d3.scale.linear = function() { | |
return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3.interpolate, false); | |
}; | |
d3.scale.log = function() { | |
return d3_scale_log(d3.scale.linear(), d3_scale_logp); | |
}; | |
var d3_scale_logFormat = d3.format(".0e"); | |
d3_scale_logp.pow = function(x) { | |
return Math.pow(10, x); | |
}; | |
d3_scale_logn.pow = function(x) { | |
return -Math.pow(10, -x); | |
}; | |
d3.scale.pow = function() { | |
return d3_scale_pow(d3.scale.linear(), 1); | |
}; | |
d3.scale.sqrt = function() { | |
return d3.scale.pow().exponent(.5); | |
}; | |
d3.scale.ordinal = function() { | |
return d3_scale_ordinal([], { | |
t: "range", | |
a: [ [] ] | |
}); | |
}; | |
d3.scale.category10 = function() { | |
return d3.scale.ordinal().range(d3_category10); | |
}; | |
d3.scale.category20 = function() { | |
return d3.scale.ordinal().range(d3_category20); | |
}; | |
d3.scale.category20b = function() { | |
return d3.scale.ordinal().range(d3_category20b); | |
}; | |
d3.scale.category20c = function() { | |
return d3.scale.ordinal().range(d3_category20c); | |
}; | |
var d3_category10 = [ "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf" ]; | |
var d3_category20 = [ "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5" ]; | |
var d3_category20b = [ "#393b79", "#5254a3", "#6b6ecf", "#9c9ede", "#637939", "#8ca252", "#b5cf6b", "#cedb9c", "#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94", "#843c39", "#ad494a", "#d6616b", "#e7969c", "#7b4173", "#a55194", "#ce6dbd", "#de9ed6" ]; | |
var d3_category20c = [ "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9" ]; | |
d3.scale.quantile = function() { | |
return d3_scale_quantile([], []); | |
}; | |
d3.scale.quantize = function() { | |
return d3_scale_quantize(0, 1, [ 0, 1 ]); | |
}; | |
d3.scale.threshold = function() { | |
return d3_scale_threshold([ .5 ], [ 0, 1 ]); | |
}; | |
d3.scale.identity = function() { | |
return d3_scale_identity([ 0, 1 ]); | |
}; | |
d3.svg = {}; | |
d3.svg.arc = function() { | |
function arc() { | |
var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0, a0 = a1, a1 = da), a1 - a0), df = da < Math.PI ? "0" : "1", c0 = Math.cos(a0), s0 = Math.sin(a0), c1 = Math.cos(a1), s1 = Math.sin(a1); | |
return da >= d3_svg_arcMax ? r0 ? "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "M0," + r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + -r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + r0 + "Z" : "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "Z" : r0 ? "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L" + r0 * c1 + "," + r0 * s1 + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 + "Z" : "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L0,0" + "Z"; | |
} | |
var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; | |
arc.innerRadius = function(v) { | |
if (!arguments.length) return innerRadius; | |
innerRadius = d3_functor(v); | |
return arc; | |
}; | |
arc.outerRadius = function(v) { | |
if (!arguments.length) return outerRadius; | |
outerRadius = d3_functor(v); | |
return arc; | |
}; | |
arc.startAngle = function(v) { | |
if (!arguments.length) return startAngle; | |
startAngle = d3_functor(v); | |
return arc; | |
}; | |
arc.endAngle = function(v) { | |
if (!arguments.length) return endAngle; | |
endAngle = d3_functor(v); | |
return arc; | |
}; | |
arc.centroid = function() { | |
var r = (innerRadius.apply(this, arguments) + outerRadius.apply(this, arguments)) / 2, a = (startAngle.apply(this, arguments) + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset; | |
return [ Math.cos(a) * r, Math.sin(a) * r ]; | |
}; | |
return arc; | |
}; | |
var d3_svg_arcOffset = -Math.PI / 2, d3_svg_arcMax = 2 * Math.PI - 1e-6; | |
d3.svg.line = function() { | |
return d3_svg_line(d3_identity); | |
}; | |
var d3_svg_lineInterpolators = d3.map({ | |
linear: d3_svg_lineLinear, | |
"linear-closed": d3_svg_lineLinearClosed, | |
"step-before": d3_svg_lineStepBefore, | |
"step-after": d3_svg_lineStepAfter, | |
basis: d3_svg_lineBasis, | |
"basis-open": d3_svg_lineBasisOpen, | |
"basis-closed": d3_svg_lineBasisClosed, | |
bundle: d3_svg_lineBundle, | |
cardinal: d3_svg_lineCardinal, | |
"cardinal-open": d3_svg_lineCardinalOpen, | |
"cardinal-closed": d3_svg_lineCardinalClosed, | |
monotone: d3_svg_lineMonotone | |
}); | |
d3_svg_lineInterpolators.forEach(function(key, value) { | |
value.key = key; | |
value.closed = /-closed$/.test(key); | |
}); | |
var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; | |
d3.svg.line.radial = function() { | |
var line = d3_svg_line(d3_svg_lineRadial); | |
line.radius = line.x, delete line.x; | |
line.angle = line.y, delete line.y; | |
return line; | |
}; | |
d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; | |
d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; | |
d3.svg.area = function() { | |
return d3_svg_area(d3_identity); | |
}; | |
d3.svg.area.radial = function() { | |
var area = d3_svg_area(d3_svg_lineRadial); | |
area.radius = area.x, delete area.x; | |
area.innerRadius = area.x0, delete area.x0; | |
area.outerRadius = area.x1, delete area.x1; | |
area.angle = area.y, delete area.y; | |
area.startAngle = area.y0, delete area.y0; | |
area.endAngle = area.y1, delete area.y1; | |
return area; | |
}; | |
d3.svg.chord = function() { | |
function chord(d, i) { | |
var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); | |
return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; | |
} | |
function subgroup(self, f, d, i) { | |
var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset, a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset; | |
return { | |
r: r, | |
a0: a0, | |
a1: a1, | |
p0: [ r * Math.cos(a0), r * Math.sin(a0) ], | |
p1: [ r * Math.cos(a1), r * Math.sin(a1) ] | |
}; | |
} | |
function equals(a, b) { | |
return a.a0 == b.a0 && a.a1 == b.a1; | |
} | |
function arc(r, p, a) { | |
return "A" + r + "," + r + " 0 " + +(a > Math.PI) + ",1 " + p; | |
} | |
function curve(r0, p0, r1, p1) { | |
return "Q 0,0 " + p1; | |
} | |
var source = d3_svg_chordSource, target = d3_svg_chordTarget, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; | |
chord.radius = function(v) { | |
if (!arguments.length) return radius; | |
radius = d3_functor(v); | |
return chord; | |
}; | |
chord.source = function(v) { | |
if (!arguments.length) return source; | |
source = d3_functor(v); | |
return chord; | |
}; | |
chord.target = function(v) { | |
if (!arguments.length) return target; | |
target = d3_functor(v); | |
return chord; | |
}; | |
chord.startAngle = function(v) { | |
if (!arguments.length) return startAngle; | |
startAngle = d3_functor(v); | |
return chord; | |
}; | |
chord.endAngle = function(v) { | |
if (!arguments.length) return endAngle; | |
endAngle = d3_functor(v); | |
return chord; | |
}; | |
return chord; | |
}; | |
d3.svg.diagonal = function() { | |
function diagonal(d, i) { | |
var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { | |
x: p0.x, | |
y: m | |
}, { | |
x: p3.x, | |
y: m | |
}, p3 ]; | |
p = p.map(projection); | |
return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; | |
} | |
var source = d3_svg_chordSource, target = d3_svg_chordTarget, projection = d3_svg_diagonalProjection; | |
diagonal.source = function(x) { | |
if (!arguments.length) return source; | |
source = d3_functor(x); | |
return diagonal; | |
}; | |
diagonal.target = function(x) { | |
if (!arguments.length) return target; | |
target = d3_functor(x); | |
return diagonal; | |
}; | |
diagonal.projection = function(x) { | |
if (!arguments.length) return projection; | |
projection = x; | |
return diagonal; | |
}; | |
return diagonal; | |
}; | |
d3.svg.diagonal.radial = function() { | |
var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; | |
diagonal.projection = function(x) { | |
return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; | |
}; | |
return diagonal; | |
}; | |
d3.svg.mouse = d3.mouse; | |
d3.svg.touches = d3.touches; | |
d3.svg.symbol = function() { | |
function symbol(d, i) { | |
return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); | |
} | |
var type = d3_svg_symbolType, size = d3_svg_symbolSize; | |
symbol.type = function(x) { | |
if (!arguments.length) return type; | |
type = d3_functor(x); | |
return symbol; | |
}; | |
symbol.size = function(x) { | |
if (!arguments.length) return size; | |
size = d3_functor(x); | |
return symbol; | |
}; | |
return symbol; | |
}; | |
var d3_svg_symbols = d3.map({ | |
circle: d3_svg_symbolCircle, | |
cross: function(size) { | |
var r = Math.sqrt(size / 5) / 2; | |
return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; | |
}, | |
diamond: function(size) { | |
var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; | |
return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; | |
}, | |
square: function(size) { | |
var r = Math.sqrt(size) / 2; | |
return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; | |
}, | |
"triangle-down": function(size) { | |
var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; | |
return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; | |
}, | |
"triangle-up": function(size) { | |
var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; | |
return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; | |
} | |
}); | |
d3.svg.symbolTypes = d3_svg_symbols.keys(); | |
var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * Math.PI / 180); | |
d3.svg.axis = function() { | |
function axis(g) { | |
g.each(function() { | |
var g = d3.select(this); | |
var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String : tickFormat_; | |
var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", "g").attr("class", "tick minor").style("opacity", 1e-6), subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(), subtickUpdate = d3.transition(subtick).style("opacity", 1); | |
var tick = g.selectAll("g").data(ticks, String), tickEnter = tick.enter().insert("g", "path").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform; | |
var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathEnter = path.enter().append("path").attr("class", "domain"), pathUpdate = d3.transition(path); | |
var scale1 = scale.copy(), scale0 = this.__chart__ || scale1; | |
this.__chart__ = scale1; | |
tickEnter.append("line").attr("class", "tick"); | |
tickEnter.append("text"); | |
var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); | |
switch (orient) { | |
case "bottom": | |
{ | |
tickTransform = d3_svg_axisX; | |
subtickEnter.attr("y2", tickMinorSize); | |
subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize); | |
lineEnter.attr("y2", tickMajorSize); | |
textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding); | |
lineUpdate.attr("x2", 0).attr("y2", tickMajorSize); | |
textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding); | |
text.attr("dy", ".71em").attr("text-anchor", "middle"); | |
pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize); | |
break; | |
} | |
case "top": | |
{ | |
tickTransform = d3_svg_axisX; | |
subtickEnter.attr("y2", -tickMinorSize); | |
subtickUpdate.attr("x2", 0).attr("y2", -tickMinorSize); | |
lineEnter.attr("y2", -tickMajorSize); | |
textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); | |
lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize); | |
textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); | |
text.attr("dy", "0em").attr("text-anchor", "middle"); | |
pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize); | |
break; | |
} | |
case "left": | |
{ | |
tickTransform = d3_svg_axisY; | |
subtickEnter.attr("x2", -tickMinorSize); | |
subtickUpdate.attr("x2", -tickMinorSize).attr("y2", 0); | |
lineEnter.attr("x2", -tickMajorSize); | |
textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)); | |
lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0); | |
textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0); | |
text.attr("dy", ".32em").attr("text-anchor", "end"); | |
pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize); | |
break; | |
} | |
case "right": | |
{ | |
tickTransform = d3_svg_axisY; | |
subtickEnter.attr("x2", tickMinorSize); | |
subtickUpdate.attr("x2", tickMinorSize).attr("y2", 0); | |
lineEnter.attr("x2", tickMajorSize); | |
textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding); | |
lineUpdate.attr("x2", tickMajorSize).attr("y2", 0); | |
textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0); | |
text.attr("dy", ".32em").attr("text-anchor", "start"); | |
pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize); | |
break; | |
} | |
} | |
if (scale.ticks) { | |
tickEnter.call(tickTransform, scale0); | |
tickUpdate.call(tickTransform, scale1); | |
tickExit.call(tickTransform, scale1); | |
subtickEnter.call(tickTransform, scale0); | |
subtickUpdate.call(tickTransform, scale1); | |
subtickExit.call(tickTransform, scale1); | |
} else { | |
var dx = scale1.rangeBand() / 2, x = function(d) { | |
return scale1(d) + dx; | |
}; | |
tickEnter.call(tickTransform, x); | |
tickUpdate.call(tickTransform, x); | |
} | |
}); | |
} | |
var scale = d3.scale.linear(), orient = "bottom", tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0; | |
axis.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = x; | |
return axis; | |
}; | |
axis.orient = function(x) { | |
if (!arguments.length) return orient; | |
orient = x; | |
return axis; | |
}; | |
axis.ticks = function() { | |
if (!arguments.length) return tickArguments_; | |
tickArguments_ = arguments; | |
return axis; | |
}; | |
axis.tickValues = function(x) { | |
if (!arguments.length) return tickValues; | |
tickValues = x; | |
return axis; | |
}; | |
axis.tickFormat = function(x) { | |
if (!arguments.length) return tickFormat_; | |
tickFormat_ = x; | |
return axis; | |
}; | |
axis.tickSize = function(x, y, z) { | |
if (!arguments.length) return tickMajorSize; | |
var n = arguments.length - 1; | |
tickMajorSize = +x; | |
tickMinorSize = n > 1 ? +y : tickMajorSize; | |
tickEndSize = n > 0 ? +arguments[n] : tickMajorSize; | |
return axis; | |
}; | |
axis.tickPadding = function(x) { | |
if (!arguments.length) return tickPadding; | |
tickPadding = +x; | |
return axis; | |
}; | |
axis.tickSubdivide = function(x) { | |
if (!arguments.length) return tickSubdivide; | |
tickSubdivide = +x; | |
return axis; | |
}; | |
return axis; | |
}; | |
d3.svg.brush = function() { | |
function brush(g) { | |
g.each(function() { | |
var g = d3.select(this), bg = g.selectAll(".background").data([ 0 ]), fg = g.selectAll(".extent").data([ 0 ]), tz = g.selectAll(".resize").data(resizes, String), e; | |
g.style("pointer-events", "all").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); | |
bg.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); | |
fg.enter().append("rect").attr("class", "extent").style("cursor", "move"); | |
tz.enter().append("g").attr("class", function(d) { | |
return "resize " + d; | |
}).style("cursor", function(d) { | |
return d3_svg_brushCursor[d]; | |
}).append("rect").attr("x", function(d) { | |
return /[ew]$/.test(d) ? -3 : null; | |
}).attr("y", function(d) { | |
return /^[ns]/.test(d) ? -3 : null; | |
}).attr("width", 6).attr("height", 6).style("visibility", "hidden"); | |
tz.style("display", brush.empty() ? "none" : null); | |
tz.exit().remove(); | |
if (x) { | |
e = d3_scaleRange(x); | |
bg.attr("x", e[0]).attr("width", e[1] - e[0]); | |
redrawX(g); | |
} | |
if (y) { | |
e = d3_scaleRange(y); | |
bg.attr("y", e[0]).attr("height", e[1] - e[0]); | |
redrawY(g); | |
} | |
redraw(g); | |
}); | |
} | |
function redraw(g) { | |
g.selectAll(".resize").attr("transform", function(d) { | |
return "translate(" + extent[+/e$/.test(d)][0] + "," + extent[+/^s/.test(d)][1] + ")"; | |
}); | |
} | |
function redrawX(g) { | |
g.select(".extent").attr("x", extent[0][0]); | |
g.selectAll(".extent,.n>rect,.s>rect").attr("width", extent[1][0] - extent[0][0]); | |
} | |
function redrawY(g) { | |
g.select(".extent").attr("y", extent[0][1]); | |
g.selectAll(".extent,.e>rect,.w>rect").attr("height", extent[1][1] - extent[0][1]); | |
} | |
function brushstart() { | |
function mouse() { | |
var touches = d3.event.changedTouches; | |
return touches ? d3.touches(target, touches)[0] : d3.mouse(target); | |
} | |
function keydown() { | |
if (d3.event.keyCode == 32) { | |
if (!dragging) { | |
center = null; | |
origin[0] -= extent[1][0]; | |
origin[1] -= extent[1][1]; | |
dragging = 2; | |
} | |
d3_eventCancel(); | |
} | |
} | |
function keyup() { | |
if (d3.event.keyCode == 32 && dragging == 2) { | |
origin[0] += extent[1][0]; | |
origin[1] += extent[1][1]; | |
dragging = 0; | |
d3_eventCancel(); | |
} | |
} | |
function brushmove() { | |
var point = mouse(), moved = false; | |
if (offset) { | |
point[0] += offset[0]; | |
point[1] += offset[1]; | |
} | |
if (!dragging) { | |
if (d3.event.altKey) { | |
if (!center) center = [ (extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2 ]; | |
origin[0] = extent[+(point[0] < center[0])][0]; | |
origin[1] = extent[+(point[1] < center[1])][1]; | |
} else center = null; | |
} | |
if (resizingX && move1(point, x, 0)) { | |
redrawX(g); | |
moved = true; | |
} | |
if (resizingY && move1(point, y, 1)) { | |
redrawY(g); | |
moved = true; | |
} | |
if (moved) { | |
redraw(g); | |
event_({ | |
type: "brush", | |
mode: dragging ? "move" : "resize" | |
}); | |
} | |
} | |
function move1(point, scale, i) { | |
var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], size = extent[1][i] - extent[0][i], min, max; | |
if (dragging) { | |
r0 -= position; | |
r1 -= size + position; | |
} | |
min = Math.max(r0, Math.min(r1, point[i])); | |
if (dragging) { | |
max = (min += position) + size; | |
} else { | |
if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); | |
if (position < min) { | |
max = min; | |
min = position; | |
} else { | |
max = position; | |
} | |
} | |
if (extent[0][i] !== min || extent[1][i] !== max) { | |
extentDomain = null; | |
extent[0][i] = min; | |
extent[1][i] = max; | |
return true; | |
} | |
} | |
function brushend() { | |
brushmove(); | |
g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null); | |
d3.select("body").style("cursor", null); | |
w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null); | |
event_({ | |
type: "brushend" | |
}); | |
d3_eventCancel(); | |
} | |
var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), center, origin = mouse(), offset; | |
var w = d3.select(window).on("mousemove.brush", brushmove).on("mouseup.brush", brushend).on("touchmove.brush", brushmove).on("touchend.brush", brushend).on("keydown.brush", keydown).on("keyup.brush", keyup); | |
if (dragging) { | |
origin[0] = extent[0][0] - origin[0]; | |
origin[1] = extent[0][1] - origin[1]; | |
} else if (resizing) { | |
var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing); | |
offset = [ extent[1 - ex][0] - origin[0], extent[1 - ey][1] - origin[1] ]; | |
origin[0] = extent[ex][0]; | |
origin[1] = extent[ey][1]; | |
} else if (d3.event.altKey) center = origin.slice(); | |
g.style("pointer-events", "none").selectAll(".resize").style("display", null); | |
d3.select("body").style("cursor", eventTarget.style("cursor")); | |
event_({ | |
type: "brushstart" | |
}); | |
brushmove(); | |
d3_eventCancel(); | |
} | |
var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, resizes = d3_svg_brushResizes[0], extent = [ [ 0, 0 ], [ 0, 0 ] ], extentDomain; | |
brush.x = function(z) { | |
if (!arguments.length) return x; | |
x = z; | |
resizes = d3_svg_brushResizes[!x << 1 | !y]; | |
return brush; | |
}; | |
brush.y = function(z) { | |
if (!arguments.length) return y; | |
y = z; | |
resizes = d3_svg_brushResizes[!x << 1 | !y]; | |
return brush; | |
}; | |
brush.extent = function(z) { | |
var x0, x1, y0, y1, t; | |
if (!arguments.length) { | |
z = extentDomain || extent; | |
if (x) { | |
x0 = z[0][0], x1 = z[1][0]; | |
if (!extentDomain) { | |
x0 = extent[0][0], x1 = extent[1][0]; | |
if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1); | |
if (x1 < x0) t = x0, x0 = x1, x1 = t; | |
} | |
} | |
if (y) { | |
y0 = z[0][1], y1 = z[1][1]; | |
if (!extentDomain) { | |
y0 = extent[0][1], y1 = extent[1][1]; | |
if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1); | |
if (y1 < y0) t = y0, y0 = y1, y1 = t; | |
} | |
} | |
return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ]; | |
} | |
extentDomain = [ [ 0, 0 ], [ 0, 0 ] ]; | |
if (x) { | |
x0 = z[0], x1 = z[1]; | |
if (y) x0 = x0[0], x1 = x1[0]; | |
extentDomain[0][0] = x0, extentDomain[1][0] = x1; | |
if (x.invert) x0 = x(x0), x1 = x(x1); | |
if (x1 < x0) t = x0, x0 = x1, x1 = t; | |
extent[0][0] = x0 | 0, extent[1][0] = x1 | 0; | |
} | |
if (y) { | |
y0 = z[0], y1 = z[1]; | |
if (x) y0 = y0[1], y1 = y1[1]; | |
extentDomain[0][1] = y0, extentDomain[1][1] = y1; | |
if (y.invert) y0 = y(y0), y1 = y(y1); | |
if (y1 < y0) t = y0, y0 = y1, y1 = t; | |
extent[0][1] = y0 | 0, extent[1][1] = y1 | 0; | |
} | |
return brush; | |
}; | |
brush.clear = function() { | |
extentDomain = null; | |
extent[0][0] = extent[0][1] = extent[1][0] = extent[1][1] = 0; | |
return brush; | |
}; | |
brush.empty = function() { | |
return x && extent[0][0] === extent[1][0] || y && extent[0][1] === extent[1][1]; | |
}; | |
return d3.rebind(brush, event, "on"); | |
}; | |
var d3_svg_brushCursor = { | |
n: "ns-resize", | |
e: "ew-resize", | |
s: "ns-resize", | |
w: "ew-resize", | |
nw: "nwse-resize", | |
ne: "nesw-resize", | |
se: "nwse-resize", | |
sw: "nesw-resize" | |
}; | |
var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; | |
d3.behavior = {}; | |
d3.behavior.drag = function() { | |
function drag() { | |
this.on("mousedown.drag", mousedown).on("touchstart.drag", mousedown); | |
} | |
function mousedown() { | |
function point() { | |
var p = target.parentNode; | |
return touchId ? d3.touches(p).filter(function(p) { | |
return p.identifier === touchId; | |
})[0] : d3.mouse(p); | |
} | |
function dragmove() { | |
if (!target.parentNode) return dragend(); | |
var p = point(), dx = p[0] - origin_[0], dy = p[1] - origin_[1]; | |
moved |= dx | dy; | |
origin_ = p; | |
d3_eventCancel(); | |
event_({ | |
type: "drag", | |
x: p[0] + offset[0], | |
y: p[1] + offset[1], | |
dx: dx, | |
dy: dy | |
}); | |
} | |
function dragend() { | |
event_({ | |
type: "dragend" | |
}); | |
if (moved) { | |
d3_eventCancel(); | |
if (d3.event.target === eventTarget) w.on("click.drag", click, true); | |
} | |
w.on(touchId ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId ? "touchend.drag-" + touchId : "mouseup.drag", null); | |
} | |
function click() { | |
d3_eventCancel(); | |
w.on("click.drag", null); | |
} | |
var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, touchId = d3.event.touches && d3.event.changedTouches[0].identifier, offset, origin_ = point(), moved = 0; | |
var w = d3.select(window).on(touchId ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true); | |
if (origin) { | |
offset = origin.apply(target, arguments); | |
offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; | |
} else { | |
offset = [ 0, 0 ]; | |
} | |
if (!touchId) d3_eventCancel(); | |
event_({ | |
type: "dragstart" | |
}); | |
} | |
var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null; | |
drag.origin = function(x) { | |
if (!arguments.length) return origin; | |
origin = x; | |
return drag; | |
}; | |
return d3.rebind(drag, event, "on"); | |
}; | |
d3.behavior.zoom = function() { | |
function zoom() { | |
this.on("mousedown.zoom", mousedown).on("mousewheel.zoom", mousewheel).on("mousemove.zoom", mousemove).on("DOMMouseScroll.zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart); | |
} | |
function location(p) { | |
return [ (p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale ]; | |
} | |
function point(l) { | |
return [ l[0] * scale + translate[0], l[1] * scale + translate[1] ]; | |
} | |
function scaleTo(s) { | |
scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); | |
} | |
function translateTo(p, l) { | |
l = point(l); | |
translate[0] += p[0] - l[0]; | |
translate[1] += p[1] - l[1]; | |
} | |
function dispatch(event) { | |
if (x1) x1.domain(x0.range().map(function(x) { | |
return (x - translate[0]) / scale; | |
}).map(x0.invert)); | |
if (y1) y1.domain(y0.range().map(function(y) { | |
return (y - translate[1]) / scale; | |
}).map(y0.invert)); | |
d3.event.preventDefault(); | |
event({ | |
type: "zoom", | |
scale: scale, | |
translate: translate | |
}); | |
} | |
function mousedown() { | |
function mousemove() { | |
moved = 1; | |
translateTo(d3.mouse(target), l); | |
dispatch(event_); | |
} | |
function mouseup() { | |
if (moved) d3_eventCancel(); | |
w.on("mousemove.zoom", null).on("mouseup.zoom", null); | |
if (moved && d3.event.target === eventTarget) w.on("click.zoom", click, true); | |
} | |
function click() { | |
d3_eventCancel(); | |
w.on("click.zoom", null); | |
} | |
var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target)); | |
window.focus(); | |
d3_eventCancel(); | |
} | |
function mousewheel() { | |
if (!translate0) translate0 = location(d3.mouse(this)); | |
scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale); | |
translateTo(d3.mouse(this), translate0); | |
dispatch(event.of(this, arguments)); | |
} | |
function mousemove() { | |
translate0 = null; | |
} | |
function dblclick() { | |
var p = d3.mouse(this), l = location(p); | |
scaleTo(d3.event.shiftKey ? scale / 2 : scale * 2); | |
translateTo(p, l); | |
dispatch(event.of(this, arguments)); | |
} | |
function touchstart() { | |
var touches = d3.touches(this), now = Date.now(); | |
scale0 = scale; | |
translate0 = {}; | |
touches.forEach(function(t) { | |
translate0[t.identifier] = location(t); | |
}); | |
d3_eventCancel(); | |
if (touches.length === 1) { | |
if (now - touchtime < 500) { | |
var p = touches[0], l = location(touches[0]); | |
scaleTo(scale * 2); | |
translateTo(p, l); | |
dispatch(event.of(this, arguments)); | |
} | |
touchtime = now; | |
} | |
} | |
function touchmove() { | |
var touches = d3.touches(this), p0 = touches[0], l0 = translate0[p0.identifier]; | |
if (p1 = touches[1]) { | |
var p1, l1 = translate0[p1.identifier]; | |
p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; | |
l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; | |
scaleTo(d3.event.scale * scale0); | |
} | |
translateTo(p0, l0); | |
touchtime = null; | |
dispatch(event.of(this, arguments)); | |
} | |
var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime; | |
zoom.translate = function(x) { | |
if (!arguments.length) return translate; | |
translate = x.map(Number); | |
return zoom; | |
}; | |
zoom.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = +x; | |
return zoom; | |
}; | |
zoom.scaleExtent = function(x) { | |
if (!arguments.length) return scaleExtent; | |
scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number); | |
return zoom; | |
}; | |
zoom.x = function(z) { | |
if (!arguments.length) return x1; | |
x1 = z; | |
x0 = z.copy(); | |
return zoom; | |
}; | |
zoom.y = function(z) { | |
if (!arguments.length) return y1; | |
y1 = z; | |
y0 = z.copy(); | |
return zoom; | |
}; | |
return d3.rebind(zoom, event, "on"); | |
}; | |
var d3_behavior_zoomDiv, d3_behavior_zoomInfinity = [ 0, Infinity ]; | |
d3.layout = {}; | |
d3.layout.bundle = function() { | |
return function(links) { | |
var paths = [], i = -1, n = links.length; | |
while (++i < n) paths.push(d3_layout_bundlePath(links[i])); | |
return paths; | |
}; | |
}; | |
d3.layout.chord = function() { | |
function relayout() { | |
var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; | |
chords = []; | |
groups = []; | |
k = 0, i = -1; | |
while (++i < n) { | |
x = 0, j = -1; | |
while (++j < n) { | |
x += matrix[i][j]; | |
} | |
groupSums.push(x); | |
subgroupIndex.push(d3.range(n)); | |
k += x; | |
} | |
if (sortGroups) { | |
groupIndex.sort(function(a, b) { | |
return sortGroups(groupSums[a], groupSums[b]); | |
}); | |
} | |
if (sortSubgroups) { | |
subgroupIndex.forEach(function(d, i) { | |
d.sort(function(a, b) { | |
return sortSubgroups(matrix[i][a], matrix[i][b]); | |
}); | |
}); | |
} | |
k = (2 * Math.PI - padding * n) / k; | |
x = 0, i = -1; | |
while (++i < n) { | |
x0 = x, j = -1; | |
while (++j < n) { | |
var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; | |
subgroups[di + "-" + dj] = { | |
index: di, | |
subindex: dj, | |
startAngle: a0, | |
endAngle: a1, | |
value: v | |
}; | |
} | |
groups[di] = { | |
index: di, | |
startAngle: x0, | |
endAngle: x, | |
value: (x - x0) / k | |
}; | |
x += padding; | |
} | |
i = -1; | |
while (++i < n) { | |
j = i - 1; | |
while (++j < n) { | |
var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; | |
if (source.value || target.value) { | |
chords.push(source.value < target.value ? { | |
source: target, | |
target: source | |
} : { | |
source: source, | |
target: target | |
}); | |
} | |
} | |
} | |
if (sortChords) resort(); | |
} | |
function resort() { | |
chords.sort(function(a, b) { | |
return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); | |
}); | |
} | |
var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; | |
chord.matrix = function(x) { | |
if (!arguments.length) return matrix; | |
n = (matrix = x) && matrix.length; | |
chords = groups = null; | |
return chord; | |
}; | |
chord.padding = function(x) { | |
if (!arguments.length) return padding; | |
padding = x; | |
chords = groups = null; | |
return chord; | |
}; | |
chord.sortGroups = function(x) { | |
if (!arguments.length) return sortGroups; | |
sortGroups = x; | |
chords = groups = null; | |
return chord; | |
}; | |
chord.sortSubgroups = function(x) { | |
if (!arguments.length) return sortSubgroups; | |
sortSubgroups = x; | |
chords = null; | |
return chord; | |
}; | |
chord.sortChords = function(x) { | |
if (!arguments.length) return sortChords; | |
sortChords = x; | |
if (chords) resort(); | |
return chord; | |
}; | |
chord.chords = function() { | |
if (!chords) relayout(); | |
return chords; | |
}; | |
chord.groups = function() { | |
if (!groups) relayout(); | |
return groups; | |
}; | |
return chord; | |
}; | |
d3.layout.force = function() { | |
function repulse(node) { | |
return function(quad, x1, y1, x2, y2) { | |
if (quad.point !== node) { | |
var dx = quad.cx - node.x, dy = quad.cy - node.y, dn = 1 / Math.sqrt(dx * dx + dy * dy); | |
if ((x2 - x1) * dn < theta) { | |
var k = quad.charge * dn * dn; | |
node.px -= dx * k; | |
node.py -= dy * k; | |
return true; | |
} | |
if (quad.point && isFinite(dn)) { | |
var k = quad.pointCharge * dn * dn; | |
node.px -= dx * k; | |
node.py -= dy * k; | |
} | |
} | |
return !quad.charge; | |
}; | |
} | |
function dragmove(d) { | |
d.px = d3.event.x; | |
d.py = d3.event.y; | |
force.resume(); | |
} | |
var force = {}, event = d3.dispatch("start", "tick", "end"), size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, gravity = .1, theta = .8, interval, nodes = [], links = [], distances, strengths, charges; | |
force.tick = function() { | |
if ((alpha *= .99) < .005) { | |
event.end({ | |
type: "end", | |
alpha: alpha = 0 | |
}); | |
return true; | |
} | |
var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; | |
for (i = 0; i < m; ++i) { | |
o = links[i]; | |
s = o.source; | |
t = o.target; | |
x = t.x - s.x; | |
y = t.y - s.y; | |
if (l = x * x + y * y) { | |
l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; | |
x *= l; | |
y *= l; | |
t.x -= x * (k = s.weight / (t.weight + s.weight)); | |
t.y -= y * k; | |
s.x += x * (k = 1 - k); | |
s.y += y * k; | |
} | |
} | |
if (k = alpha * gravity) { | |
x = size[0] / 2; | |
y = size[1] / 2; | |
i = -1; | |
if (k) while (++i < n) { | |
o = nodes[i]; | |
o.x += (x - o.x) * k; | |
o.y += (y - o.y) * k; | |
} | |
} | |
if (charge) { | |
d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); | |
i = -1; | |
while (++i < n) { | |
if (!(o = nodes[i]).fixed) { | |
q.visit(repulse(o)); | |
} | |
} | |
} | |
i = -1; | |
while (++i < n) { | |
o = nodes[i]; | |
if (o.fixed) { | |
o.x = o.px; | |
o.y = o.py; | |
} else { | |
o.x -= (o.px - (o.px = o.x)) * friction; | |
o.y -= (o.py - (o.py = o.y)) * friction; | |
} | |
} | |
event.tick({ | |
type: "tick", | |
alpha: alpha | |
}); | |
}; | |
force.nodes = function(x) { | |
if (!arguments.length) return nodes; | |
nodes = x; | |
return force; | |
}; | |
force.links = function(x) { | |
if (!arguments.length) return links; | |
links = x; | |
return force; | |
}; | |
force.size = function(x) { | |
if (!arguments.length) return size; | |
size = x; | |
return force; | |
}; | |
force.linkDistance = function(x) { | |
if (!arguments.length) return linkDistance; | |
linkDistance = d3_functor(x); | |
return force; | |
}; | |
force.distance = force.linkDistance; | |
force.linkStrength = function(x) { | |
if (!arguments.length) return linkStrength; | |
linkStrength = d3_functor(x); | |
return force; | |
}; | |
force.friction = function(x) { | |
if (!arguments.length) return friction; | |
friction = x; | |
return force; | |
}; | |
force.charge = function(x) { | |
if (!arguments.length) return charge; | |
charge = typeof x === "function" ? x : +x; | |
return force; | |
}; | |
force.gravity = function(x) { | |
if (!arguments.length) return gravity; | |
gravity = x; | |
return force; | |
}; | |
force.theta = function(x) { | |
if (!arguments.length) return theta; | |
theta = x; | |
return force; | |
}; | |
force.alpha = function(x) { | |
if (!arguments.length) return alpha; | |
if (alpha) { | |
if (x > 0) alpha = x; else alpha = 0; | |
} else if (x > 0) { | |
event.start({ | |
type: "start", | |
alpha: alpha = x | |
}); | |
d3.timer(force.tick); | |
} | |
return force; | |
}; | |
force.start = function() { | |
function position(dimension, size) { | |
var neighbors = neighbor(i), j = -1, m = neighbors.length, x; | |
while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x; | |
return Math.random() * size; | |
} | |
function neighbor() { | |
if (!neighbors) { | |
neighbors = []; | |
for (j = 0; j < n; ++j) { | |
neighbors[j] = []; | |
} | |
for (j = 0; j < m; ++j) { | |
var o = links[j]; | |
neighbors[o.source.index].push(o.target); | |
neighbors[o.target.index].push(o.source); | |
} | |
} | |
return neighbors[i]; | |
} | |
var i, j, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; | |
for (i = 0; i < n; ++i) { | |
(o = nodes[i]).index = i; | |
o.weight = 0; | |
} | |
distances = []; | |
strengths = []; | |
for (i = 0; i < m; ++i) { | |
o = links[i]; | |
if (typeof o.source == "number") o.source = nodes[o.source]; | |
if (typeof o.target == "number") o.target = nodes[o.target]; | |
distances[i] = linkDistance.call(this, o, i); | |
strengths[i] = linkStrength.call(this, o, i); | |
++o.source.weight; | |
++o.target.weight; | |
} | |
for (i = 0; i < n; ++i) { | |
o = nodes[i]; | |
if (isNaN(o.x)) o.x = position("x", w); | |
if (isNaN(o.y)) o.y = position("y", h); | |
if (isNaN(o.px)) o.px = o.x; | |
if (isNaN(o.py)) o.py = o.y; | |
} | |
charges = []; | |
if (typeof charge === "function") { | |
for (i = 0; i < n; ++i) { | |
charges[i] = +charge.call(this, nodes[i], i); | |
} | |
} else { | |
for (i = 0; i < n; ++i) { | |
charges[i] = charge; | |
} | |
} | |
return force.resume(); | |
}; | |
force.resume = function() { | |
return force.alpha(.1); | |
}; | |
force.stop = function() { | |
return force.alpha(0); | |
}; | |
force.drag = function() { | |
if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart", d3_layout_forceDragstart).on("drag", dragmove).on("dragend", d3_layout_forceDragend); | |
this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); | |
}; | |
return d3.rebind(force, event, "on"); | |
}; | |
d3.layout.partition = function() { | |
function position(node, x, dx, dy) { | |
var children = node.children; | |
node.x = x; | |
node.y = node.depth * dy; | |
node.dx = dx; | |
node.dy = dy; | |
if (children && (n = children.length)) { | |
var i = -1, n, c, d; | |
dx = node.value ? dx / node.value : 0; | |
while (++i < n) { | |
position(c = children[i], x, d = c.value * dx, dy); | |
x += d; | |
} | |
} | |
} | |
function depth(node) { | |
var children = node.children, d = 0; | |
if (children && (n = children.length)) { | |
var i = -1, n; | |
while (++i < n) d = Math.max(d, depth(children[i])); | |
} | |
return 1 + d; | |
} | |
function partition(d, i) { | |
var nodes = hierarchy.call(this, d, i); | |
position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); | |
return nodes; | |
} | |
var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; | |
partition.size = function(x) { | |
if (!arguments.length) return size; | |
size = x; | |
return partition; | |
}; | |
return d3_layout_hierarchyRebind(partition, hierarchy); | |
}; | |
d3.layout.pie = function() { | |
function pie(data, i) { | |
var values = data.map(function(d, i) { | |
return +value.call(pie, d, i); | |
}); | |
var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); | |
var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - startAngle) / d3.sum(values); | |
var index = d3.range(data.length); | |
if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { | |
return values[j] - values[i]; | |
} : function(i, j) { | |
return sort(data[i], data[j]); | |
}); | |
var arcs = []; | |
index.forEach(function(i) { | |
var d; | |
arcs[i] = { | |
data: data[i], | |
value: d = values[i], | |
startAngle: a, | |
endAngle: a += d * k | |
}; | |
}); | |
return arcs; | |
} | |
var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = 2 * Math.PI; | |
pie.value = function(x) { | |
if (!arguments.length) return value; | |
value = x; | |
return pie; | |
}; | |
pie.sort = function(x) { | |
if (!arguments.length) return sort; | |
sort = x; | |
return pie; | |
}; | |
pie.startAngle = function(x) { | |
if (!arguments.length) return startAngle; | |
startAngle = x; | |
return pie; | |
}; | |
pie.endAngle = function(x) { | |
if (!arguments.length) return endAngle; | |
endAngle = x; | |
return pie; | |
}; | |
return pie; | |
}; | |
var d3_layout_pieSortByValue = {}; | |
d3.layout.stack = function() { | |
function stack(data, index) { | |
var series = data.map(function(d, i) { | |
return values.call(stack, d, i); | |
}); | |
var points = series.map(function(d, i) { | |
return d.map(function(v, i) { | |
return [ x.call(stack, v, i), y.call(stack, v, i) ]; | |
}); | |
}); | |
var orders = order.call(stack, points, index); | |
series = d3.permute(series, orders); | |
points = d3.permute(points, orders); | |
var offsets = offset.call(stack, points, index); | |
var n = series.length, m = series[0].length, i, j, o; | |
for (j = 0; j < m; ++j) { | |
out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); | |
for (i = 1; i < n; ++i) { | |
out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); | |
} | |
} | |
return data; | |
} | |
var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; | |
stack.values = function(x) { | |
if (!arguments.length) return values; | |
values = x; | |
return stack; | |
}; | |
stack.order = function(x) { | |
if (!arguments.length) return order; | |
order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; | |
return stack; | |
}; | |
stack.offset = function(x) { | |
if (!arguments.length) return offset; | |
offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; | |
return stack; | |
}; | |
stack.x = function(z) { | |
if (!arguments.length) return x; | |
x = z; | |
return stack; | |
}; | |
stack.y = function(z) { | |
if (!arguments.length) return y; | |
y = z; | |
return stack; | |
}; | |
stack.out = function(z) { | |
if (!arguments.length) return out; | |
out = z; | |
return stack; | |
}; | |
return stack; | |
}; | |
var d3_layout_stackOrders = d3.map({ | |
"inside-out": function(data) { | |
var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { | |
return max[a] - max[b]; | |
}), top = 0, bottom = 0, tops = [], bottoms = []; | |
for (i = 0; i < n; ++i) { | |
j = index[i]; | |
if (top < bottom) { | |
top += sums[j]; | |
tops.push(j); | |
} else { | |
bottom += sums[j]; | |
bottoms.push(j); | |
} | |
} | |
return bottoms.reverse().concat(tops); | |
}, | |
reverse: function(data) { | |
return d3.range(data.length).reverse(); | |
}, | |
"default": d3_layout_stackOrderDefault | |
}); | |
var d3_layout_stackOffsets = d3.map({ | |
silhouette: function(data) { | |
var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; | |
for (j = 0; j < m; ++j) { | |
for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; | |
if (o > max) max = o; | |
sums.push(o); | |
} | |
for (j = 0; j < m; ++j) { | |
y0[j] = (max - sums[j]) / 2; | |
} | |
return y0; | |
}, | |
wiggle: function(data) { | |
var n = data.length, x = data[0], m = x.length, max = 0, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; | |
y0[0] = o = o0 = 0; | |
for (j = 1; j < m; ++j) { | |
for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; | |
for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { | |
for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { | |
s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; | |
} | |
s2 += s3 * data[i][j][1]; | |
} | |
y0[j] = o -= s1 ? s2 / s1 * dx : 0; | |
if (o < o0) o0 = o; | |
} | |
for (j = 0; j < m; ++j) y0[j] -= o0; | |
return y0; | |
}, | |
expand: function(data) { | |
var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; | |
for (j = 0; j < m; ++j) { | |
for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; | |
if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; | |
} | |
for (j = 0; j < m; ++j) y0[j] = 0; | |
return y0; | |
}, | |
zero: d3_layout_stackOffsetZero | |
}); | |
d3.layout.histogram = function() { | |
function histogram(data, i) { | |
var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; | |
while (++i < m) { | |
bin = bins[i] = []; | |
bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); | |
bin.y = 0; | |
} | |
if (m > 0) { | |
i = -1; | |
while (++i < n) { | |
x = values[i]; | |
if (x >= range[0] && x <= range[1]) { | |
bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; | |
bin.y += k; | |
bin.push(data[i]); | |
} | |
} | |
} | |
return bins; | |
} | |
var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; | |
histogram.value = function(x) { | |
if (!arguments.length) return valuer; | |
valuer = x; | |
return histogram; | |
}; | |
histogram.range = function(x) { | |
if (!arguments.length) return ranger; | |
ranger = d3_functor(x); | |
return histogram; | |
}; | |
histogram.bins = function(x) { | |
if (!arguments.length) return binner; | |
binner = typeof x === "number" ? function(range) { | |
return d3_layout_histogramBinFixed(range, x); | |
} : d3_functor(x); | |
return histogram; | |
}; | |
histogram.frequency = function(x) { | |
if (!arguments.length) return frequency; | |
frequency = !!x; | |
return histogram; | |
}; | |
return histogram; | |
}; | |
d3.layout.hierarchy = function() { | |
function recurse(data, depth, nodes) { | |
var childs = children.call(hierarchy, data, depth), node = d3_layout_hierarchyInline ? data : { | |
data: data | |
}; | |
node.depth = depth; | |
nodes.push(node); | |
if (childs && (n = childs.length)) { | |
var i = -1, n, c = node.children = [], v = 0, j = depth + 1, d; | |
while (++i < n) { | |
d = recurse(childs[i], j, nodes); | |
d.parent = node; | |
c.push(d); | |
v += d.value; | |
} | |
if (sort) c.sort(sort); | |
if (value) node.value = v; | |
} else if (value) { | |
node.value = +value.call(hierarchy, data, depth) || 0; | |
} | |
return node; | |
} | |
function revalue(node, depth) { | |
var children = node.children, v = 0; | |
if (children && (n = children.length)) { | |
var i = -1, n, j = depth + 1; | |
while (++i < n) v += revalue(children[i], j); | |
} else if (value) { | |
v = +value.call(hierarchy, d3_layout_hierarchyInline ? node : node.data, depth) || 0; | |
} | |
if (value) node.value = v; | |
return v; | |
} | |
function hierarchy(d) { | |
var nodes = []; | |
recurse(d, 0, nodes); | |
return nodes; | |
} | |
var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; | |
hierarchy.sort = function(x) { | |
if (!arguments.length) return sort; | |
sort = x; | |
return hierarchy; | |
}; | |
hierarchy.children = function(x) { | |
if (!arguments.length) return children; | |
children = x; | |
return hierarchy; | |
}; | |
hierarchy.value = function(x) { | |
if (!arguments.length) return value; | |
value = x; | |
return hierarchy; | |
}; | |
hierarchy.revalue = function(root) { | |
revalue(root, 0); | |
return root; | |
}; | |
return hierarchy; | |
}; | |
var d3_layout_hierarchyInline = false; | |
d3.layout.pack = function() { | |
function pack(d, i) { | |
var nodes = hierarchy.call(this, d, i), root = nodes[0]; | |
root.x = 0; | |
root.y = 0; | |
d3_layout_treeVisitAfter(root, function(d) { | |
d.r = Math.sqrt(d.value); | |
}); | |
d3_layout_treeVisitAfter(root, d3_layout_packSiblings); | |
var w = size[0], h = size[1], k = Math.max(2 * root.r / w, 2 * root.r / h); | |
if (padding > 0) { | |
var dr = padding * k / 2; | |
d3_layout_treeVisitAfter(root, function(d) { | |
d.r += dr; | |
}); | |
d3_layout_treeVisitAfter(root, d3_layout_packSiblings); | |
d3_layout_treeVisitAfter(root, function(d) { | |
d.r -= dr; | |
}); | |
k = Math.max(2 * root.r / w, 2 * root.r / h); | |
} | |
d3_layout_packTransform(root, w / 2, h / 2, 1 / k); | |
return nodes; | |
} | |
var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ]; | |
pack.size = function(x) { | |
if (!arguments.length) return size; | |
size = x; | |
return pack; | |
}; | |
pack.padding = function(_) { | |
if (!arguments.length) return padding; | |
padding = +_; | |
return pack; | |
}; | |
return d3_layout_hierarchyRebind(pack, hierarchy); | |
}; | |
d3.layout.cluster = function() { | |
function cluster(d, i) { | |
var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0, kx, ky; | |
d3_layout_treeVisitAfter(root, function(node) { | |
var children = node.children; | |
if (children && children.length) { | |
node.x = d3_layout_clusterX(children); | |
node.y = d3_layout_clusterY(children); | |
} else { | |
node.x = previousNode ? x += separation(node, previousNode) : 0; | |
node.y = 0; | |
previousNode = node; | |
} | |
}); | |
var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; | |
d3_layout_treeVisitAfter(root, function(node) { | |
node.x = (node.x - x0) / (x1 - x0) * size[0]; | |
node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; | |
}); | |
return nodes; | |
} | |
var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; | |
cluster.separation = function(x) { | |
if (!arguments.length) return separation; | |
separation = x; | |
return cluster; | |
}; | |
cluster.size = function(x) { | |
if (!arguments.length) return size; | |
size = x; | |
return cluster; | |
}; | |
return d3_layout_hierarchyRebind(cluster, hierarchy); | |
}; | |
d3.layout.tree = function() { | |
function tree(d, i) { | |
function firstWalk(node, previousSibling) { | |
var children = node.children, layout = node._tree; | |
if (children && (n = children.length)) { | |
var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1; | |
while (++i < n) { | |
child = children[i]; | |
firstWalk(child, previousChild); | |
ancestor = apportion(child, previousChild, ancestor); | |
previousChild = child; | |
} | |
d3_layout_treeShift(node); | |
var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim); | |
if (previousSibling) { | |
layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); | |
layout.mod = layout.prelim - midpoint; | |
} else { | |
layout.prelim = midpoint; | |
} | |
} else { | |
if (previousSibling) { | |
layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); | |
} | |
} | |
} | |
function secondWalk(node, x) { | |
node.x = node._tree.prelim + x; | |
var children = node.children; | |
if (children && (n = children.length)) { | |
var i = -1, n; | |
x += node._tree.mod; | |
while (++i < n) { | |
secondWalk(children[i], x); | |
} | |
} | |
} | |
function apportion(node, previousSibling, ancestor) { | |
if (previousSibling) { | |
var vip = node, vop = node, vim = previousSibling, vom = node.parent.children[0], sip = vip._tree.mod, sop = vop._tree.mod, sim = vim._tree.mod, som = vom._tree.mod, shift; | |
while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { | |
vom = d3_layout_treeLeft(vom); | |
vop = d3_layout_treeRight(vop); | |
vop._tree.ancestor = node; | |
shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip); | |
if (shift > 0) { | |
d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift); | |
sip += shift; | |
sop += shift; | |
} | |
sim += vim._tree.mod; | |
sip += vip._tree.mod; | |
som += vom._tree.mod; | |
sop += vop._tree.mod; | |
} | |
if (vim && !d3_layout_treeRight(vop)) { | |
vop._tree.thread = vim; | |
vop._tree.mod += sim - sop; | |
} | |
if (vip && !d3_layout_treeLeft(vom)) { | |
vom._tree.thread = vip; | |
vom._tree.mod += sip - som; | |
ancestor = node; | |
} | |
} | |
return ancestor; | |
} | |
var nodes = hierarchy.call(this, d, i), root = nodes[0]; | |
d3_layout_treeVisitAfter(root, function(node, previousSibling) { | |
node._tree = { | |
ancestor: node, | |
prelim: 0, | |
mod: 0, | |
change: 0, | |
shift: 0, | |
number: previousSibling ? previousSibling._tree.number + 1 : 0 | |
}; | |
}); | |
firstWalk(root); | |
secondWalk(root, -root._tree.prelim); | |
var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), right = d3_layout_treeSearch(root, d3_layout_treeRightmost), deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2, y1 = deep.depth || 1; | |
d3_layout_treeVisitAfter(root, function(node) { | |
node.x = (node.x - x0) / (x1 - x0) * size[0]; | |
node.y = node.depth / y1 * size[1]; | |
delete node._tree; | |
}); | |
return nodes; | |
} | |
var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; | |
tree.separation = function(x) { | |
if (!arguments.length) return separation; | |
separation = x; | |
return tree; | |
}; | |
tree.size = function(x) { | |
if (!arguments.length) return size; | |
size = x; | |
return tree; | |
}; | |
return d3_layout_hierarchyRebind(tree, hierarchy); | |
}; | |
d3.layout.treemap = function() { | |
function scale(children, k) { | |
var i = -1, n = children.length, child, area; | |
while (++i < n) { | |
area = (child = children[i]).value * (k < 0 ? 0 : k); | |
child.area = isNaN(area) || area <= 0 ? 0 : area; | |
} | |
} | |
function squarify(node) { | |
var children = node.children; | |
if (children && children.length) { | |
var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = Math.min(rect.dx, rect.dy), n; | |
scale(remaining, rect.dx * rect.dy / node.value); | |
row.area = 0; | |
while ((n = remaining.length) > 0) { | |
row.push(child = remaining[n - 1]); | |
row.area += child.area; | |
if ((score = worst(row, u)) <= best) { | |
remaining.pop(); | |
best = score; | |
} else { | |
row.area -= row.pop().area; | |
position(row, u, rect, false); | |
u = Math.min(rect.dx, rect.dy); | |
row.length = row.area = 0; | |
best = Infinity; | |
} | |
} | |
if (row.length) { | |
position(row, u, rect, true); | |
row.length = row.area = 0; | |
} | |
children.forEach(squarify); | |
} | |
} | |
function stickify(node) { | |
var children = node.children; | |
if (children && children.length) { | |
var rect = pad(node), remaining = children.slice(), child, row = []; | |
scale(remaining, rect.dx * rect.dy / node.value); | |
row.area = 0; | |
while (child = remaining.pop()) { | |
row.push(child); | |
row.area += child.area; | |
if (child.z != null) { | |
position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); | |
row.length = row.area = 0; | |
} | |
} | |
children.forEach(stickify); | |
} | |
} | |
function worst(row, u) { | |
var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; | |
while (++i < n) { | |
if (!(r = row[i].area)) continue; | |
if (r < rmin) rmin = r; | |
if (r > rmax) rmax = r; | |
} | |
s *= s; | |
u *= u; | |
return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; | |
} | |
function position(row, u, rect, flush) { | |
var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; | |
if (u == rect.dx) { | |
if (flush || v > rect.dy) v = rect.dy; | |
while (++i < n) { | |
o = row[i]; | |
o.x = x; | |
o.y = y; | |
o.dy = v; | |
x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); | |
} | |
o.z = true; | |
o.dx += rect.x + rect.dx - x; | |
rect.y += v; | |
rect.dy -= v; | |
} else { | |
if (flush || v > rect.dx) v = rect.dx; | |
while (++i < n) { | |
o = row[i]; | |
o.x = x; | |
o.y = y; | |
o.dx = v; | |
y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); | |
} | |
o.z = false; | |
o.dy += rect.y + rect.dy - y; | |
rect.x += v; | |
rect.dx -= v; | |
} | |
} | |
function treemap(d) { | |
var nodes = stickies || hierarchy(d), root = nodes[0]; | |
root.x = 0; | |
root.y = 0; | |
root.dx = size[0]; | |
root.dy = size[1]; | |
if (stickies) hierarchy.revalue(root); | |
scale([ root ], root.dx * root.dy / root.value); | |
(stickies ? stickify : squarify)(root); | |
if (sticky) stickies = nodes; | |
return nodes; | |
} | |
var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, ratio = .5 * (1 + Math.sqrt(5)); | |
treemap.size = function(x) { | |
if (!arguments.length) return size; | |
size = x; | |
return treemap; | |
}; | |
treemap.padding = function(x) { | |
function padFunction(node) { | |
var p = x.call(treemap, node, node.depth); | |
return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); | |
} | |
function padConstant(node) { | |
return d3_layout_treemapPad(node, x); | |
} | |
if (!arguments.length) return padding; | |
var type; | |
pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], padConstant) : padConstant; | |
return treemap; | |
}; | |
treemap.round = function(x) { | |
if (!arguments.length) return round != Number; | |
round = x ? Math.round : Number; | |
return treemap; | |
}; | |
treemap.sticky = function(x) { | |
if (!arguments.length) return sticky; | |
sticky = x; | |
stickies = null; | |
return treemap; | |
}; | |
treemap.ratio = function(x) { | |
if (!arguments.length) return ratio; | |
ratio = x; | |
return treemap; | |
}; | |
return d3_layout_hierarchyRebind(treemap, hierarchy); | |
}; | |
d3.csv = d3_dsv(",", "text/csv"); | |
d3.tsv = d3_dsv(" ", "text/tab-separated-values"); | |
d3.geo = {}; | |
var d3_geo_radians = Math.PI / 180; | |
d3.geo.azimuthal = function() { | |
function azimuthal(coordinates) { | |
var x1 = coordinates[0] * d3_geo_radians - x0, y1 = coordinates[1] * d3_geo_radians, cx1 = Math.cos(x1), sx1 = Math.sin(x1), cy1 = Math.cos(y1), sy1 = Math.sin(y1), cc = mode !== "orthographic" ? sy0 * sy1 + cy0 * cy1 * cx1 : null, c, k = mode === "stereographic" ? 1 / (1 + cc) : mode === "gnomonic" ? 1 / cc : mode === "equidistant" ? (c = Math.acos(cc), c ? c / Math.sin(c) : 0) : mode === "equalarea" ? Math.sqrt(2 / (1 + cc)) : 1, x = k * cy1 * sx1, y = k * (sy0 * cy1 * cx1 - cy0 * sy1); | |
return [ scale * x + translate[0], scale * y + translate[1] ]; | |
} | |
var mode = "orthographic", origin, scale = 200, translate = [ 480, 250 ], x0, y0, cy0, sy0; | |
azimuthal.invert = function(coordinates) { | |
var x = (coordinates[0] - translate[0]) / scale, y = (coordinates[1] - translate[1]) / scale, p = Math.sqrt(x * x + y * y), c = mode === "stereographic" ? 2 * Math.atan(p) : mode === "gnomonic" ? Math.atan(p) : mode === "equidistant" ? p : mode === "equalarea" ? 2 * Math.asin(.5 * p) : Math.asin(p), sc = Math.sin(c), cc = Math.cos(c); | |
return [ (x0 + Math.atan2(x * sc, p * cy0 * cc + y * sy0 * sc)) / d3_geo_radians, Math.asin(cc * sy0 - (p ? y * sc * cy0 / p : 0)) / d3_geo_radians ]; | |
}; | |
azimuthal.mode = function(x) { | |
if (!arguments.length) return mode; | |
mode = x + ""; | |
return azimuthal; | |
}; | |
azimuthal.origin = function(x) { | |
if (!arguments.length) return origin; | |
origin = x; | |
x0 = origin[0] * d3_geo_radians; | |
y0 = origin[1] * d3_geo_radians; | |
cy0 = Math.cos(y0); | |
sy0 = Math.sin(y0); | |
return azimuthal; | |
}; | |
azimuthal.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = +x; | |
return azimuthal; | |
}; | |
azimuthal.translate = function(x) { | |
if (!arguments.length) return translate; | |
translate = [ +x[0], +x[1] ]; | |
return azimuthal; | |
}; | |
return azimuthal.origin([ 0, 0 ]); | |
}; | |
d3.geo.albers = function() { | |
function albers(coordinates) { | |
var t = n * (d3_geo_radians * coordinates[0] - lng0), p = Math.sqrt(C - 2 * n * Math.sin(d3_geo_radians * coordinates[1])) / n; | |
return [ scale * p * Math.sin(t) + translate[0], scale * (p * Math.cos(t) - p0) + translate[1] ]; | |
} | |
function reload() { | |
var phi1 = d3_geo_radians * parallels[0], phi2 = d3_geo_radians * parallels[1], lat0 = d3_geo_radians * origin[1], s = Math.sin(phi1), c = Math.cos(phi1); | |
lng0 = d3_geo_radians * origin[0]; | |
n = .5 * (s + Math.sin(phi2)); | |
C = c * c + 2 * n * s; | |
p0 = Math.sqrt(C - 2 * n * Math.sin(lat0)) / n; | |
return albers; | |
} | |
var origin = [ -98, 38 ], parallels = [ 29.5, 45.5 ], scale = 1e3, translate = [ 480, 250 ], lng0, n, C, p0; | |
albers.invert = function(coordinates) { | |
var x = (coordinates[0] - translate[0]) / scale, y = (coordinates[1] - translate[1]) / scale, p0y = p0 + y, t = Math.atan2(x, p0y), p = Math.sqrt(x * x + p0y * p0y); | |
return [ (lng0 + t / n) / d3_geo_radians, Math.asin((C - p * p * n * n) / (2 * n)) / d3_geo_radians ]; | |
}; | |
albers.origin = function(x) { | |
if (!arguments.length) return origin; | |
origin = [ +x[0], +x[1] ]; | |
return reload(); | |
}; | |
albers.parallels = function(x) { | |
if (!arguments.length) return parallels; | |
parallels = [ +x[0], +x[1] ]; | |
return reload(); | |
}; | |
albers.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = +x; | |
return albers; | |
}; | |
albers.translate = function(x) { | |
if (!arguments.length) return translate; | |
translate = [ +x[0], +x[1] ]; | |
return albers; | |
}; | |
return reload(); | |
}; | |
d3.geo.albersUsa = function() { | |
function albersUsa(coordinates) { | |
var lon = coordinates[0], lat = coordinates[1]; | |
return (lat > 50 ? alaska : lon < -140 ? hawaii : lat < 21 ? puertoRico : lower48)(coordinates); | |
} | |
var lower48 = d3.geo.albers(); | |
var alaska = d3.geo.albers().origin([ -160, 60 ]).parallels([ 55, 65 ]); | |
var hawaii = d3.geo.albers().origin([ -160, 20 ]).parallels([ 8, 18 ]); | |
var puertoRico = d3.geo.albers().origin([ -60, 10 ]).parallels([ 8, 18 ]); | |
albersUsa.scale = function(x) { | |
if (!arguments.length) return lower48.scale(); | |
lower48.scale(x); | |
alaska.scale(x * .6); | |
hawaii.scale(x); | |
puertoRico.scale(x * 1.5); | |
return albersUsa.translate(lower48.translate()); | |
}; | |
albersUsa.translate = function(x) { | |
if (!arguments.length) return lower48.translate(); | |
var dz = lower48.scale() / 1e3, dx = x[0], dy = x[1]; | |
lower48.translate(x); | |
alaska.translate([ dx - 400 * dz, dy + 170 * dz ]); | |
hawaii.translate([ dx - 190 * dz, dy + 200 * dz ]); | |
puertoRico.translate([ dx + 580 * dz, dy + 430 * dz ]); | |
return albersUsa; | |
}; | |
return albersUsa.scale(lower48.scale()); | |
}; | |
d3.geo.bonne = function() { | |
function bonne(coordinates) { | |
var x = coordinates[0] * d3_geo_radians - x0, y = coordinates[1] * d3_geo_radians - y0; | |
if (y1) { | |
var p = c1 + y1 - y, E = x * Math.cos(y) / p; | |
x = p * Math.sin(E); | |
y = p * Math.cos(E) - c1; | |
} else { | |
x *= Math.cos(y); | |
y *= -1; | |
} | |
return [ scale * x + translate[0], scale * y + translate[1] ]; | |
} | |
var scale = 200, translate = [ 480, 250 ], x0, y0, y1, c1; | |
bonne.invert = function(coordinates) { | |
var x = (coordinates[0] - translate[0]) / scale, y = (coordinates[1] - translate[1]) / scale; | |
if (y1) { | |
var c = c1 + y, p = Math.sqrt(x * x + c * c); | |
y = c1 + y1 - p; | |
x = x0 + p * Math.atan2(x, c) / Math.cos(y); | |
} else { | |
y *= -1; | |
x /= Math.cos(y); | |
} | |
return [ x / d3_geo_radians, y / d3_geo_radians ]; | |
}; | |
bonne.parallel = function(x) { | |
if (!arguments.length) return y1 / d3_geo_radians; | |
c1 = 1 / Math.tan(y1 = x * d3_geo_radians); | |
return bonne; | |
}; | |
bonne.origin = function(x) { | |
if (!arguments.length) return [ x0 / d3_geo_radians, y0 / d3_geo_radians ]; | |
x0 = x[0] * d3_geo_radians; | |
y0 = x[1] * d3_geo_radians; | |
return bonne; | |
}; | |
bonne.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = +x; | |
return bonne; | |
}; | |
bonne.translate = function(x) { | |
if (!arguments.length) return translate; | |
translate = [ +x[0], +x[1] ]; | |
return bonne; | |
}; | |
return bonne.origin([ 0, 0 ]).parallel(45); | |
}; | |
d3.geo.equirectangular = function() { | |
function equirectangular(coordinates) { | |
var x = coordinates[0] / 360, y = -coordinates[1] / 360; | |
return [ scale * x + translate[0], scale * y + translate[1] ]; | |
} | |
var scale = 500, translate = [ 480, 250 ]; | |
equirectangular.invert = function(coordinates) { | |
var x = (coordinates[0] - translate[0]) / scale, y = (coordinates[1] - translate[1]) / scale; | |
return [ 360 * x, -360 * y ]; | |
}; | |
equirectangular.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = +x; | |
return equirectangular; | |
}; | |
equirectangular.translate = function(x) { | |
if (!arguments.length) return translate; | |
translate = [ +x[0], +x[1] ]; | |
return equirectangular; | |
}; | |
return equirectangular; | |
}; | |
d3.geo.mercator = function() { | |
function mercator(coordinates) { | |
var x = coordinates[0] / 360, y = -(Math.log(Math.tan(Math.PI / 4 + coordinates[1] * d3_geo_radians / 2)) / d3_geo_radians) / 360; | |
return [ scale * x + translate[0], scale * Math.max(-.5, Math.min(.5, y)) + translate[1] ]; | |
} | |
var scale = 500, translate = [ 480, 250 ]; | |
mercator.invert = function(coordinates) { | |
var x = (coordinates[0] - translate[0]) / scale, y = (coordinates[1] - translate[1]) / scale; | |
return [ 360 * x, 2 * Math.atan(Math.exp(-360 * y * d3_geo_radians)) / d3_geo_radians - 90 ]; | |
}; | |
mercator.scale = function(x) { | |
if (!arguments.length) return scale; | |
scale = +x; | |
return mercator; | |
}; | |
mercator.translate = function(x) { | |
if (!arguments.length) return translate; | |
translate = [ +x[0], +x[1] ]; | |
return mercator; | |
}; | |
return mercator; | |
}; | |
d3.geo.path = function() { | |
function path(d, i) { | |
if (typeof pointRadius === "function") pointCircle = d3_path_circle(pointRadius.apply(this, arguments)); | |
pathType(d); | |
var result = buffer.length ? buffer.join("") : null; | |
buffer = []; | |
return result; | |
} | |
function project(coordinates) { | |
return projection(coordinates).join(","); | |
} | |
function polygonArea(coordinates) { | |
var sum = area(coordinates[0]), i = 0, n = coordinates.length; | |
while (++i < n) sum -= area(coordinates[i]); | |
return sum; | |
} | |
function polygonCentroid(coordinates) { | |
var polygon = d3.geom.polygon(coordinates[0].map(projection)), area = polygon.area(), centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1), x = centroid[0], y = centroid[1], z = area, i = 0, n = coordinates.length; | |
while (++i < n) { | |
polygon = d3.geom.polygon(coordinates[i].map(projection)); | |
area = polygon.area(); | |
centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1); | |
x -= centroid[0]; | |
y -= centroid[1]; | |
z -= area; | |
} | |
return [ x, y, 6 * z ]; | |
} | |
function area(coordinates) { | |
return Math.abs(d3.geom.polygon(coordinates.map(projection)).area()); | |
} | |
var pointRadius = 4.5, pointCircle = d3_path_circle(pointRadius), projection = d3.geo.albersUsa(), buffer = []; | |
var pathType = d3_geo_type({ | |
FeatureCollection: function(o) { | |
var features = o.features, i = -1, n = features.length; | |
while (++i < n) buffer.push(pathType(features[i].geometry)); | |
}, | |
Feature: function(o) { | |
pathType(o.geometry); | |
}, | |
Point: function(o) { | |
buffer.push("M", project(o.coordinates), pointCircle); | |
}, | |
MultiPoint: function(o) { | |
var coordinates = o.coordinates, i = -1, n = coordinates.length; | |
while (++i < n) buffer.push("M", project(coordinates[i]), pointCircle); | |
}, | |
LineString: function(o) { | |
var coordinates = o.coordinates, i = -1, n = coordinates.length; | |
buffer.push("M"); | |
while (++i < n) buffer.push(project(coordinates[i]), "L"); | |
buffer.pop(); | |
}, | |
MultiLineString: function(o) { | |
var coordinates = o.coordinates, i = -1, n = coordinates.length, subcoordinates, j, m; | |
while (++i < n) { | |
subcoordinates = coordinates[i]; | |
j = -1; | |
m = subcoordinates.length; | |
buffer.push("M"); | |
while (++j < m) buffer.push(project(subcoordinates[j]), "L"); | |
buffer.pop(); | |
} | |
}, | |
Polygon: function(o) { | |
var coordinates = o.coordinates, i = -1, n = coordinates.length, subcoordinates, j, m; | |
while (++i < n) { | |
subcoordinates = coordinates[i]; | |
j = -1; | |
if ((m = subcoordinates.length - 1) > 0) { | |
buffer.push("M"); | |
while (++j < m) buffer.push(project(subcoordinates[j]), "L"); | |
buffer[buffer.length - 1] = "Z"; | |
} | |
} | |
}, | |
MultiPolygon: function(o) { | |
var coordinates = o.coordinates, i = -1, n = coordinates.length, subcoordinates, j, m, subsubcoordinates, k, p; | |
while (++i < n) { | |
subcoordinates = coordinates[i]; | |
j = -1; | |
m = subcoordinates.length; | |
while (++j < m) { | |
subsubcoordinates = subcoordinates[j]; | |
k = -1; | |
if ((p = subsubcoordinates.length - 1) > 0) { | |
buffer.push("M"); | |
while (++k < p) buffer.push(project(subsubcoordinates[k]), "L"); | |
buffer[buffer.length - 1] = "Z"; | |
} | |
} | |
} | |
}, | |
GeometryCollection: function(o) { | |
var geometries = o.geometries, i = -1, n = geometries.length; | |
while (++i < n) buffer.push(pathType(geometries[i])); | |
} | |
}); | |
var areaType = path.area = d3_geo_type({ | |
FeatureCollection: function(o) { | |
var area = 0, features = o.features, i = -1, n = features.length; | |
while (++i < n) area += areaType(features[i]); | |
return area; | |
}, | |
Feature: function(o) { | |
return areaType(o.geometry); | |
}, | |
Polygon: function(o) { | |
return polygonArea(o.coordinates); | |
}, | |
MultiPolygon: function(o) { | |
var sum = 0, coordinates = o.coordinates, i = -1, n = coordinates.length; | |
while (++i < n) sum += polygonArea(coordinates[i]); | |
return sum; | |
}, | |
GeometryCollection: function(o) { | |
var sum = 0, geometries = o.geometries, i = -1, n = geometries.length; | |
while (++i < n) sum += areaType(geometries[i]); | |
return sum; | |
} | |
}, 0); | |
var centroidType = path.centroid = d3_geo_type({ | |
Feature: function(o) { | |
return centroidType(o.geometry); | |
}, | |
Polygon: function(o) { | |
var centroid = polygonCentroid(o.coordinates); | |
return [ centroid[0] / centroid[2], centroid[1] / centroid[2] ]; | |
}, | |
MultiPolygon: function(o) { | |
var area = 0, coordinates = o.coordinates, centroid, x = 0, y = 0, z = 0, i = -1, n = coordinates.length; | |
while (++i < n) { | |
centroid = polygonCentroid(coordinates[i]); | |
x += centroid[0]; | |
y += centroid[1]; | |
z += centroid[2]; | |
} | |
return [ x / z, y / z ]; | |
} | |
}); | |
path.projection = function(x) { | |
projection = x; | |
return path; | |
}; | |
path.pointRadius = function(x) { | |
if (typeof x === "function") pointRadius = x; else { | |
pointRadius = +x; | |
pointCircle = d3_path_circle(pointRadius); | |
} | |
return path; | |
}; | |
return path; | |
}; | |
d3.geo.bounds = function(feature) { | |
var left = Infinity, bottom = Infinity, right = -Infinity, top = -Infinity; | |
d3_geo_bounds(feature, function(x, y) { | |
if (x < left) left = x; | |
if (x > right) right = x; | |
if (y < bottom) bottom = y; | |
if (y > top) top = y; | |
}); | |
return [ [ left, bottom ], [ right, top ] ]; | |
}; | |
var d3_geo_boundsTypes = { | |
Feature: d3_geo_boundsFeature, | |
FeatureCollection: d3_geo_boundsFeatureCollection, | |
GeometryCollection: d3_geo_boundsGeometryCollection, | |
LineString: d3_geo_boundsLineString, | |
MultiLineString: d3_geo_boundsMultiLineString, | |
MultiPoint: d3_geo_boundsLineString, | |
MultiPolygon: d3_geo_boundsMultiPolygon, | |
Point: d3_geo_boundsPoint, | |
Polygon: d3_geo_boundsPolygon | |
}; | |
d3.geo.circle = function() { | |
function circle() {} | |
function visible(point) { | |
return arc.distance(point) < radians; | |
} | |
function clip(coordinates) { | |
var i = -1, n = coordinates.length, clipped = [], p0, p1, p2, d0, d1; | |
while (++i < n) { | |
d1 = arc.distance(p2 = coordinates[i]); | |
if (d1 < radians) { | |
if (p1) clipped.push(d3_geo_greatArcInterpolate(p1, p2)((d0 - radians) / (d0 - d1))); | |
clipped.push(p2); | |
p0 = p1 = null; | |
} else { | |
p1 = p2; | |
if (!p0 && clipped.length) { | |
clipped.push(d3_geo_greatArcInterpolate(clipped[clipped.length - 1], p1)((radians - d0) / (d1 - d0))); | |
p0 = p1; | |
} | |
} | |
d0 = d1; | |
} | |
p0 = coordinates[0]; | |
p1 = clipped[0]; | |
if (p1 && p2[0] === p0[0] && p2[1] === p0[1] && !(p2[0] === p1[0] && p2[1] === p1[1])) { | |
clipped.push(p1); | |
} | |
return resample(clipped); | |
} | |
function resample(coordinates) { | |
var i = 0, n = coordinates.length, j, m, resampled = n ? [ coordinates[0] ] : coordinates, resamples, origin = arc.source(); | |
while (++i < n) { | |
resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates; | |
for (j = 0, m = resamples.length; ++j < m; ) resampled.push(resamples[j]); | |
} | |
arc.source(origin); | |
return resampled; | |
} | |
var origin = [ 0, 0 ], degrees = 90 - .01, radians = degrees * d3_geo_radians, arc = d3.geo.greatArc().source(origin).target(d3_identity); | |
circle.clip = function(d) { | |
if (typeof origin === "function") arc.source(origin.apply(this, arguments)); | |
return clipType(d) || null; | |
}; | |
var clipType = d3_geo_type({ | |
FeatureCollection: function(o) { | |
var features = o.features.map(clipType).filter(d3_identity); | |
return features && (o = Object.create(o), o.features = features, o); | |
}, | |
Feature: function(o) { | |
var geometry = clipType(o.geometry); | |
return geometry && (o = Object.create(o), o.geometry = geometry, o); | |
}, | |
Point: function(o) { | |
return visible(o.coordinates) && o; | |
}, | |
MultiPoint: function(o) { | |
var coordinates = o.coordinates.filter(visible); | |
return coordinates.length && { | |
type: o.type, | |
coordinates: coordinates | |
}; | |
}, | |
LineString: function(o) { | |
var coordinates = clip(o.coordinates); | |
return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o); | |
}, | |
MultiLineString: function(o) { | |
var coordinates = o.coordinates.map(clip).filter(function(d) { | |
return d.length; | |
}); | |
return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o); | |
}, | |
Polygon: function(o) { | |
var coordinates = o.coordinates.map(clip); | |
return coordinates[0].length && (o = Object.create(o), o.coordinates = coordinates, o); | |
}, | |
MultiPolygon: function(o) { | |
var coordinates = o.coordinates.map(function(d) { | |
return d.map(clip); | |
}).filter(function(d) { | |
return d[0].length; | |
}); | |
return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o); | |
}, | |
GeometryCollection: function(o) { | |
var geometries = o.geometries.map(clipType).filter(d3_identity); | |
return geometries.length && (o = Object.create(o), o.geometries = geometries, o); | |
} | |
}); | |
circle.origin = function(x) { | |
if (!arguments.length) return origin; | |
origin = x; | |
if (typeof origin !== "function") arc.source(origin); | |
return circle; | |
}; | |
circle.angle = function(x) { | |
if (!arguments.length) return degrees; | |
radians = (degrees = +x) * d3_geo_radians; | |
return circle; | |
}; | |
return d3.rebind(circle, arc, "precision"); | |
}; | |
d3.geo.greatArc = function() { | |
function greatArc() { | |
var d = greatArc.distance.apply(this, arguments), t = 0, dt = precision / d, coordinates = [ p0 ]; | |
while ((t += dt) < 1) coordinates.push(interpolate(t)); | |
coordinates.push(p1); | |
return { | |
type: "LineString", | |
coordinates: coordinates | |
}; | |
} | |
var source = d3_geo_greatArcSource, p0, target = d3_geo_greatArcTarget, p1, precision = 6 * d3_geo_radians, interpolate = d3_geo_greatArcInterpolator(); | |
greatArc.distance = function() { | |
if (typeof source === "function") interpolate.source(p0 = source.apply(this, arguments)); | |
if (typeof target === "function") interpolate.target(p1 = target.apply(this, arguments)); | |
return interpolate.distance(); | |
}; | |
greatArc.source = function(_) { | |
if (!arguments.length) return source; | |
source = _; | |
if (typeof source !== "function") interpolate.source(p0 = source); | |
return greatArc; | |
}; | |
greatArc.target = function(_) { | |
if (!arguments.length) return target; | |
target = _; | |
if (typeof target !== "function") interpolate.target(p1 = target); | |
return greatArc; | |
}; | |
greatArc.precision = function(_) { | |
if (!arguments.length) return precision / d3_geo_radians; | |
precision = _ * d3_geo_radians; | |
return greatArc; | |
}; | |
return greatArc; | |
}; | |
d3.geo.greatCircle = d3.geo.circle; | |
d3.geom = {}; | |
d3.geom.contour = function(grid, start) { | |
var s = start || d3_geom_contourStart(grid), c = [], x = s[0], y = s[1], dx = 0, dy = 0, pdx = NaN, pdy = NaN, i = 0; | |
do { | |
i = 0; | |
if (grid(x - 1, y - 1)) i += 1; | |
if (grid(x, y - 1)) i += 2; | |
if (grid(x - 1, y)) i += 4; | |
if (grid(x, y)) i += 8; | |
if (i === 6) { | |
dx = pdy === -1 ? -1 : 1; | |
dy = 0; | |
} else if (i === 9) { | |
dx = 0; | |
dy = pdx === 1 ? -1 : 1; | |
} else { | |
dx = d3_geom_contourDx[i]; | |
dy = d3_geom_contourDy[i]; | |
} | |
if (dx != pdx && dy != pdy) { | |
c.push([ x, y ]); | |
pdx = dx; | |
pdy = dy; | |
} | |
x += dx; | |
y += dy; | |
} while (s[0] != x || s[1] != y); | |
return c; | |
}; | |
var d3_geom_contourDx = [ 1, 0, 1, 1, -1, 0, -1, 1, 0, 0, 0, 0, -1, 0, -1, NaN ], d3_geom_contourDy = [ 0, -1, 0, 0, 0, -1, 0, 0, 1, -1, 1, 1, 0, -1, 0, NaN ]; | |
d3.geom.hull = function(vertices) { | |
if (vertices.length < 3) return []; | |
var len = vertices.length, plen = len - 1, points = [], stack = [], i, j, h = 0, x1, y1, x2, y2, u, v, a, sp; | |
for (i = 1; i < len; ++i) { | |
if (vertices[i][1] < vertices[h][1]) { | |
h = i; | |
} else if (vertices[i][1] == vertices[h][1]) { | |
h = vertices[i][0] < vertices[h][0] ? i : h; | |
} | |
} | |
for (i = 0; i < len; ++i) { | |
if (i === h) continue; | |
y1 = vertices[i][1] - vertices[h][1]; | |
x1 = vertices[i][0] - vertices[h][0]; | |
points.push({ | |
angle: Math.atan2(y1, x1), | |
index: i | |
}); | |
} | |
points.sort(function(a, b) { | |
return a.angle - b.angle; | |
}); | |
a = points[0].angle; | |
v = points[0].index; | |
u = 0; | |
for (i = 1; i < plen; ++i) { | |
j = points[i].index; | |
if (a == points[i].angle) { | |
x1 = vertices[v][0] - vertices[h][0]; | |
y1 = vertices[v][1] - vertices[h][1]; | |
x2 = vertices[j][0] - vertices[h][0]; | |
y2 = vertices[j][1] - vertices[h][1]; | |
if (x1 * x1 + y1 * y1 >= x2 * x2 + y2 * y2) { | |
points[i].index = -1; | |
} else { | |
points[u].index = -1; | |
a = points[i].angle; | |
u = i; | |
v = j; | |
} | |
} else { | |
a = points[i].angle; | |
u = i; | |
v = j; | |
} | |
} | |
stack.push(h); | |
for (i = 0, j = 0; i < 2; ++j) { | |
if (points[j].index !== -1) { | |
stack.push(points[j].index); | |
i++; | |
} | |
} | |
sp = stack.length; | |
for (; j < plen; ++j) { | |
if (points[j].index === -1) continue; | |
while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) { | |
--sp; | |
} | |
stack[sp++] = points[j].index; | |
} | |
var poly = []; | |
for (i = 0; i < sp; ++i) { | |
poly.push(vertices[stack[i]]); | |
} | |
return poly; | |
}; | |
d3.geom.polygon = function(coordinates) { | |
coordinates.area = function() { | |
var i = 0, n = coordinates.length, a = coordinates[n - 1][0] * coordinates[0][1], b = coordinates[n - 1][1] * coordinates[0][0]; | |
while (++i < n) { | |
a += coordinates[i - 1][0] * coordinates[i][1]; | |
b += coordinates[i - 1][1] * coordinates[i][0]; | |
} | |
return (b - a) * .5; | |
}; | |
coordinates.centroid = function(k) { | |
var i = -1, n = coordinates.length, x = 0, y = 0, a, b = coordinates[n - 1], c; | |
if (!arguments.length) k = -1 / (6 * coordinates.area()); | |
while (++i < n) { | |
a = b; | |
b = coordinates[i]; | |
c = a[0] * b[1] - b[0] * a[1]; | |
x += (a[0] + b[0]) * c; | |
y += (a[1] + b[1]) * c; | |
} | |
return [ x * k, y * k ]; | |
}; | |
coordinates.clip = function(subject) { | |
var input, i = -1, n = coordinates.length, j, m, a = coordinates[n - 1], b, c, d; | |
while (++i < n) { | |
input = subject.slice(); | |
subject.length = 0; | |
b = coordinates[i]; | |
c = input[(m = input.length) - 1]; | |
j = -1; | |
while (++j < m) { | |
d = input[j]; | |
if (d3_geom_polygonInside(d, a, b)) { | |
if (!d3_geom_polygonInside(c, a, b)) { | |
subject.push(d3_geom_polygonIntersect(c, d, a, b)); | |
} | |
subject.push(d); | |
} else if (d3_geom_polygonInside(c, a, b)) { | |
subject.push(d3_geom_polygonIntersect(c, d, a, b)); | |
} | |
c = d; | |
} | |
a = b; | |
} | |
return subject; | |
}; | |
return coordinates; | |
}; | |
d3.geom.voronoi = function(vertices) { | |
var polygons = vertices.map(function() { | |
return []; | |
}); | |
d3_voronoi_tessellate(vertices, function(e) { | |
var s1, s2, x1, x2, y1, y2; | |
if (e.a === 1 && e.b >= 0) { | |
s1 = e.ep.r; | |
s2 = e.ep.l; | |
} else { | |
s1 = e.ep.l; | |
s2 = e.ep.r; | |
} | |
if (e.a === 1) { | |
y1 = s1 ? s1.y : -1e6; | |
x1 = e.c - e.b * y1; | |
y2 = s2 ? s2.y : 1e6; | |
x2 = e.c - e.b * y2; | |
} else { | |
x1 = s1 ? s1.x : -1e6; | |
y1 = e.c - e.a * x1; | |
x2 = s2 ? s2.x : 1e6; | |
y2 = e.c - e.a * x2; | |
} | |
var v1 = [ x1, y1 ], v2 = [ x2, y2 ]; | |
polygons[e.region.l.index].push(v1, v2); | |
polygons[e.region.r.index].push(v1, v2); | |
}); | |
return polygons.map(function(polygon, i) { | |
var cx = vertices[i][0], cy = vertices[i][1]; | |
polygon.forEach(function(v) { | |
v.angle = Math.atan2(v[0] - cx, v[1] - cy); | |
}); | |
return polygon.sort(function(a, b) { | |
return a.angle - b.angle; | |
}).filter(function(d, i) { | |
return !i || d.angle - polygon[i - 1].angle > 1e-10; | |
}); | |
}); | |
}; | |
var d3_voronoi_opposite = { | |
l: "r", | |
r: "l" | |
}; | |
d3.geom.delaunay = function(vertices) { | |
var edges = vertices.map(function() { | |
return []; | |
}), triangles = []; | |
d3_voronoi_tessellate(vertices, function(e) { | |
edges[e.region.l.index].push(vertices[e.region.r.index]); | |
}); | |
edges.forEach(function(edge, i) { | |
var v = vertices[i], cx = v[0], cy = v[1]; | |
edge.forEach(function(v) { | |
v.angle = Math.atan2(v[0] - cx, v[1] - cy); | |
}); | |
edge.sort(function(a, b) { | |
return a.angle - b.angle; | |
}); | |
for (var j = 0, m = edge.length - 1; j < m; j++) { | |
triangles.push([ v, edge[j], edge[j + 1] ]); | |
} | |
}); | |
return triangles; | |
}; | |
d3.geom.quadtree = function(points, x1, y1, x2, y2) { | |
function insert(n, p, x1, y1, x2, y2) { | |
if (isNaN(p.x) || isNaN(p.y)) return; | |
if (n.leaf) { | |
var v = n.point; | |
if (v) { | |
if (Math.abs(v.x - p.x) + Math.abs(v.y - p.y) < .01) { | |
insertChild(n, p, x1, y1, x2, y2); | |
} else { | |
n.point = null; | |
insertChild(n, v, x1, y1, x2, y2); | |
insertChild(n, p, x1, y1, x2, y2); | |
} | |
} else { | |
n.point = p; | |
} | |
} else { | |
insertChild(n, p, x1, y1, x2, y2); | |
} | |
} | |
function insertChild(n, p, x1, y1, x2, y2) { | |
var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = p.x >= sx, bottom = p.y >= sy, i = (bottom << 1) + right; | |
n.leaf = false; | |
n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); | |
if (right) x1 = sx; else x2 = sx; | |
if (bottom) y1 = sy; else y2 = sy; | |
insert(n, p, x1, y1, x2, y2); | |
} | |
var p, i = -1, n = points.length; | |
if (n && isNaN(points[0].x)) points = points.map(d3_geom_quadtreePoint); | |
if (arguments.length < 5) { | |
if (arguments.length === 3) { | |
y2 = x2 = y1; | |
y1 = x1; | |
} else { | |
x1 = y1 = Infinity; | |
x2 = y2 = -Infinity; | |
while (++i < n) { | |
p = points[i]; | |
if (p.x < x1) x1 = p.x; | |
if (p.y < y1) y1 = p.y; | |
if (p.x > x2) x2 = p.x; | |
if (p.y > y2) y2 = p.y; | |
} | |
var dx = x2 - x1, dy = y2 - y1; | |
if (dx > dy) y2 = y1 + dx; else x2 = x1 + dy; | |
} | |
} | |
var root = d3_geom_quadtreeNode(); | |
root.add = function(p) { | |
insert(root, p, x1, y1, x2, y2); | |
}; | |
root.visit = function(f) { | |
d3_geom_quadtreeVisit(f, root, x1, y1, x2, y2); | |
}; | |
points.forEach(root.add); | |
return root; | |
}; | |
d3.time = {}; | |
var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; | |
d3_time_utc.prototype = { | |
getDate: function() { | |
return this._.getUTCDate(); | |
}, | |
getDay: function() { | |
return this._.getUTCDay(); | |
}, | |
getFullYear: function() { | |
return this._.getUTCFullYear(); | |
}, | |
getHours: function() { | |
return this._.getUTCHours(); | |
}, | |
getMilliseconds: function() { | |
return this._.getUTCMilliseconds(); | |
}, | |
getMinutes: function() { | |
return this._.getUTCMinutes(); | |
}, | |
getMonth: function() { | |
return this._.getUTCMonth(); | |
}, | |
getSeconds: function() { | |
return this._.getUTCSeconds(); | |
}, | |
getTime: function() { | |
return this._.getTime(); | |
}, | |
getTimezoneOffset: function() { | |
return 0; | |
}, | |
valueOf: function() { | |
return this._.valueOf(); | |
}, | |
setDate: function() { | |
d3_time_prototype.setUTCDate.apply(this._, arguments); | |
}, | |
setDay: function() { | |
d3_time_prototype.setUTCDay.apply(this._, arguments); | |
}, | |
setFullYear: function() { | |
d3_time_prototype.setUTCFullYear.apply(this._, arguments); | |
}, | |
setHours: function() { | |
d3_time_prototype.setUTCHours.apply(this._, arguments); | |
}, | |
setMilliseconds: function() { | |
d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); | |
}, | |
setMinutes: function() { | |
d3_time_prototype.setUTCMinutes.apply(this._, arguments); | |
}, | |
setMonth: function() { | |
d3_time_prototype.setUTCMonth.apply(this._, arguments); | |
}, | |
setSeconds: function() { | |
d3_time_prototype.setUTCSeconds.apply(this._, arguments); | |
}, | |
setTime: function() { | |
d3_time_prototype.setTime.apply(this._, arguments); | |
} | |
}; | |
var d3_time_prototype = Date.prototype; | |
var d3_time_formatDateTime = "%a %b %e %H:%M:%S %Y", d3_time_formatDate = "%m/%d/%y", d3_time_formatTime = "%H:%M:%S"; | |
var d3_time_days = d3_time_daySymbols, d3_time_dayAbbreviations = d3_time_days.map(d3_time_formatAbbreviate), d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = d3_time_months.map(d3_time_formatAbbreviate); | |
d3.time.format = function(template) { | |
function format(date) { | |
var string = [], i = -1, j = 0, c, f; | |
while (++i < n) { | |
if (template.charCodeAt(i) == 37) { | |
string.push(template.substring(j, i), (f = d3_time_formats[c = template.charAt(++i)]) ? f(date) : c); | |
j = i + 1; | |
} | |
} | |
string.push(template.substring(j, i)); | |
return string.join(""); | |
} | |
var n = template.length; | |
format.parse = function(string) { | |
var d = { | |
y: 1900, | |
m: 0, | |
d: 1, | |
H: 0, | |
M: 0, | |
S: 0, | |
L: 0 | |
}, i = d3_time_parse(d, template, string, 0); | |
if (i != string.length) return null; | |
if ("p" in d) d.H = d.H % 12 + d.p * 12; | |
var date = new d3_time; | |
date.setFullYear(d.y, d.m, d.d); | |
date.setHours(d.H, d.M, d.S, d.L); | |
return date; | |
}; | |
format.toString = function() { | |
return template; | |
}; | |
return format; | |
}; | |
var d3_time_zfill2 = d3.format("02d"), d3_time_zfill3 = d3.format("03d"), d3_time_zfill4 = d3.format("04d"), d3_time_sfill2 = d3.format("2d"); | |
var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations); | |
var d3_time_formats = { | |
a: function(d) { | |
return d3_time_dayAbbreviations[d.getDay()]; | |
}, | |
A: function(d) { | |
return d3_time_days[d.getDay()]; | |
}, | |
b: function(d) { | |
return d3_time_monthAbbreviations[d.getMonth()]; | |
}, | |
B: function(d) { | |
return d3_time_months[d.getMonth()]; | |
}, | |
c: d3.time.format(d3_time_formatDateTime), | |
d: function(d) { | |
return d3_time_zfill2(d.getDate()); | |
}, | |
e: function(d) { | |
return d3_time_sfill2(d.getDate()); | |
}, | |
H: function(d) { | |
return d3_time_zfill2(d.getHours()); | |
}, | |
I: function(d) { | |
return d3_time_zfill2(d.getHours() % 12 || 12); | |
}, | |
j: function(d) { | |
return d3_time_zfill3(1 + d3.time.dayOfYear(d)); | |
}, | |
L: function(d) { | |
return d3_time_zfill3(d.getMilliseconds()); | |
}, | |
m: function(d) { | |
return d3_time_zfill2(d.getMonth() + 1); | |
}, | |
M: function(d) { | |
return d3_time_zfill2(d.getMinutes()); | |
}, | |
p: function(d) { | |
return d.getHours() >= 12 ? "PM" : "AM"; | |
}, | |
S: function(d) { | |
return d3_time_zfill2(d.getSeconds()); | |
}, | |
U: function(d) { | |
return d3_time_zfill2(d3.time.sundayOfYear(d)); | |
}, | |
w: function(d) { | |
return d.getDay(); | |
}, | |
W: function(d) { | |
return d3_time_zfill2(d3.time.mondayOfYear(d)); | |
}, | |
x: d3.time.format(d3_time_formatDate), | |
X: d3.time.format(d3_time_formatTime), | |
y: function(d) { | |
return d3_time_zfill2(d.getFullYear() % 100); | |
}, | |
Y: function(d) { | |
return d3_time_zfill4(d.getFullYear() % 1e4); | |
}, | |
Z: d3_time_zone, | |
"%": function(d) { | |
return "%"; | |
} | |
}; | |
var d3_time_parsers = { | |
a: d3_time_parseWeekdayAbbrev, | |
A: d3_time_parseWeekday, | |
b: d3_time_parseMonthAbbrev, | |
B: d3_time_parseMonth, | |
c: d3_time_parseLocaleFull, | |
d: d3_time_parseDay, | |
e: d3_time_parseDay, | |
H: d3_time_parseHour24, | |
I: d3_time_parseHour24, | |
L: d3_time_parseMilliseconds, | |
m: d3_time_parseMonthNumber, | |
M: d3_time_parseMinutes, | |
p: d3_time_parseAmPm, | |
S: d3_time_parseSeconds, | |
x: d3_time_parseLocaleDate, | |
X: d3_time_parseLocaleTime, | |
y: d3_time_parseYear, | |
Y: d3_time_parseFullYear | |
}; | |
var d3_time_numberRe = /^\s*\d+/; | |
var d3_time_amPmLookup = d3.map({ | |
am: 0, | |
pm: 1 | |
}); | |
d3.time.format.utc = function(template) { | |
function format(date) { | |
try { | |
d3_time = d3_time_utc; | |
var utc = new d3_time; | |
utc._ = date; | |
return local(utc); | |
} finally { | |
d3_time = Date; | |
} | |
} | |
var local = d3.time.format(template); | |
format.parse = function(string) { | |
try { | |
d3_time = d3_time_utc; | |
var date = local.parse(string); | |
return date && date._; | |
} finally { | |
d3_time = Date; | |
} | |
}; | |
format.toString = local.toString; | |
return format; | |
}; | |
var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ"); | |
d3.time.format.iso = Date.prototype.toISOString ? d3_time_formatIsoNative : d3_time_formatIso; | |
d3_time_formatIsoNative.parse = function(string) { | |
var date = new Date(string); | |
return isNaN(date) ? null : date; | |
}; | |
d3_time_formatIsoNative.toString = d3_time_formatIso.toString; | |
d3.time.second = d3_time_interval(function(date) { | |
return new d3_time(Math.floor(date / 1e3) * 1e3); | |
}, function(date, offset) { | |
date.setTime(date.getTime() + Math.floor(offset) * 1e3); | |
}, function(date) { | |
return date.getSeconds(); | |
}); | |
d3.time.seconds = d3.time.second.range; | |
d3.time.seconds.utc = d3.time.second.utc.range; | |
d3.time.minute = d3_time_interval(function(date) { | |
return new d3_time(Math.floor(date / 6e4) * 6e4); | |
}, function(date, offset) { | |
date.setTime(date.getTime() + Math.floor(offset) * 6e4); | |
}, function(date) { | |
return date.getMinutes(); | |
}); | |
d3.time.minutes = d3.time.minute.range; | |
d3.time.minutes.utc = d3.time.minute.utc.range; | |
d3.time.hour = d3_time_interval(function(date) { | |
var timezone = date.getTimezoneOffset() / 60; | |
return new d3_time((Math.floor(date / 36e5 - timezone) + timezone) * 36e5); | |
}, function(date, offset) { | |
date.setTime(date.getTime() + Math.floor(offset) * 36e5); | |
}, function(date) { | |
return date.getHours(); | |
}); | |
d3.time.hours = d3.time.hour.range; | |
d3.time.hours.utc = d3.time.hour.utc.range; | |
d3.time.day = d3_time_interval(function(date) { | |
var day = new d3_time(1970, 0); | |
day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); | |
return day; | |
}, function(date, offset) { | |
date.setDate(date.getDate() + offset); | |
}, function(date) { | |
return date.getDate() - 1; | |
}); | |
d3.time.days = d3.time.day.range; | |
d3.time.days.utc = d3.time.day.utc.range; | |
d3.time.dayOfYear = function(date) { | |
var year = d3.time.year(date); | |
return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); | |
}; | |
d3_time_daySymbols.forEach(function(day, i) { | |
day = day.toLowerCase(); | |
i = 7 - i; | |
var interval = d3.time[day] = d3_time_interval(function(date) { | |
(date = d3.time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7); | |
return date; | |
}, function(date, offset) { | |
date.setDate(date.getDate() + Math.floor(offset) * 7); | |
}, function(date) { | |
var day = d3.time.year(date).getDay(); | |
return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i); | |
}); | |
d3.time[day + "s"] = interval.range; | |
d3.time[day + "s"].utc = interval.utc.range; | |
d3.time[day + "OfYear"] = function(date) { | |
var day = d3.time.year(date).getDay(); | |
return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7); | |
}; | |
}); | |
d3.time.week = d3.time.sunday; | |
d3.time.weeks = d3.time.sunday.range; | |
d3.time.weeks.utc = d3.time.sunday.utc.range; | |
d3.time.weekOfYear = d3.time.sundayOfYear; | |
d3.time.month = d3_time_interval(function(date) { | |
date = d3.time.day(date); | |
date.setDate(1); | |
return date; | |
}, function(date, offset) { | |
date.setMonth(date.getMonth() + offset); | |
}, function(date) { | |
return date.getMonth(); | |
}); | |
d3.time.months = d3.time.month.range; | |
d3.time.months.utc = d3.time.month.utc.range; | |
d3.time.year = d3_time_interval(function(date) { | |
date = d3.time.day(date); | |
date.setMonth(0, 1); | |
return date; | |
}, function(date, offset) { | |
date.setFullYear(date.getFullYear() + offset); | |
}, function(date) { | |
return date.getFullYear(); | |
}); | |
d3.time.years = d3.time.year.range; | |
d3.time.years.utc = d3.time.year.utc.range; | |
var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; | |
var d3_time_scaleLocalMethods = [ [ d3.time.second, 1 ], [ d3.time.second, 5 ], [ d3.time.second, 15 ], [ d3.time.second, 30 ], [ d3.time.minute, 1 ], [ d3.time.minute, 5 ], [ d3.time.minute, 15 ], [ d3.time.minute, 30 ], [ d3.time.hour, 1 ], [ d3.time.hour, 3 ], [ d3.time.hour, 6 ], [ d3.time.hour, 12 ], [ d3.time.day, 1 ], [ d3.time.day, 2 ], [ d3.time.week, 1 ], [ d3.time.month, 1 ], [ d3.time.month, 3 ], [ d3.time.year, 1 ] ]; | |
var d3_time_scaleLocalFormats = [ [ d3.time.format("%Y"), function(d) { | |
return true; | |
} ], [ d3.time.format("%B"), function(d) { | |
return d.getMonth(); | |
} ], [ d3.time.format("%b %d"), function(d) { | |
return d.getDate() != 1; | |
} ], [ d3.time.format("%a %d"), function(d) { | |
return d.getDay() && d.getDate() != 1; | |
} ], [ d3.time.format("%I %p"), function(d) { | |
return d.getHours(); | |
} ], [ d3.time.format("%I:%M"), function(d) { | |
return d.getMinutes(); | |
} ], [ d3.time.format(":%S"), function(d) { | |
return d.getSeconds(); | |
} ], [ d3.time.format(".%L"), function(d) { | |
return d.getMilliseconds(); | |
} ] ]; | |
var d3_time_scaleLinear = d3.scale.linear(), d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats); | |
d3_time_scaleLocalMethods.year = function(extent, m) { | |
return d3_time_scaleLinear.domain(extent.map(d3_time_scaleGetYear)).ticks(m).map(d3_time_scaleSetYear); | |
}; | |
d3.time.scale = function() { | |
return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); | |
}; | |
var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) { | |
return [ m[0].utc, m[1] ]; | |
}); | |
var d3_time_scaleUTCFormats = [ [ d3.time.format.utc("%Y"), function(d) { | |
return true; | |
} ], [ d3.time.format.utc("%B"), function(d) { | |
return d.getUTCMonth(); | |
} ], [ d3.time.format.utc("%b %d"), function(d) { | |
return d.getUTCDate() != 1; | |
} ], [ d3.time.format.utc("%a %d"), function(d) { | |
return d.getUTCDay() && d.getUTCDate() != 1; | |
} ], [ d3.time.format.utc("%I %p"), function(d) { | |
return d.getUTCHours(); | |
} ], [ d3.time.format.utc("%I:%M"), function(d) { | |
return d.getUTCMinutes(); | |
} ], [ d3.time.format.utc(":%S"), function(d) { | |
return d.getUTCSeconds(); | |
} ], [ d3.time.format.utc(".%L"), function(d) { | |
return d.getUTCMilliseconds(); | |
} ] ]; | |
var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats); | |
d3_time_scaleUTCMethods.year = function(extent, m) { | |
return d3_time_scaleLinear.domain(extent.map(d3_time_scaleUTCGetYear)).ticks(m).map(d3_time_scaleUTCSetYear); | |
}; | |
d3.time.scale.utc = function() { | |
return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat); | |
}; | |
})(); |
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
source "http://rubygems.org" | |
gem 'rake' | |
gem 'rack' |
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
GEM | |
remote: http://rubygems.org/ | |
specs: | |
rack (1.4.1) | |
rake (0.9.2.2) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
rack | |
rake |
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
<html> | |
<head> | |
<link rel="stylesheet/less" type="text/css" href="style/radar.less"> | |
<link rel="stylesheet" type="text/css" href="style/jquery-ui-1.8.24.custom.css"> | |
<script src="js/less-1.3.0.js"></script> | |
<script src="js/d3.v2.js"></script> | |
<script src="js/underscore.js"></script> | |
<script src="js/jquery-1.8.2.js"></script> | |
<script src="js/jquery-ui-1.8.24.custom.min.js"></script> | |
<script src="js/radar.js"></script> | |
</head> | |
<body> | |
<div id="history" style="display: none"></div> | |
<svg id="radar" width="800" height="800"></svg> | |
</body> | |
</html> |
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
/*! | |
* jQuery JavaScript Library v1.8.2 | |
* http://jquery.com/ | |
* | |
* Includes Sizzle.js | |
* http://sizzlejs.com/ | |
* | |
* Copyright 2012 jQuery Foundation and other contributors | |
* Released under the MIT license | |
* http://jquery.org/license | |
* | |
* Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time) | |
*/ | |
(function( window, undefined ) { | |
var | |
// A central reference to the root jQuery(document) | |
rootjQuery, | |
// The deferred used on DOM ready | |
readyList, | |
// Use the correct document accordingly with window argument (sandbox) | |
document = window.document, | |
location = window.location, | |
navigator = window.navigator, | |
// Map over jQuery in case of overwrite | |
_jQuery = window.jQuery, | |
// Map over the $ in case of overwrite | |
_$ = window.$, | |
// Save a reference to some core methods | |
core_push = Array.prototype.push, | |
core_slice = Array.prototype.slice, | |
core_indexOf = Array.prototype.indexOf, | |
core_toString = Object.prototype.toString, | |
core_hasOwn = Object.prototype.hasOwnProperty, | |
core_trim = String.prototype.trim, | |
// Define a local copy of jQuery | |
jQuery = function( selector, context ) { | |
// The jQuery object is actually just the init constructor 'enhanced' | |
return new jQuery.fn.init( selector, context, rootjQuery ); | |
}, | |
// Used for matching numbers | |
core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, | |
// Used for detecting and trimming whitespace | |
core_rnotwhite = /\S/, | |
core_rspace = /\s+/, | |
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) | |
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, | |
// A simple way to check for HTML strings | |
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521) | |
rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, | |
// Match a standalone tag | |
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, | |
// JSON RegExp | |
rvalidchars = /^[\],:{}\s]*$/, | |
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, | |
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, | |
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, | |
// Matches dashed string for camelizing | |
rmsPrefix = /^-ms-/, | |
rdashAlpha = /-([\da-z])/gi, | |
// Used by jQuery.camelCase as callback to replace() | |
fcamelCase = function( all, letter ) { | |
return ( letter + "" ).toUpperCase(); | |
}, | |
// The ready event handler and self cleanup method | |
DOMContentLoaded = function() { | |
if ( document.addEventListener ) { | |
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); | |
jQuery.ready(); | |
} else if ( document.readyState === "complete" ) { | |
// we're here because readyState === "complete" in oldIE | |
// which is good enough for us to call the dom ready! | |
document.detachEvent( "onreadystatechange", DOMContentLoaded ); | |
jQuery.ready(); | |
} | |
}, | |
// [[Class]] -> type pairs | |
class2type = {}; | |
jQuery.fn = jQuery.prototype = { | |
constructor: jQuery, | |
init: function( selector, context, rootjQuery ) { | |
var match, elem, ret, doc; | |
// Handle $(""), $(null), $(undefined), $(false) | |
if ( !selector ) { | |
return this; | |
} | |
// Handle $(DOMElement) | |
if ( selector.nodeType ) { | |
this.context = this[0] = selector; | |
this.length = 1; | |
return this; | |
} | |
// Handle HTML strings | |
if ( typeof selector === "string" ) { | |
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { | |
// Assume that strings that start and end with <> are HTML and skip the regex check | |
match = [ null, selector, null ]; | |
} else { | |
match = rquickExpr.exec( selector ); | |
} | |
// Match html or make sure no context is specified for #id | |
if ( match && (match[1] || !context) ) { | |
// HANDLE: $(html) -> $(array) | |
if ( match[1] ) { | |
context = context instanceof jQuery ? context[0] : context; | |
doc = ( context && context.nodeType ? context.ownerDocument || context : document ); | |
// scripts is true for back-compat | |
selector = jQuery.parseHTML( match[1], doc, true ); | |
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { | |
this.attr.call( selector, context, true ); | |
} | |
return jQuery.merge( this, selector ); | |
// HANDLE: $(#id) | |
} else { | |
elem = document.getElementById( match[2] ); | |
// Check parentNode to catch when Blackberry 4.6 returns | |
// nodes that are no longer in the document #6963 | |
if ( elem && elem.parentNode ) { | |
// Handle the case where IE and Opera return items | |
// by name instead of ID | |
if ( elem.id !== match[2] ) { | |
return rootjQuery.find( selector ); | |
} | |
// Otherwise, we inject the element directly into the jQuery object | |
this.length = 1; | |
this[0] = elem; | |
} | |
this.context = document; | |
this.selector = selector; | |
return this; | |
} | |
// HANDLE: $(expr, $(...)) | |
} else if ( !context || context.jquery ) { | |
return ( context || rootjQuery ).find( selector ); | |
// HANDLE: $(expr, context) | |
// (which is just equivalent to: $(context).find(expr) | |
} else { | |
return this.constructor( context ).find( selector ); | |
} | |
// HANDLE: $(function) | |
// Shortcut for document ready | |
} 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 ); | |
}, | |
// Start with an empty selector | |
selector: "", | |
// The current version of jQuery being used | |
jquery: "1.8.2", | |
// The default length of a jQuery object is 0 | |
length: 0, | |
// The number of elements contained in the matched element set | |
size: function() { | |
return this.length; | |
}, | |
toArray: function() { | |
return core_slice.call( this ); | |
}, | |
// Get the Nth element in the matched element set OR | |
// Get the whole matched element set as a clean array | |
get: function( num ) { | |
return num == null ? | |
// Return a 'clean' array | |
this.toArray() : | |
// Return just the object | |
( num < 0 ? this[ this.length + num ] : this[ num ] ); | |
}, | |
// Take an array of elements and push it onto the stack | |
// (returning the new matched element set) | |
pushStack: function( elems, name, selector ) { | |
// Build a new jQuery matched element set | |
var ret = jQuery.merge( this.constructor(), elems ); | |
// Add the old object onto the stack (as a reference) | |
ret.prevObject = this; | |
ret.context = this.context; | |
if ( name === "find" ) { | |
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; | |
} else if ( name ) { | |
ret.selector = this.selector + "." + name + "(" + selector + ")"; | |
} | |
// Return the newly-formed element set | |
return ret; | |
}, | |
// Execute a callback for every element in the matched set. | |
// (You can seed the arguments with an array of args, but this is | |
// only used internally.) | |
each: function( callback, args ) { | |
return jQuery.each( this, callback, args ); | |
}, | |
ready: function( fn ) { | |
// Add the callback | |
jQuery.ready.promise().done( fn ); | |
return this; | |
}, | |
eq: function( i ) { | |
i = +i; | |
return i === -1 ? | |
this.slice( i ) : | |
this.slice( i, i + 1 ); | |
}, | |
first: function() { | |
return this.eq( 0 ); | |
}, | |
last: function() { | |
return this.eq( -1 ); | |
}, | |
slice: function() { | |
return this.pushStack( core_slice.apply( this, arguments ), | |
"slice", core_slice.call(arguments).join(",") ); | |
}, | |
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); | |
}, | |
// For internal use only. | |
// Behaves like an Array's method, not like a jQuery method. | |
push: core_push, | |
sort: [].sort, | |
splice: [].splice | |
}; | |
// Give the init function the jQuery prototype for later instantiation | |
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; | |
// Handle a deep copy situation | |
if ( typeof target === "boolean" ) { | |
deep = target; | |
target = arguments[1] || {}; | |
// skip the boolean and the target | |
i = 2; | |
} | |
// Handle case when target is a string or something (possible in deep copy) | |
if ( typeof target !== "object" && !jQuery.isFunction(target) ) { | |
target = {}; | |
} | |
// extend jQuery itself if only one argument is passed | |
if ( length === i ) { | |
target = this; | |
--i; | |
} | |
for ( ; i < length; i++ ) { | |
// Only deal with non-null/undefined values | |
if ( (options = arguments[ i ]) != null ) { | |
// Extend the base object | |
for ( name in options ) { | |
src = target[ name ]; | |
copy = options[ name ]; | |
// Prevent never-ending loop | |
if ( target === copy ) { | |
continue; | |
} | |
// Recurse if we're merging plain objects or arrays | |
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 : {}; | |
} | |
// Never move original objects, clone them | |
target[ name ] = jQuery.extend( deep, clone, copy ); | |
// Don't bring in undefined values | |
} else if ( copy !== undefined ) { | |
target[ name ] = copy; | |
} | |
} | |
} | |
} | |
// Return the modified object | |
return target; | |
}; | |
jQuery.extend({ | |
noConflict: function( deep ) { | |
if ( window.$ === jQuery ) { | |
window.$ = _$; | |
} | |
if ( deep && window.jQuery === jQuery ) { | |
window.jQuery = _jQuery; | |
} | |
return jQuery; | |
}, | |
// Is the DOM ready to be used? Set to true once it occurs. | |
isReady: false, | |
// A counter to track how many items to wait for before | |
// the ready event fires. See #6781 | |
readyWait: 1, | |
// Hold (or release) the ready event | |
holdReady: function( hold ) { | |
if ( hold ) { | |
jQuery.readyWait++; | |
} else { | |
jQuery.ready( true ); | |
} | |
}, | |
// Handle when the DOM is ready | |
ready: function( wait ) { | |
// Abort if there are pending holds or we're already ready | |
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { | |
return; | |
} | |
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). | |
if ( !document.body ) { | |
return setTimeout( jQuery.ready, 1 ); | |
} | |
// Remember that the DOM is ready | |
jQuery.isReady = true; | |
// If a normal DOM Ready event fired, decrement, and wait if need be | |
if ( wait !== true && --jQuery.readyWait > 0 ) { | |
return; | |
} | |
// If there are functions bound, to execute | |
readyList.resolveWith( document, [ jQuery ] ); | |
// Trigger any bound ready events | |
if ( jQuery.fn.trigger ) { | |
jQuery( document ).trigger("ready").off("ready"); | |
} | |
}, | |
// See test/unit/core.js for details concerning isFunction. | |
// Since version 1.3, DOM methods and functions like alert | |
// aren't supported. They return false on IE (#2968). | |
isFunction: function( obj ) { | |
return jQuery.type(obj) === "function"; | |
}, | |
isArray: Array.isArray || function( obj ) { | |
return jQuery.type(obj) === "array"; | |
}, | |
isWindow: function( obj ) { | |
return obj != null && obj == obj.window; | |
}, | |
isNumeric: function( obj ) { | |
return !isNaN( parseFloat(obj) ) && isFinite( obj ); | |
}, | |
type: function( obj ) { | |
return obj == null ? | |
String( obj ) : | |
class2type[ core_toString.call(obj) ] || "object"; | |
}, | |
isPlainObject: function( obj ) { | |
// Must be an Object. | |
// Because of IE, we also have to check the presence of the constructor property. | |
// Make sure that DOM nodes and window objects don't pass through, as well | |
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { | |
return false; | |
} | |
try { | |
// Not own constructor property must be Object | |
if ( obj.constructor && | |
!core_hasOwn.call(obj, "constructor") && | |
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { | |
return false; | |
} | |
} catch ( e ) { | |
// IE8,9 Will throw exceptions on certain host objects #9897 | |
return false; | |
} | |
// Own properties are enumerated firstly, so to speed up, | |
// if last one is own, then all properties are own. | |
var key; | |
for ( key in obj ) {} | |
return key === undefined || core_hasOwn.call( obj, key ); | |
}, | |
isEmptyObject: function( obj ) { | |
var name; | |
for ( name in obj ) { | |
return false; | |
} | |
return true; | |
}, | |
error: function( msg ) { | |
throw new Error( msg ); | |
}, | |
// data: string of html | |
// context (optional): If specified, the fragment will be created in this context, defaults to document | |
// scripts (optional): If true, will include scripts passed in the html string | |
parseHTML: function( data, context, scripts ) { | |
var parsed; | |
if ( !data || typeof data !== "string" ) { | |
return null; | |
} | |
if ( typeof context === "boolean" ) { | |
scripts = context; | |
context = 0; | |
} | |
context = context || document; | |
// Single tag | |
if ( (parsed = rsingleTag.exec( data )) ) { | |
return [ context.createElement( parsed[1] ) ]; | |
} | |
parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] ); | |
return jQuery.merge( [], | |
(parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes ); | |
}, | |
parseJSON: function( data ) { | |
if ( !data || typeof data !== "string") { | |
return null; | |
} | |
// Make sure leading/trailing whitespace is removed (IE can't handle it) | |
data = jQuery.trim( data ); | |
// Attempt to parse using the native JSON parser first | |
if ( window.JSON && window.JSON.parse ) { | |
return window.JSON.parse( data ); | |
} | |
// Make sure the incoming data is actual JSON | |
// Logic borrowed from http://json.org/json2.js | |
if ( rvalidchars.test( data.replace( rvalidescape, "@" ) | |
.replace( rvalidtokens, "]" ) | |
.replace( rvalidbraces, "")) ) { | |
return ( new Function( "return " + data ) )(); | |
} | |
jQuery.error( "Invalid JSON: " + data ); | |
}, | |
// Cross-browser xml parsing | |
parseXML: function( data ) { | |
var xml, tmp; | |
if ( !data || typeof data !== "string" ) { | |
return null; | |
} | |
try { | |
if ( window.DOMParser ) { // Standard | |
tmp = new DOMParser(); | |
xml = tmp.parseFromString( data , "text/xml" ); | |
} else { // IE | |
xml = new ActiveXObject( "Microsoft.XMLDOM" ); | |
xml.async = "false"; | |
xml.loadXML( data ); | |
} | |
} catch( e ) { | |
xml = undefined; | |
} | |
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { | |
jQuery.error( "Invalid XML: " + data ); | |
} | |
return xml; | |
}, | |
noop: function() {}, | |
// Evaluates a script in a global context | |
// Workarounds based on findings by Jim Driscoll | |
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context | |
globalEval: function( data ) { | |
if ( data && core_rnotwhite.test( data ) ) { | |
// We use execScript on Internet Explorer | |
// We use an anonymous function so that context is window | |
// rather than jQuery in Firefox | |
( window.execScript || function( data ) { | |
window[ "eval" ].call( window, data ); | |
} )( data ); | |
} | |
}, | |
// Convert dashed to camelCase; used by the css and data modules | |
// Microsoft forgot to hump their vendor prefix (#9572) | |
camelCase: function( string ) { | |
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); | |
}, | |
nodeName: function( elem, name ) { | |
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); | |
}, | |
// args is for internal usage only | |
each: function( obj, callback, args ) { | |
var name, | |
i = 0, | |
length = obj.length, | |
isObj = length === undefined || jQuery.isFunction( obj ); | |
if ( args ) { | |
if ( isObj ) { | |
for ( name in obj ) { | |
if ( callback.apply( obj[ name ], args ) === false ) { | |
break; | |
} | |
} | |
} else { | |
for ( ; i < length; ) { | |
if ( callback.apply( obj[ i++ ], args ) === false ) { | |
break; | |
} | |
} | |
} | |
// A special, fast, case for the most common use of each | |
} else { | |
if ( isObj ) { | |
for ( name in obj ) { | |
if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) { | |
break; | |
} | |
} | |
} else { | |
for ( ; i < length; ) { | |
if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) { | |
break; | |
} | |
} | |
} | |
} | |
return obj; | |
}, | |
// Use native String.trim function wherever possible | |
trim: core_trim && !core_trim.call("\uFEFF\xA0") ? | |
function( text ) { | |
return text == null ? | |
"" : | |
core_trim.call( text ); | |
} : | |
// Otherwise use our own trimming functionality | |
function( text ) { | |
return text == null ? | |
"" : | |
( text + "" ).replace( rtrim, "" ); | |
}, | |
// results is for internal usage only | |
makeArray: function( arr, results ) { | |
var type, | |
ret = results || []; | |
if ( arr != null ) { | |
// The window, strings (and functions) also have 'length' | |
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 | |
type = jQuery.type( arr ); | |
if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) { | |
core_push.call( ret, arr ); | |
} else { | |
jQuery.merge( ret, arr ); | |
} | |
} | |
return ret; | |
}, | |
inArray: function( elem, arr, i ) { | |
var len; | |
if ( arr ) { | |
if ( core_indexOf ) { | |
return core_indexOf.call( arr, elem, i ); | |
} | |
len = arr.length; | |
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; | |
for ( ; i < len; i++ ) { | |
// Skip accessing in sparse arrays | |
if ( i in arr && arr[ i ] === elem ) { | |
return i; | |
} | |
} | |
} | |
return -1; | |
}, | |
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; | |
// Go through the array, only saving the items | |
// that pass the validator function | |
for ( ; i < length; i++ ) { | |
retVal = !!callback( elems[ i ], i ); | |
if ( inv !== retVal ) { | |
ret.push( elems[ i ] ); | |
} | |
} | |
return ret; | |
}, | |
// arg is for internal usage only | |
map: function( elems, callback, arg ) { | |
var value, key, | |
ret = [], | |
i = 0, | |
length = elems.length, | |
// jquery objects are treated as arrays | |
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; | |
// Go through the array, translating each of the items to their | |
if ( isArray ) { | |
for ( ; i < length; i++ ) { | |
value = callback( elems[ i ], i, arg ); | |
if ( value != null ) { | |
ret[ ret.length ] = value; | |
} | |
} | |
// Go through every key on the object, | |
} else { | |
for ( key in elems ) { | |
value = callback( elems[ key ], key, arg ); | |
if ( value != null ) { | |
ret[ ret.length ] = value; | |
} | |
} | |
} | |
// Flatten any nested arrays | |
return ret.concat.apply( [], ret ); | |
}, | |
// A global GUID counter for objects | |
guid: 1, | |
// Bind a function to a context, optionally partially applying any | |
// arguments. | |
proxy: function( fn, context ) { | |
var tmp, args, proxy; | |
if ( typeof context === "string" ) { | |
tmp = fn[ context ]; | |
context = fn; | |
fn = tmp; | |
} | |
// Quick check to determine if target is callable, in the spec | |
// this throws a TypeError, but we will just return undefined. | |
if ( !jQuery.isFunction( fn ) ) { | |
return undefined; | |
} | |
// Simulated bind | |
args = core_slice.call( arguments, 2 ); | |
proxy = function() { | |
return fn.apply( context, args.concat( core_slice.call( arguments ) ) ); | |
}; | |
// Set the guid of unique handler to the same of original handler, so it can be removed | |
proxy.guid = fn.guid = fn.guid || jQuery.guid++; | |
return proxy; | |
}, | |
// Multifunctional method to get and set values of a collection | |
// The value/s can optionally be executed if it's a function | |
access: function( elems, fn, key, value, chainable, emptyGet, pass ) { | |
var exec, | |
bulk = key == null, | |
i = 0, | |
length = elems.length; | |
// Sets many values | |
if ( key && typeof key === "object" ) { | |
for ( i in key ) { | |
jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); | |
} | |
chainable = 1; | |
// Sets one value | |
} else if ( value !== undefined ) { | |
// Optionally, function values get executed if exec is true | |
exec = pass === undefined && jQuery.isFunction( value ); | |
if ( bulk ) { | |
// Bulk operations only iterate when executing function values | |
if ( exec ) { | |
exec = fn; | |
fn = function( elem, key, value ) { | |
return exec.call( jQuery( elem ), value ); | |
}; | |
// Otherwise they run against the entire set | |
} else { | |
fn.call( elems, value ); | |
fn = null; | |
} | |
} | |
if ( fn ) { | |
for (; i < length; i++ ) { | |
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); | |
} | |
} | |
chainable = 1; | |
} | |
return chainable ? | |
elems : | |
// Gets | |
bulk ? | |
fn.call( elems ) : | |
length ? fn( elems[0], key ) : emptyGet; | |
}, | |
now: function() { | |
return ( new Date() ).getTime(); | |
} | |
}); | |
jQuery.ready.promise = function( obj ) { | |
if ( !readyList ) { | |
readyList = jQuery.Deferred(); | |
// Catch cases where $(document).ready() is called after the browser event has already occurred. | |
// we once tried to use readyState "interactive" here, but it caused issues like the one | |
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 | |
if ( document.readyState === "complete" ) { | |
// Handle it asynchronously to allow scripts the opportunity to delay ready | |
setTimeout( jQuery.ready, 1 ); | |
// Standards-based browsers support DOMContentLoaded | |
} else if ( document.addEventListener ) { | |
// Use the handy event callback | |
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); | |
// A fallback to window.onload, that will always work | |
window.addEventListener( "load", jQuery.ready, false ); | |
// If IE event model is used | |
} else { | |
// Ensure firing before onload, maybe late but safe also for iframes | |
document.attachEvent( "onreadystatechange", DOMContentLoaded ); | |
// A fallback to window.onload, that will always work | |
window.attachEvent( "onload", jQuery.ready ); | |
// If IE and not a frame | |
// continually check to see if the document is ready | |
var top = false; | |
try { | |
top = window.frameElement == null && document.documentElement; | |
} catch(e) {} | |
if ( top && top.doScroll ) { | |
(function doScrollCheck() { | |
if ( !jQuery.isReady ) { | |
try { | |
// Use the trick by Diego Perini | |
// http://javascript.nwbox.com/IEContentLoaded/ | |
top.doScroll("left"); | |
} catch(e) { | |
return setTimeout( doScrollCheck, 50 ); | |
} | |
// and execute any waiting functions | |
jQuery.ready(); | |
} | |
})(); | |
} | |
} | |
} | |
return readyList.promise( obj ); | |
}; | |
// Populate the class2type map | |
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { | |
class2type[ "[object " + name + "]" ] = name.toLowerCase(); | |
}); | |
// All jQuery objects should point back to these | |
rootjQuery = jQuery(document); | |
// String to Object options format cache | |
var optionsCache = {}; | |
// Convert String-formatted options into Object-formatted ones and store in cache | |
function createOptions( options ) { | |
var object = optionsCache[ options ] = {}; | |
jQuery.each( options.split( core_rspace ), function( _, flag ) { | |
object[ flag ] = true; | |
}); | |
return object; | |
} | |
/* | |
* Create a callback list using the following parameters: | |
* | |
* options: an optional list of space-separated options that will change how | |
* the callback list behaves or a more traditional option object | |
* | |
* By default a callback list will act like an event callback list and can be | |
* "fired" multiple times. | |
* | |
* Possible options: | |
* | |
* once: will ensure the callback list can only be fired once (like a Deferred) | |
* | |
* memory: will keep track of previous values and will call any callback added | |
* after the list has been fired right away with the latest "memorized" | |
* values (like a Deferred) | |
* | |
* unique: will ensure a callback can only be added once (no duplicate in the list) | |
* | |
* stopOnFalse: interrupt callings when a callback returns false | |
* | |
*/ | |
jQuery.Callbacks = function( options ) { | |
// Convert options from String-formatted to Object-formatted if needed | |
// (we check in cache first) | |
options = typeof options === "string" ? | |
( optionsCache[ options ] || createOptions( options ) ) : | |
jQuery.extend( {}, options ); | |
var // Last fire value (for non-forgettable lists) | |
memory, | |
// Flag to know if list was already fired | |
fired, | |
// Flag to know if list is currently firing | |
firing, | |
// First callback to fire (used internally by add and fireWith) | |
firingStart, | |
// End of the loop when firing | |
firingLength, | |
// Index of currently firing callback (modified by remove if needed) | |
firingIndex, | |
// Actual callback list | |
list = [], | |
// Stack of fire calls for repeatable lists | |
stack = !options.once && [], | |
// Fire callbacks | |
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; // To prevent further calls using add | |
break; | |
} | |
} | |
firing = false; | |
if ( list ) { | |
if ( stack ) { | |
if ( stack.length ) { | |
fire( stack.shift() ); | |
} | |
} else if ( memory ) { | |
list = []; | |
} else { | |
self.disable(); | |
} | |
} | |
}, | |
// Actual Callbacks object | |
self = { | |
// Add a callback or a collection of callbacks to the list | |
add: function() { | |
if ( list ) { | |
// First, we save the current length | |
var start = list.length; | |
(function add( args ) { | |
jQuery.each( args, function( _, arg ) { | |
var type = jQuery.type( arg ); | |
if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) { | |
list.push( arg ); | |
} else if ( arg && arg.length && type !== "string" ) { | |
// Inspect recursively | |
add( arg ); | |
} | |
}); | |
})( arguments ); | |
// Do we need to add the callbacks to the | |
// current firing batch? | |
if ( firing ) { | |
firingLength = list.length; | |
// With memory, if we're not firing then | |
// we should call right away | |
} else if ( memory ) { | |
firingStart = start; | |
fire( memory ); | |
} | |
} | |
return this; | |
}, | |
// Remove a callback from the list | |
remove: function() { | |
if ( list ) { | |
jQuery.each( arguments, function( _, arg ) { | |
var index; | |
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { | |
list.splice( index, 1 ); | |
// Handle firing indexes | |
if ( firing ) { | |
if ( index <= firingLength ) { | |
firingLength--; | |
} | |
if ( index <= firingIndex ) { | |
firingIndex--; | |
} | |
} | |
} | |
}); | |
} | |
return this; | |
}, | |
// Control if a given callback is in the list | |
has: function( fn ) { | |
return jQuery.inArray( fn, list ) > -1; | |
}, | |
// Remove all callbacks from the list | |
empty: function() { | |
list = []; | |
return this; | |
}, | |
// Have the list do nothing anymore | |
disable: function() { | |
list = stack = memory = undefined; | |
return this; | |
}, | |
// Is it disabled? | |
disabled: function() { | |
return !list; | |
}, | |
// Lock the list in its current state | |
lock: function() { | |
stack = undefined; | |
if ( !memory ) { | |
self.disable(); | |
} | |
return this; | |
}, | |
// Is it locked? | |
locked: function() { | |
return !stack; | |
}, | |
// Call all callbacks with the given context and arguments | |
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; | |
}, | |
// Call all the callbacks with the given arguments | |
fire: function() { | |
self.fireWith( this, arguments ); | |
return this; | |
}, | |
// To know if the callbacks have already been called at least once | |
fired: function() { | |
return !!fired; | |
} | |
}; | |
return self; | |
}; | |
jQuery.extend({ | |
Deferred: function( func ) { | |
var tuples = [ | |
// action, add listener, listener list, final state | |
[ "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( /* fnDone, fnFail, fnProgress */ ) { | |
var fns = arguments; | |
return jQuery.Deferred(function( newDefer ) { | |
jQuery.each( tuples, function( i, tuple ) { | |
var action = tuple[ 0 ], | |
fn = fns[ i ]; | |
// deferred[ done | fail | progress ] for forwarding actions to newDefer | |
deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? | |
function() { | |
var returned = 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 === deferred ? newDefer : this, [ returned ] ); | |
} | |
} : | |
newDefer[ action ] | |
); | |
}); | |
fns = null; | |
}).promise(); | |
}, | |
// Get a promise for this deferred | |
// If obj is provided, the promise aspect is added to the object | |
promise: function( obj ) { | |
return obj != null ? jQuery.extend( obj, promise ) : promise; | |
} | |
}, | |
deferred = {}; | |
// Keep pipe for back-compat | |
promise.pipe = promise.then; | |
// Add list-specific methods | |
jQuery.each( tuples, function( i, tuple ) { | |
var list = tuple[ 2 ], | |
stateString = tuple[ 3 ]; | |
// promise[ done | fail | progress ] = list.add | |
promise[ tuple[1] ] = list.add; | |
// Handle state | |
if ( stateString ) { | |
list.add(function() { | |
// state = [ resolved | rejected ] | |
state = stateString; | |
// [ reject_list | resolve_list ].disable; progress_list.lock | |
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); | |
} | |
// deferred[ resolve | reject | notify ] = list.fire | |
deferred[ tuple[0] ] = list.fire; | |
deferred[ tuple[0] + "With" ] = list.fireWith; | |
}); | |
// Make the deferred a promise | |
promise.promise( deferred ); | |
// Call given func if any | |
if ( func ) { | |
func.call( deferred, deferred ); | |
} | |
// All done! | |
return deferred; | |
}, | |
// Deferred helper | |
when: function( subordinate /* , ..., subordinateN */ ) { | |
var i = 0, | |
resolveValues = core_slice.call( arguments ), | |
length = resolveValues.length, | |
// the count of uncompleted subordinates | |
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, | |
// the master Deferred. If resolveValues consist of only a single Deferred, just use that. | |
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), | |
// Update function for both resolve and progress values | |
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; | |
// add listeners to Deferred subordinates; treat others as resolved | |
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 we're not waiting on anything, resolve the master | |
if ( !remaining ) { | |
deferred.resolveWith( resolveContexts, resolveValues ); | |
} | |
return deferred.promise(); | |
} | |
}); | |
jQuery.support = (function() { | |
var support, | |
all, | |
a, | |
select, | |
opt, | |
input, | |
fragment, | |
eventName, | |
i, | |
isSupported, | |
clickFn, | |
div = document.createElement("div"); | |
// Preliminary tests | |
div.setAttribute( "className", "t" ); | |
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; | |
all = div.getElementsByTagName("*"); | |
a = div.getElementsByTagName("a")[ 0 ]; | |
a.style.cssText = "top:1px;float:left;opacity:.5"; | |
// Can't get basic test support | |
if ( !all || !all.length ) { | |
return {}; | |
} | |
// First batch of supports tests | |
select = document.createElement("select"); | |
opt = select.appendChild( document.createElement("option") ); | |
input = div.getElementsByTagName("input")[ 0 ]; | |
support = { | |
// IE strips leading whitespace when .innerHTML is used | |
leadingWhitespace: ( div.firstChild.nodeType === 3 ), | |
// Make sure that tbody elements aren't automatically inserted | |
// IE will insert them into empty tables | |
tbody: !div.getElementsByTagName("tbody").length, | |
// Make sure that link elements get serialized correctly by innerHTML | |
// This requires a wrapper element in IE | |
htmlSerialize: !!div.getElementsByTagName("link").length, | |
// Get the style information from getAttribute | |
// (IE uses .cssText instead) | |
style: /top/.test( a.getAttribute("style") ), | |
// Make sure that URLs aren't manipulated | |
// (IE normalizes it by default) | |
hrefNormalized: ( a.getAttribute("href") === "/a" ), | |
// Make sure that element opacity exists | |
// (IE uses filter instead) | |
// Use a regex to work around a WebKit issue. See #5145 | |
opacity: /^0.5/.test( a.style.opacity ), | |
// Verify style float existence | |
// (IE uses styleFloat instead of cssFloat) | |
cssFloat: !!a.style.cssFloat, | |
// Make sure that if no value is specified for a checkbox | |
// that it defaults to "on". | |
// (WebKit defaults to "" instead) | |
checkOn: ( input.value === "on" ), | |
// Make sure that a selected-by-default option has a working selected property. | |
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup) | |
optSelected: opt.selected, | |
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) | |
getSetAttribute: div.className !== "t", | |
// Tests for enctype support on a form(#6743) | |
enctype: !!document.createElement("form").enctype, | |
// Makes sure cloning an html5 element does not cause problems | |
// Where outerHTML is undefined, this still works | |
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>", | |
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode | |
boxModel: ( document.compatMode === "CSS1Compat" ), | |
// Will be defined later | |
submitBubbles: true, | |
changeBubbles: true, | |
focusinBubbles: false, | |
deleteExpando: true, | |
noCloneEvent: true, | |
inlineBlockNeedsLayout: false, | |
shrinkWrapBlocks: false, | |
reliableMarginRight: true, | |
boxSizingReliable: true, | |
pixelPosition: false | |
}; | |
// Make sure checked status is properly cloned | |
input.checked = true; | |
support.noCloneChecked = input.cloneNode( true ).checked; | |
// Make sure that the options inside disabled selects aren't marked as disabled | |
// (WebKit marks them as disabled) | |
select.disabled = true; | |
support.optDisabled = !opt.disabled; | |
// Test to see if it's possible to delete an expando from an element | |
// Fails in Internet Explorer | |
try { | |
delete div.test; | |
} catch( e ) { | |
support.deleteExpando = false; | |
} | |
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { | |
div.attachEvent( "onclick", clickFn = function() { | |
// Cloning a node shouldn't copy over any | |
// bound event handlers (IE does this) | |
support.noCloneEvent = false; | |
}); | |
div.cloneNode( true ).fireEvent("onclick"); | |
div.detachEvent( "onclick", clickFn ); | |
} | |
// Check if a radio maintains its value | |
// after being appended to the DOM | |
input = document.createElement("input"); | |
input.value = "t"; | |
input.setAttribute( "type", "radio" ); | |
support.radioValue = input.value === "t"; | |
input.setAttribute( "checked", "checked" ); | |
// #11217 - WebKit loses check when the name is after the checked attribute | |
input.setAttribute( "name", "t" ); | |
div.appendChild( input ); | |
fragment = document.createDocumentFragment(); | |
fragment.appendChild( div.lastChild ); | |
// WebKit doesn't clone checked state correctly in fragments | |
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; | |
// Check if a disconnected checkbox will retain its checked | |
// value of true after appended to the DOM (IE6/7) | |
support.appendChecked = input.checked; | |
fragment.removeChild( input ); | |
fragment.appendChild( div ); | |
// Technique from Juriy Zaytsev | |
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ | |
// We only care about the case where non-standard event systems | |
// are used, namely in IE. Short-circuiting here helps us to | |
// avoid an eval call (in setAttribute) which can cause CSP | |
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP | |
if ( div.attachEvent ) { | |
for ( i in { | |
submit: true, | |
change: true, | |
focusin: true | |
}) { | |
eventName = "on" + i; | |
isSupported = ( eventName in div ); | |
if ( !isSupported ) { | |
div.setAttribute( eventName, "return;" ); | |
isSupported = ( typeof div[ eventName ] === "function" ); | |
} | |
support[ i + "Bubbles" ] = isSupported; | |
} | |
} | |
// Run tests that need a body at doc ready | |
jQuery(function() { | |
var container, div, tds, marginDiv, | |
divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", | |
body = document.getElementsByTagName("body")[0]; | |
if ( !body ) { | |
// Return for frameset docs that don't have a body | |
return; | |
} | |
container = document.createElement("div"); | |
container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; | |
body.insertBefore( container, body.firstChild ); | |
// Construct the test element | |
div = document.createElement("div"); | |
container.appendChild( div ); | |
// Check if table cells still have offsetWidth/Height when they are set | |
// to display:none and there are still other visible table cells in a | |
// table row; if so, offsetWidth/Height are not reliable for use when | |
// determining if an element has been hidden directly using | |
// display:none (it is still safe to use offsets if a parent element is | |
// hidden; don safety goggles and see bug #4512 for more information). | |
// (only IE 8 fails this test) | |
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; | |
tds = div.getElementsByTagName("td"); | |
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; | |
isSupported = ( tds[ 0 ].offsetHeight === 0 ); | |
tds[ 0 ].style.display = ""; | |
tds[ 1 ].style.display = "none"; | |
// Check if empty table cells still have offsetWidth/Height | |
// (IE <= 8 fail this test) | |
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); | |
// Check box-sizing and margin behavior | |
div.innerHTML = ""; | |
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; | |
support.boxSizing = ( div.offsetWidth === 4 ); | |
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); | |
// NOTE: To any future maintainer, we've window.getComputedStyle | |
// because jsdom on node.js will break without it. | |
if ( window.getComputedStyle ) { | |
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; | |
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; | |
// Check if div with explicit width and no margin-right incorrectly | |
// gets computed margin-right based on width of container. For more | |
// info see bug #3333 | |
// Fails in WebKit before Feb 2011 nightlies | |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | |
marginDiv = document.createElement("div"); | |
marginDiv.style.cssText = div.style.cssText = divReset; | |
marginDiv.style.marginRight = marginDiv.style.width = "0"; | |
div.style.width = "1px"; | |
div.appendChild( marginDiv ); | |
support.reliableMarginRight = | |
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); | |
} | |
if ( typeof div.style.zoom !== "undefined" ) { | |
// Check if natively block-level elements act like inline-block | |
// elements when setting their display to 'inline' and giving | |
// them layout | |
// (IE < 8 does this) | |
div.innerHTML = ""; | |
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; | |
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); | |
// Check if elements with layout shrink-wrap their children | |
// (IE 6 does this) | |
div.style.display = "block"; | |
div.style.overflow = "visible"; | |
div.innerHTML = "<div></div>"; | |
div.firstChild.style.width = "5px"; | |
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); | |
container.style.zoom = 1; | |
} | |
// Null elements to avoid leaks in IE | |
body.removeChild( container ); | |
container = div = tds = marginDiv = null; | |
}); | |
// Null elements to avoid leaks in IE | |
fragment.removeChild( div ); | |
all = a = select = opt = input = fragment = div = null; | |
return support; | |
})(); | |
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, | |
rmultiDash = /([A-Z])/g; | |
jQuery.extend({ | |
cache: {}, | |
deletedIds: [], | |
// Remove at next major release (1.9/2.0) | |
uuid: 0, | |
// Unique for each copy of jQuery on the page | |
// Non-digits removed to match rinlinejQuery | |
expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), | |
// The following elements throw uncatchable exceptions if you | |
// attempt to add expando properties to them. | |
noData: { | |
"embed": true, | |
// Ban all objects except for Flash (which handle expandos) | |
"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", | |
"applet": true | |
}, | |
hasData: function( elem ) { | |
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; | |
return !!elem && !isEmptyDataObject( elem ); | |
}, | |
data: function( elem, name, data, pvt /* Internal Use Only */ ) { | |
if ( !jQuery.acceptData( elem ) ) { | |
return; | |
} | |
var thisCache, ret, | |
internalKey = jQuery.expando, | |
getByName = typeof name === "string", | |
// We have to handle DOM nodes and JS objects differently because IE6-7 | |
// can't GC object references properly across the DOM-JS boundary | |
isNode = elem.nodeType, | |
// Only DOM nodes need the global jQuery cache; JS object data is | |
// attached directly to the object so GC can occur automatically | |
cache = isNode ? jQuery.cache : elem, | |
// Only defining an ID for JS objects if its cache already exists allows | |
// the code to shortcut on the same path as a DOM node with no cache | |
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; | |
// Avoid doing any more work than we need to when trying to get data on an | |
// object that has no data at all | |
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { | |
return; | |
} | |
if ( !id ) { | |
// Only DOM nodes need a new unique ID for each element since their data | |
// ends up in the global cache | |
if ( isNode ) { | |
elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++; | |
} else { | |
id = internalKey; | |
} | |
} | |
if ( !cache[ id ] ) { | |
cache[ id ] = {}; | |
// Avoids exposing jQuery metadata on plain JS objects when the object | |
// is serialized using JSON.stringify | |
if ( !isNode ) { | |
cache[ id ].toJSON = jQuery.noop; | |
} | |
} | |
// An object can be passed to jQuery.data instead of a key/value pair; this gets | |
// shallow copied over onto the existing cache | |
if ( typeof name === "object" || typeof name === "function" ) { | |
if ( pvt ) { | |
cache[ id ] = jQuery.extend( cache[ id ], name ); | |
} else { | |
cache[ id ].data = jQuery.extend( cache[ id ].data, name ); | |
} | |
} | |
thisCache = cache[ id ]; | |
// jQuery data() is stored in a separate object inside the object's internal data | |
// cache in order to avoid key collisions between internal data and user-defined | |
// data. | |
if ( !pvt ) { | |
if ( !thisCache.data ) { | |
thisCache.data = {}; | |
} | |
thisCache = thisCache.data; | |
} | |
if ( data !== undefined ) { | |
thisCache[ jQuery.camelCase( name ) ] = data; | |
} | |
// Check for both converted-to-camel and non-converted data property names | |
// If a data property was specified | |
if ( getByName ) { | |
// First Try to find as-is property data | |
ret = thisCache[ name ]; | |
// Test for null|undefined property data | |
if ( ret == null ) { | |
// Try to find the camelCased property | |
ret = thisCache[ jQuery.camelCase( name ) ]; | |
} | |
} else { | |
ret = thisCache; | |
} | |
return ret; | |
}, | |
removeData: function( elem, name, pvt /* Internal Use Only */ ) { | |
if ( !jQuery.acceptData( elem ) ) { | |
return; | |
} | |
var thisCache, i, l, | |
isNode = elem.nodeType, | |
// See jQuery.data for more information | |
cache = isNode ? jQuery.cache : elem, | |
id = isNode ? elem[ jQuery.expando ] : jQuery.expando; | |
// If there is already no cache entry for this object, there is no | |
// purpose in continuing | |
if ( !cache[ id ] ) { | |
return; | |
} | |
if ( name ) { | |
thisCache = pvt ? cache[ id ] : cache[ id ].data; | |
if ( thisCache ) { | |
// Support array or space separated string names for data keys | |
if ( !jQuery.isArray( name ) ) { | |
// try the string as a key before any manipulation | |
if ( name in thisCache ) { | |
name = [ name ]; | |
} else { | |
// split the camel cased version by spaces unless a key with the spaces exists | |
name = jQuery.camelCase( name ); | |
if ( name in thisCache ) { | |
name = [ name ]; | |
} else { | |
name = name.split(" "); | |
} | |
} | |
} | |
for ( i = 0, l = name.length; i < l; i++ ) { | |
delete thisCache[ name[i] ]; | |
} | |
// If there is no data left in the cache, we want to continue | |
// and let the cache object itself get destroyed | |
if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { | |
return; | |
} | |
} | |
} | |
// See jQuery.data for more information | |
if ( !pvt ) { | |
delete cache[ id ].data; | |
// Don't destroy the parent cache unless the internal data object | |
// had been the only thing left in it | |
if ( !isEmptyDataObject( cache[ id ] ) ) { | |
return; | |
} | |
} | |
// Destroy the cache | |
if ( isNode ) { | |
jQuery.cleanData( [ elem ], true ); | |
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) | |
} else if ( jQuery.support.deleteExpando || cache != cache.window ) { | |
delete cache[ id ]; | |
// When all else fails, null | |
} else { | |
cache[ id ] = null; | |
} | |
}, | |
// For internal use only. | |
_data: function( elem, name, data ) { | |
return jQuery.data( elem, name, data, true ); | |
}, | |
// A method for determining if a DOM node can handle the data expando | |
acceptData: function( elem ) { | |
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; | |
// nodes accept data unless otherwise specified; rejection can be conditional | |
return !noData || noData !== true && elem.getAttribute("classid") === noData; | |
} | |
}); | |
jQuery.fn.extend({ | |
data: function( key, value ) { | |
var parts, part, attr, name, l, | |
elem = this[0], | |
i = 0, | |
data = null; | |
// Gets all values | |
if ( key === undefined ) { | |
if ( this.length ) { | |
data = jQuery.data( elem ); | |
if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { | |
attr = elem.attributes; | |
for ( l = attr.length; i < l; i++ ) { | |
name = attr[i].name; | |
if ( !name.indexOf( "data-" ) ) { | |
name = jQuery.camelCase( name.substring(5) ); | |
dataAttr( elem, name, data[ name ] ); | |
} | |
} | |
jQuery._data( elem, "parsedAttrs", true ); | |
} | |
} | |
return data; | |
} | |
// Sets multiple values | |
if ( typeof key === "object" ) { | |
return this.each(function() { | |
jQuery.data( this, key ); | |
}); | |
} | |
parts = key.split( ".", 2 ); | |
parts[1] = parts[1] ? "." + parts[1] : ""; | |
part = parts[1] + "!"; | |
return jQuery.access( this, function( value ) { | |
if ( value === undefined ) { | |
data = this.triggerHandler( "getData" + part, [ parts[0] ] ); | |
// Try to fetch any internally stored data first | |
if ( data === undefined && elem ) { | |
data = jQuery.data( elem, key ); | |
data = dataAttr( elem, key, data ); | |
} | |
return data === undefined && parts[1] ? | |
this.data( parts[0] ) : | |
data; | |
} | |
parts[1] = value; | |
this.each(function() { | |
var self = jQuery( this ); | |
self.triggerHandler( "setData" + part, parts ); | |
jQuery.data( this, key, value ); | |
self.triggerHandler( "changeData" + part, parts ); | |
}); | |
}, null, value, arguments.length > 1, null, false ); | |
}, | |
removeData: function( key ) { | |
return this.each(function() { | |
jQuery.removeData( this, key ); | |
}); | |
} | |
}); | |
function dataAttr( elem, key, data ) { | |
// If nothing was found internally, try to fetch any | |
// data from the HTML5 data-* attribute | |
if ( data === undefined && elem.nodeType === 1 ) { | |
var 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 : | |
// Only convert to a number if it doesn't change the string | |
+data + "" === data ? +data : | |
rbrace.test( data ) ? jQuery.parseJSON( data ) : | |
data; | |
} catch( e ) {} | |
// Make sure we set the data so it isn't changed later | |
jQuery.data( elem, key, data ); | |
} else { | |
data = undefined; | |
} | |
} | |
return data; | |
} | |
// checks a cache object for emptiness | |
function isEmptyDataObject( obj ) { | |
var name; | |
for ( name in obj ) { | |
// if the public data object is empty, the private is still empty | |
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { | |
continue; | |
} | |
if ( name !== "toJSON" ) { | |
return false; | |
} | |
} | |
return true; | |
} | |
jQuery.extend({ | |
queue: function( elem, type, data ) { | |
var queue; | |
if ( elem ) { | |
type = ( type || "fx" ) + "queue"; | |
queue = jQuery._data( elem, type ); | |
// Speed up dequeue by getting out quickly if this is just a lookup | |
if ( data ) { | |
if ( !queue || jQuery.isArray(data) ) { | |
queue = jQuery._data( 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 the fx queue is dequeued, always remove the progress sentinel | |
if ( fn === "inprogress" ) { | |
fn = queue.shift(); | |
startLength--; | |
} | |
if ( fn ) { | |
// Add a progress sentinel to prevent the fx queue from being | |
// automatically dequeued | |
if ( type === "fx" ) { | |
queue.unshift( "inprogress" ); | |
} | |
// clear up the last queue stop function | |
delete hooks.stop; | |
fn.call( elem, next, hooks ); | |
} | |
if ( !startLength && hooks ) { | |
hooks.empty.fire(); | |
} | |
}, | |
// not intended for public consumption - generates a queueHooks object, or returns the current one | |
_queueHooks: function( elem, type ) { | |
var key = type + "queueHooks"; | |
return jQuery._data( elem, key ) || jQuery._data( elem, key, { | |
empty: jQuery.Callbacks("once memory").add(function() { | |
jQuery.removeData( elem, type + "queue", true ); | |
jQuery.removeData( elem, key, true ); | |
}) | |
}); | |
} | |
}); | |
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 ); | |
// ensure a hooks for this queue | |
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 ); | |
}); | |
}, | |
// Based off of the plugin by Clint Helfers, with permission. | |
// http://blindsignals.com/index.php/2009/07/jquery-delay/ | |
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", [] ); | |
}, | |
// Get a promise resolved when queues of a certain type | |
// are emptied (fx is the type by default) | |
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 = jQuery._data( elements[ i ], type + "queueHooks" ); | |
if ( tmp && tmp.empty ) { | |
count++; | |
tmp.empty.add( resolve ); | |
} | |
} | |
resolve(); | |
return defer.promise( obj ); | |
} | |
}); | |
var nodeHook, boolHook, fixSpecified, | |
rclass = /[\t\r\n]/g, | |
rreturn = /\r/g, | |
rtype = /^(?:button|input)$/i, | |
rfocusable = /^(?:button|input|object|select|textarea)$/i, | |
rclickable = /^a(?:rea|)$/i, | |
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, | |
getSetAttribute = jQuery.support.getSetAttribute; | |
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 ) { | |
name = jQuery.propFix[ name ] || name; | |
return this.each(function() { | |
// try/catch handles cases where IE balks (such as removing a property on window) | |
try { | |
this[ name ] = undefined; | |
delete this[ name ]; | |
} catch( e ) {} | |
}); | |
}, | |
addClass: function( value ) { | |
var classNames, i, l, elem, | |
setClass, c, cl; | |
if ( jQuery.isFunction( value ) ) { | |
return this.each(function( j ) { | |
jQuery( this ).addClass( value.call(this, j, this.className) ); | |
}); | |
} | |
if ( value && typeof value === "string" ) { | |
classNames = value.split( core_rspace ); | |
for ( i = 0, l = this.length; i < l; i++ ) { | |
elem = this[ i ]; | |
if ( elem.nodeType === 1 ) { | |
if ( !elem.className && classNames.length === 1 ) { | |
elem.className = value; | |
} else { | |
setClass = " " + elem.className + " "; | |
for ( c = 0, cl = classNames.length; c < cl; c++ ) { | |
if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) { | |
setClass += classNames[ c ] + " "; | |
} | |
} | |
elem.className = jQuery.trim( setClass ); | |
} | |
} | |
} | |
} | |
return this; | |
}, | |
removeClass: function( value ) { | |
var removes, className, elem, c, cl, i, l; | |
if ( jQuery.isFunction( value ) ) { | |
return this.each(function( j ) { | |
jQuery( this ).removeClass( value.call(this, j, this.className) ); | |
}); | |
} | |
if ( (value && typeof value === "string") || value === undefined ) { | |
removes = ( value || "" ).split( core_rspace ); | |
for ( i = 0, l = this.length; i < l; i++ ) { | |
elem = this[ i ]; | |
if ( elem.nodeType === 1 && elem.className ) { | |
className = (" " + elem.className + " ").replace( rclass, " " ); | |
// loop over each item in the removal list | |
for ( c = 0, cl = removes.length; c < cl; c++ ) { | |
// Remove until there is nothing to remove, | |
while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) { | |
className = className.replace( " " + removes[ c ] + " " , " " ); | |
} | |
} | |
elem.className = value ? jQuery.trim( className ) : ""; | |
} | |
} | |
} | |
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" ) { | |
// toggle individual class names | |
var className, | |
i = 0, | |
self = jQuery( this ), | |
state = stateVal, | |
classNames = value.split( core_rspace ); | |
while ( (className = classNames[ i++ ]) ) { | |
// check each className given, space separated list | |
state = isBool ? state : !self.hasClass( className ); | |
self[ state ? "addClass" : "removeClass" ]( className ); | |
} | |
} else if ( type === "undefined" || type === "boolean" ) { | |
if ( this.className ) { | |
// store className if set | |
jQuery._data( this, "__className__", this.className ); | |
} | |
// toggle whole className | |
this.className = this.className || value === false ? "" : jQuery._data( 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" ? | |
// handle most common string cases | |
ret.replace(rreturn, "") : | |
// handle cases where value is null/undef or number | |
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; | |
} | |
// Treat null/undefined as ""; convert numbers to string | |
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 set returns undefined, fall back to normal setting | |
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { | |
this.value = val; | |
} | |
}); | |
} | |
}); | |
jQuery.extend({ | |
valHooks: { | |
option: { | |
get: function( elem ) { | |
// attributes.value is undefined in Blackberry 4.7 but | |
// uses .value. See #6932 | |
var val = elem.attributes.value; | |
return !val || val.specified ? elem.value : elem.text; | |
} | |
}, | |
select: { | |
get: function( elem ) { | |
var value, i, max, option, | |
index = elem.selectedIndex, | |
values = [], | |
options = elem.options, | |
one = elem.type === "select-one"; | |
// Nothing was selected | |
if ( index < 0 ) { | |
return null; | |
} | |
// Loop through all the selected options | |
i = one ? index : 0; | |
max = one ? index + 1 : options.length; | |
for ( ; i < max; i++ ) { | |
option = options[ i ]; | |
// Don't return options that are disabled or in a disabled optgroup | |
if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && | |
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { | |
// Get the specific value for the option | |
value = jQuery( option ).val(); | |
// We don't need an array for one selects | |
if ( one ) { | |
return value; | |
} | |
// Multi-Selects return an array | |
values.push( value ); | |
} | |
} | |
// Fixes Bug #2551 -- select.val() broken in IE after form.reset() | |
if ( one && !values.length && options.length ) { | |
return jQuery( options[ index ] ).val(); | |
} | |
return values; | |
}, | |
set: function( elem, value ) { | |
var values = jQuery.makeArray( value ); | |
jQuery(elem).find("option").each(function() { | |
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; | |
}); | |
if ( !values.length ) { | |
elem.selectedIndex = -1; | |
} | |
return values; | |
} | |
} | |
}, | |
// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 | |
attrFn: {}, | |
attr: function( elem, name, value, pass ) { | |
var ret, hooks, notxml, | |
nType = elem.nodeType; | |
// don't get/set attributes on text, comment and attribute nodes | |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
return; | |
} | |
if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) { | |
return jQuery( elem )[ name ]( value ); | |
} | |
// Fallback to prop when attributes are not supported | |
if ( typeof elem.getAttribute === "undefined" ) { | |
return jQuery.prop( elem, name, value ); | |
} | |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
// All attributes are lowercase | |
// Grab necessary hook if one is defined | |
if ( notxml ) { | |
name = name.toLowerCase(); | |
hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); | |
} | |
if ( value !== undefined ) { | |
if ( value === null ) { | |
jQuery.removeAttr( elem, name ); | |
return; | |
} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { | |
return ret; | |
} else { | |
elem.setAttribute( name, value + "" ); | |
return value; | |
} | |
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { | |
return ret; | |
} else { | |
ret = elem.getAttribute( name ); | |
// Non-existent attributes return null, we normalize to undefined | |
return ret === null ? | |
undefined : | |
ret; | |
} | |
}, | |
removeAttr: function( elem, value ) { | |
var propName, attrNames, name, isBool, | |
i = 0; | |
if ( value && elem.nodeType === 1 ) { | |
attrNames = value.split( core_rspace ); | |
for ( ; i < attrNames.length; i++ ) { | |
name = attrNames[ i ]; | |
if ( name ) { | |
propName = jQuery.propFix[ name ] || name; | |
isBool = rboolean.test( name ); | |
// See #9699 for explanation of this approach (setting first, then removal) | |
// Do not do this for boolean attributes (see #10870) | |
if ( !isBool ) { | |
jQuery.attr( elem, name, "" ); | |
} | |
elem.removeAttribute( getSetAttribute ? name : propName ); | |
// Set corresponding property to false for boolean attributes | |
if ( isBool && propName in elem ) { | |
elem[ propName ] = false; | |
} | |
} | |
} | |
} | |
}, | |
attrHooks: { | |
type: { | |
set: function( elem, value ) { | |
// We can't allow the type property to be changed (since it causes problems in IE) | |
if ( rtype.test( elem.nodeName ) && elem.parentNode ) { | |
jQuery.error( "type property can't be changed" ); | |
} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { | |
// Setting the type on a radio button after the value resets the value in IE6-9 | |
// Reset value to it's default in case type is set after value | |
// This is for element creation | |
var val = elem.value; | |
elem.setAttribute( "type", value ); | |
if ( val ) { | |
elem.value = val; | |
} | |
return value; | |
} | |
} | |
}, | |
// Use the value property for back compat | |
// Use the nodeHook for button elements in IE6/7 (#1954) | |
value: { | |
get: function( elem, name ) { | |
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { | |
return nodeHook.get( elem, name ); | |
} | |
return name in elem ? | |
elem.value : | |
null; | |
}, | |
set: function( elem, value, name ) { | |
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { | |
return nodeHook.set( elem, value, name ); | |
} | |
// Does not return so that setAttribute is also used | |
elem.value = value; | |
} | |
} | |
}, | |
propFix: { | |
tabindex: "tabIndex", | |
readonly: "readOnly", | |
"for": "htmlFor", | |
"class": "className", | |
maxlength: "maxLength", | |
cellspacing: "cellSpacing", | |
cellpadding: "cellPadding", | |
rowspan: "rowSpan", | |
colspan: "colSpan", | |
usemap: "useMap", | |
frameborder: "frameBorder", | |
contenteditable: "contentEditable" | |
}, | |
prop: function( elem, name, value ) { | |
var ret, hooks, notxml, | |
nType = elem.nodeType; | |
// don't get/set properties on text, comment and attribute nodes | |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
return; | |
} | |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | |
if ( notxml ) { | |
// Fix name and attach hooks | |
name = jQuery.propFix[ name ] || name; | |
hooks = jQuery.propHooks[ name ]; | |
} | |
if ( value !== undefined ) { | |
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { | |
return ret; | |
} else { | |
return ( elem[ name ] = value ); | |
} | |
} else { | |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { | |
return ret; | |
} else { | |
return elem[ name ]; | |
} | |
} | |
}, | |
propHooks: { | |
tabIndex: { | |
get: function( elem ) { | |
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set | |
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ | |
var attributeNode = elem.getAttributeNode("tabindex"); | |
return attributeNode && attributeNode.specified ? | |
parseInt( attributeNode.value, 10 ) : | |
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? | |
0 : | |
undefined; | |
} | |
} | |
} | |
}); | |
// Hook for boolean attributes | |
boolHook = { | |
get: function( elem, name ) { | |
// Align boolean attributes with corresponding properties | |
// Fall back to attribute presence where some booleans are not supported | |
var attrNode, | |
property = jQuery.prop( elem, name ); | |
return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? | |
name.toLowerCase() : | |
undefined; | |
}, | |
set: function( elem, value, name ) { | |
var propName; | |
if ( value === false ) { | |
// Remove boolean attributes when set to false | |
jQuery.removeAttr( elem, name ); | |
} else { | |
// value is true since we know at this point it's type boolean and not false | |
// Set boolean attributes to the same name and set the DOM property | |
propName = jQuery.propFix[ name ] || name; | |
if ( propName in elem ) { | |
// Only set the IDL specifically if it already exists on the element | |
elem[ propName ] = true; | |
} | |
elem.setAttribute( name, name.toLowerCase() ); | |
} | |
return name; | |
} | |
}; | |
// IE6/7 do not support getting/setting some attributes with get/setAttribute | |
if ( !getSetAttribute ) { | |
fixSpecified = { | |
name: true, | |
id: true, | |
coords: true | |
}; | |
// Use this for any attribute in IE6/7 | |
// This fixes almost every IE6/7 issue | |
nodeHook = jQuery.valHooks.button = { | |
get: function( elem, name ) { | |
var ret; | |
ret = elem.getAttributeNode( name ); | |
return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ? | |
ret.value : | |
undefined; | |
}, | |
set: function( elem, value, name ) { | |
// Set the existing or create a new attribute node | |
var ret = elem.getAttributeNode( name ); | |
if ( !ret ) { | |
ret = document.createAttribute( name ); | |
elem.setAttributeNode( ret ); | |
} | |
return ( ret.value = value + "" ); | |
} | |
}; | |
// Set width and height to auto instead of 0 on empty string( Bug #8150 ) | |
// This is for removals | |
jQuery.each([ "width", "height" ], function( i, name ) { | |
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { | |
set: function( elem, value ) { | |
if ( value === "" ) { | |
elem.setAttribute( name, "auto" ); | |
return value; | |
} | |
} | |
}); | |
}); | |
// Set contenteditable to false on removals(#10429) | |
// Setting to empty string throws an error as an invalid value | |
jQuery.attrHooks.contenteditable = { | |
get: nodeHook.get, | |
set: function( elem, value, name ) { | |
if ( value === "" ) { | |
value = "false"; | |
} | |
nodeHook.set( elem, value, name ); | |
} | |
}; | |
} | |
// Some attributes require a special call on IE | |
if ( !jQuery.support.hrefNormalized ) { | |
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { | |
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { | |
get: function( elem ) { | |
var ret = elem.getAttribute( name, 2 ); | |
return ret === null ? undefined : ret; | |
} | |
}); | |
}); | |
} | |
if ( !jQuery.support.style ) { | |
jQuery.attrHooks.style = { | |
get: function( elem ) { | |
// Return undefined in the case of empty string | |
// Normalize to lowercase since IE uppercases css property names | |
return elem.style.cssText.toLowerCase() || undefined; | |
}, | |
set: function( elem, value ) { | |
return ( elem.style.cssText = value + "" ); | |
} | |
}; | |
} | |
// Safari mis-reports the default selected property of an option | |
// Accessing the parent's selectedIndex property fixes it | |
if ( !jQuery.support.optSelected ) { | |
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { | |
get: function( elem ) { | |
var parent = elem.parentNode; | |
if ( parent ) { | |
parent.selectedIndex; | |
// Make sure that it also works with optgroups, see #5701 | |
if ( parent.parentNode ) { | |
parent.parentNode.selectedIndex; | |
} | |
} | |
return null; | |
} | |
}); | |
} | |
// IE6/7 call enctype encoding | |
if ( !jQuery.support.enctype ) { | |
jQuery.propFix.enctype = "encoding"; | |
} | |
// Radios and checkboxes getter/setter | |
if ( !jQuery.support.checkOn ) { | |
jQuery.each([ "radio", "checkbox" ], function() { | |
jQuery.valHooks[ this ] = { | |
get: function( elem ) { | |
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified | |
return elem.getAttribute("value") === null ? "on" : elem.value; | |
} | |
}; | |
}); | |
} | |
jQuery.each([ "radio", "checkbox" ], function() { | |
jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { | |
set: function( elem, value ) { | |
if ( jQuery.isArray( value ) ) { | |
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); | |
} | |
} | |
}); | |
}); | |
var rformElems = /^(?:textarea|input|select)$/i, | |
rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, | |
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, | |
rkeyEvent = /^key/, | |
rmouseEvent = /^(?:mouse|contextmenu)|click/, | |
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | |
hoverHack = function( events ) { | |
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); | |
}; | |
/* | |
* Helper functions for managing events -- not part of the public interface. | |
* Props to Dean Edwards' addEvent library for many of the ideas. | |
*/ | |
jQuery.event = { | |
add: function( elem, types, handler, data, selector ) { | |
var elemData, eventHandle, events, | |
t, tns, type, namespaces, handleObj, | |
handleObjIn, handlers, special; | |
// Don't attach events to noData or text/comment nodes (allow plain objects tho) | |
if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { | |
return; | |
} | |
// Caller can pass in an object of custom data in lieu of the handler | |
if ( handler.handler ) { | |
handleObjIn = handler; | |
handler = handleObjIn.handler; | |
selector = handleObjIn.selector; | |
} | |
// Make sure that the handler has a unique ID, used to find/remove it later | |
if ( !handler.guid ) { | |
handler.guid = jQuery.guid++; | |
} | |
// Init the element's event structure and main handler, if this is the first | |
events = elemData.events; | |
if ( !events ) { | |
elemData.events = events = {}; | |
} | |
eventHandle = elemData.handle; | |
if ( !eventHandle ) { | |
elemData.handle = eventHandle = function( e ) { | |
// Discard the second event of a jQuery.event.trigger() and | |
// when an event is called after a page has unloaded | |
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? | |
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : | |
undefined; | |
}; | |
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events | |
eventHandle.elem = elem; | |
} | |
// Handle multiple events separated by a space | |
// jQuery(...).bind("mouseover mouseout", fn); | |
types = jQuery.trim( hoverHack(types) ).split( " " ); | |
for ( t = 0; t < types.length; t++ ) { | |
tns = rtypenamespace.exec( types[t] ) || []; | |
type = tns[1]; | |
namespaces = ( tns[2] || "" ).split( "." ).sort(); | |
// If event changes its type, use the special event handlers for the changed type | |
special = jQuery.event.special[ type ] || {}; | |
// If selector defined, determine special event api type, otherwise given type | |
type = ( selector ? special.delegateType : special.bindType ) || type; | |
// Update special based on newly reset type | |
special = jQuery.event.special[ type ] || {}; | |
// handleObj is passed to all event handlers | |
handleObj = jQuery.extend({ | |
type: type, | |
origType: tns[1], | |
data: data, | |
handler: handler, | |
guid: handler.guid, | |
selector: selector, | |
needsContext: selector && jQuery.expr.match.needsContext.test( selector ), | |
namespace: namespaces.join(".") | |
}, handleObjIn ); | |
// Init the event handler queue if we're the first | |
handlers = events[ type ]; | |
if ( !handlers ) { | |
handlers = events[ type ] = []; | |
handlers.delegateCount = 0; | |
// Only use addEventListener/attachEvent if the special events handler returns false | |
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { | |
// Bind the global event handler to the element | |
if ( elem.addEventListener ) { | |
elem.addEventListener( type, eventHandle, false ); | |
} else if ( elem.attachEvent ) { | |
elem.attachEvent( "on" + type, eventHandle ); | |
} | |
} | |
} | |
if ( special.add ) { | |
special.add.call( elem, handleObj ); | |
if ( !handleObj.handler.guid ) { | |
handleObj.handler.guid = handler.guid; | |
} | |
} | |
// Add to the element's handler list, delegates in front | |
if ( selector ) { | |
handlers.splice( handlers.delegateCount++, 0, handleObj ); | |
} else { | |
handlers.push( handleObj ); | |
} | |
// Keep track of which events have ever been used, for event optimization | |
jQuery.event.global[ type ] = true; | |
} | |
// Nullify elem to prevent memory leaks in IE | |
elem = null; | |
}, | |
global: {}, | |
// Detach an event or set of events from an element | |
remove: function( elem, types, handler, selector, mappedTypes ) { | |
var t, tns, type, origType, namespaces, origCount, | |
j, events, special, eventType, handleObj, | |
elemData = jQuery.hasData( elem ) && jQuery._data( elem ); | |
if ( !elemData || !(events = elemData.events) ) { | |
return; | |
} | |
// Once for each type.namespace in types; type may be omitted | |
types = jQuery.trim( hoverHack( types || "" ) ).split(" "); | |
for ( t = 0; t < types.length; t++ ) { | |
tns = rtypenamespace.exec( types[t] ) || []; | |
type = origType = tns[1]; | |
namespaces = tns[2]; | |
// Unbind all events (on this namespace, if provided) for the element | |
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; | |
eventType = events[ type ] || []; | |
origCount = eventType.length; | |
namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; | |
// Remove matching events | |
for ( j = 0; j < eventType.length; j++ ) { | |
handleObj = eventType[ j ]; | |
if ( ( mappedTypes || origType === handleObj.origType ) && | |
( !handler || handler.guid === handleObj.guid ) && | |
( !namespaces || namespaces.test( handleObj.namespace ) ) && | |
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { | |
eventType.splice( j--, 1 ); | |
if ( handleObj.selector ) { | |
eventType.delegateCount--; | |
} | |
if ( special.remove ) { | |
special.remove.call( elem, handleObj ); | |
} | |
} | |
} | |
// Remove generic event handler if we removed something and no more handlers exist | |
// (avoids potential for endless recursion during removal of special event handlers) | |
if ( eventType.length === 0 && origCount !== eventType.length ) { | |
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { | |
jQuery.removeEvent( elem, type, elemData.handle ); | |
} | |
delete events[ type ]; | |
} | |
} | |
// Remove the expando if it's no longer used | |
if ( jQuery.isEmptyObject( events ) ) { | |
delete elemData.handle; | |
// removeData also checks for emptiness and clears the expando if empty | |
// so use it instead of delete | |
jQuery.removeData( elem, "events", true ); | |
} | |
}, | |
// Events that are safe to short-circuit if no handlers are attached. | |
// Native DOM events should not be added, they may have inline handlers. | |
customEvent: { | |
"getData": true, | |
"setData": true, | |
"changeData": true | |
}, | |
trigger: function( event, data, elem, onlyHandlers ) { | |
// Don't do events on text and comment nodes | |
if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { | |
return; | |
} | |
// Event object or event type | |
var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType, | |
type = event.type || event, | |
namespaces = []; | |
// focus/blur morphs to focusin/out; ensure we're not firing them right now | |
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { | |
return; | |
} | |
if ( type.indexOf( "!" ) >= 0 ) { | |
// Exclusive events trigger only for the exact event (no namespaces) | |
type = type.slice(0, -1); | |
exclusive = true; | |
} | |
if ( type.indexOf( "." ) >= 0 ) { | |
// Namespaced trigger; create a regexp to match event type in handle() | |
namespaces = type.split("."); | |
type = namespaces.shift(); | |
namespaces.sort(); | |
} | |
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { | |
// No jQuery handlers for this event type, and it can't have inline handlers | |
return; | |
} | |
// Caller can pass in an Event, Object, or just an event type string | |
event = typeof event === "object" ? | |
// jQuery.Event object | |
event[ jQuery.expando ] ? event : | |
// Object literal | |
new jQuery.Event( type, event ) : | |
// Just the event type (string) | |
new jQuery.Event( type ); | |
event.type = type; | |
event.isTrigger = true; | |
event.exclusive = exclusive; | |
event.namespace = namespaces.join( "." ); | |
event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; | |
ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; | |
// Handle a global trigger | |
if ( !elem ) { | |
// TODO: Stop taunting the data cache; remove global events and always attach to document | |
cache = jQuery.cache; | |
for ( i in cache ) { | |
if ( cache[ i ].events && cache[ i ].events[ type ] ) { | |
jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); | |
} | |
} | |
return; | |
} | |
// Clean up the event in case it is being reused | |
event.result = undefined; | |
if ( !event.target ) { | |
event.target = elem; | |
} | |
// Clone any incoming data and prepend the event, creating the handler arg list | |
data = data != null ? jQuery.makeArray( data ) : []; | |
data.unshift( event ); | |
// Allow special events to draw outside the lines | |
special = jQuery.event.special[ type ] || {}; | |
if ( special.trigger && special.trigger.apply( elem, data ) === false ) { | |
return; | |
} | |
// Determine event propagation path in advance, per W3C events spec (#9951) | |
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724) | |
eventPath = [[ elem, special.bindType || type ]]; | |
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { | |
bubbleType = special.delegateType || type; | |
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; | |
for ( old = elem; cur; cur = cur.parentNode ) { | |
eventPath.push([ cur, bubbleType ]); | |
old = cur; | |
} | |
// Only add window if we got to document (e.g., not plain obj or detached DOM) | |
if ( old === (elem.ownerDocument || document) ) { | |
eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); | |
} | |
} | |
// Fire handlers on the event path | |
for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { | |
cur = eventPath[i][0]; | |
event.type = eventPath[i][1]; | |
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); | |
if ( handle ) { | |
handle.apply( cur, data ); | |
} | |
// Note that this is a bare JS function and not a jQuery handler | |
handle = ontype && cur[ ontype ]; | |
if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { | |
event.preventDefault(); | |
} | |
} | |
event.type = type; | |
// If nobody prevented the default action, do it now | |
if ( !onlyHandlers && !event.isDefaultPrevented() ) { | |
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && | |
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { | |
// Call a native DOM method on the target with the same name name as the event. | |
// Can't use an .isFunction() check here because IE6/7 fails that test. | |
// Don't do default actions on window, that's where global variables be (#6170) | |
// IE<9 dies on focus/blur to hidden element (#1486) | |
if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { | |
// Don't re-trigger an onFOO event when we call its FOO() method | |
old = elem[ ontype ]; | |
if ( old ) { | |
elem[ ontype ] = null; | |
} | |
// Prevent re-triggering of the same event, since we already bubbled it above | |
jQuery.event.triggered = type; | |
elem[ type ](); | |
jQuery.event.triggered = undefined; | |
if ( old ) { | |
elem[ ontype ] = old; | |
} | |
} | |
} | |
} | |
return event.result; | |
}, | |
dispatch: function( event ) { | |
// Make a writable jQuery.Event from the native event object | |
event = jQuery.event.fix( event || window.event ); | |
var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related, | |
handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), | |
delegateCount = handlers.delegateCount, | |
args = core_slice.call( arguments ), | |
run_all = !event.exclusive && !event.namespace, | |
special = jQuery.event.special[ event.type ] || {}, | |
handlerQueue = []; | |
// Use the fix-ed jQuery.Event rather than the (read-only) native event | |
args[0] = event; | |
event.delegateTarget = this; | |
// Call the preDispatch hook for the mapped type, and let it bail if desired | |
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { | |
return; | |
} | |
// Determine handlers that should run if there are delegated events | |
// Avoid non-left-click bubbling in Firefox (#3861) | |
if ( delegateCount && !(event.button && event.type === "click") ) { | |
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { | |
// Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764) | |
if ( cur.disabled !== true || event.type !== "click" ) { | |
selMatch = {}; | |
matches = []; | |
for ( i = 0; i < delegateCount; i++ ) { | |
handleObj = handlers[ i ]; | |
sel = handleObj.selector; | |
if ( selMatch[ sel ] === undefined ) { | |
selMatch[ sel ] = handleObj.needsContext ? | |
jQuery( sel, this ).index( cur ) >= 0 : | |
jQuery.find( sel, this, null, [ cur ] ).length; | |
} | |
if ( selMatch[ sel ] ) { | |
matches.push( handleObj ); | |
} | |
} | |
if ( matches.length ) { | |
handlerQueue.push({ elem: cur, matches: matches }); | |
} | |
} | |
} | |
} | |
// Add the remaining (directly-bound) handlers | |
if ( handlers.length > delegateCount ) { | |
handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); | |
} | |
// Run delegates first; they may want to stop propagation beneath us | |
for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { | |
matched = handlerQueue[ i ]; | |
event.currentTarget = matched.elem; | |
for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { | |
handleObj = matched.matches[ j ]; | |
// Triggered event must either 1) be non-exclusive and have no namespace, or | |
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). | |
if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { | |
event.data = handleObj.data; | |
event.handleObj = handleObj; | |
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) | |
.apply( matched.elem, args ); | |
if ( ret !== undefined ) { | |
event.result = ret; | |
if ( ret === false ) { | |
event.preventDefault(); | |
event.stopPropagation(); | |
} | |
} | |
} | |
} | |
} | |
// Call the postDispatch hook for the mapped type | |
if ( special.postDispatch ) { | |
special.postDispatch.call( this, event ); | |
} | |
return event.result; | |
}, | |
// Includes some event props shared by KeyEvent and MouseEvent | |
// *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** | |
props: "attrChange attrName relatedNode srcElement 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 ) { | |
// Add which for key events | |
if ( event.which == null ) { | |
event.which = original.charCode != null ? original.charCode : original.keyCode; | |
} | |
return event; | |
} | |
}, | |
mouseHooks: { | |
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), | |
filter: function( event, original ) { | |
var eventDoc, doc, body, | |
button = original.button, | |
fromElement = original.fromElement; | |
// Calculate pageX/Y if missing and clientX/Y available | |
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 ); | |
} | |
// Add relatedTarget, if necessary | |
if ( !event.relatedTarget && fromElement ) { | |
event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; | |
} | |
// Add which for click: 1 === left; 2 === middle; 3 === right | |
// Note: button is not normalized, so don't use it | |
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; | |
} | |
// Create a writable copy of the event object and normalize some properties | |
var i, prop, | |
originalEvent = event, | |
fixHook = jQuery.event.fixHooks[ event.type ] || {}, | |
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; | |
event = jQuery.Event( originalEvent ); | |
for ( i = copy.length; i; ) { | |
prop = copy[ --i ]; | |
event[ prop ] = originalEvent[ prop ]; | |
} | |
// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) | |
if ( !event.target ) { | |
event.target = originalEvent.srcElement || document; | |
} | |
// Target should not be a text node (#504, Safari) | |
if ( event.target.nodeType === 3 ) { | |
event.target = event.target.parentNode; | |
} | |
// For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8) | |
event.metaKey = !!event.metaKey; | |
return fixHook.filter? fixHook.filter( event, originalEvent ) : event; | |
}, | |
special: { | |
load: { | |
// Prevent triggered image.load events from bubbling to window.load | |
noBubble: true | |
}, | |
focus: { | |
delegateType: "focusin" | |
}, | |
blur: { | |
delegateType: "focusout" | |
}, | |
beforeunload: { | |
setup: function( data, namespaces, eventHandle ) { | |
// We only want to do this special case on windows | |
if ( jQuery.isWindow( this ) ) { | |
this.onbeforeunload = eventHandle; | |
} | |
}, | |
teardown: function( namespaces, eventHandle ) { | |
if ( this.onbeforeunload === eventHandle ) { | |
this.onbeforeunload = null; | |
} | |
} | |
} | |
}, | |
simulate: function( type, elem, event, bubble ) { | |
// Piggyback on a donor event to simulate a different one. | |
// Fake originalEvent to avoid donor's stopPropagation, but if the | |
// simulated event prevents default then we do the same on the donor. | |
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(); | |
} | |
} | |
}; | |
// Some plugins are using, but it's undocumented/deprecated and will be removed. | |
// The 1.7 special event interface should provide all the hooks needed now. | |
jQuery.event.handle = jQuery.event.dispatch; | |
jQuery.removeEvent = document.removeEventListener ? | |
function( elem, type, handle ) { | |
if ( elem.removeEventListener ) { | |
elem.removeEventListener( type, handle, false ); | |
} | |
} : | |
function( elem, type, handle ) { | |
var name = "on" + type; | |
if ( elem.detachEvent ) { | |
// #8545, #7054, preventing memory leaks for custom events in IE6-8 – | |
// detachEvent needed property on element, by name of that event, to properly expose it to GC | |
if ( typeof elem[ name ] === "undefined" ) { | |
elem[ name ] = null; | |
} | |
elem.detachEvent( name, handle ); | |
} | |
}; | |
jQuery.Event = function( src, props ) { | |
// Allow instantiation without the 'new' keyword | |
if ( !(this instanceof jQuery.Event) ) { | |
return new jQuery.Event( src, props ); | |
} | |
// Event object | |
if ( src && src.type ) { | |
this.originalEvent = src; | |
this.type = src.type; | |
// Events bubbling up the document may have been marked as prevented | |
// by a handler lower down the tree; reflect the correct value. | |
this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || | |
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; | |
// Event type | |
} else { | |
this.type = src; | |
} | |
// Put explicitly provided properties onto the event object | |
if ( props ) { | |
jQuery.extend( this, props ); | |
} | |
// Create a timestamp if incoming event doesn't have one | |
this.timeStamp = src && src.timeStamp || jQuery.now(); | |
// Mark it as fixed | |
this[ jQuery.expando ] = true; | |
}; | |
function returnFalse() { | |
return false; | |
} | |
function returnTrue() { | |
return true; | |
} | |
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding | |
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html | |
jQuery.Event.prototype = { | |
preventDefault: function() { | |
this.isDefaultPrevented = returnTrue; | |
var e = this.originalEvent; | |
if ( !e ) { | |
return; | |
} | |
// if preventDefault exists run it on the original event | |
if ( e.preventDefault ) { | |
e.preventDefault(); | |
// otherwise set the returnValue property of the original event to false (IE) | |
} else { | |
e.returnValue = false; | |
} | |
}, | |
stopPropagation: function() { | |
this.isPropagationStopped = returnTrue; | |
var e = this.originalEvent; | |
if ( !e ) { | |
return; | |
} | |
// if stopPropagation exists run it on the original event | |
if ( e.stopPropagation ) { | |
e.stopPropagation(); | |
} | |
// otherwise set the cancelBubble property of the original event to true (IE) | |
e.cancelBubble = true; | |
}, | |
stopImmediatePropagation: function() { | |
this.isImmediatePropagationStopped = returnTrue; | |
this.stopPropagation(); | |
}, | |
isDefaultPrevented: returnFalse, | |
isPropagationStopped: returnFalse, | |
isImmediatePropagationStopped: returnFalse | |
}; | |
// Create mouseenter/leave events using mouseover/out and event-time checks | |
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, | |
selector = handleObj.selector; | |
// For mousenter/leave call the handler if related is outside the target. | |
// NB: No relatedTarget if the mouse left/entered the browser window | |
if ( !related || (related !== target && !jQuery.contains( target, related )) ) { | |
event.type = handleObj.origType; | |
ret = handleObj.handler.apply( this, arguments ); | |
event.type = fix; | |
} | |
return ret; | |
} | |
}; | |
}); | |
// IE submit delegation | |
if ( !jQuery.support.submitBubbles ) { | |
jQuery.event.special.submit = { | |
setup: function() { | |
// Only need this for delegated form submit events | |
if ( jQuery.nodeName( this, "form" ) ) { | |
return false; | |
} | |
// Lazy-add a submit handler when a descendant form may potentially be submitted | |
jQuery.event.add( this, "click._submit keypress._submit", function( e ) { | |
// Node name check avoids a VML-related crash in IE (#9807) | |
var elem = e.target, | |
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; | |
if ( form && !jQuery._data( form, "_submit_attached" ) ) { | |
jQuery.event.add( form, "submit._submit", function( event ) { | |
event._submit_bubble = true; | |
}); | |
jQuery._data( form, "_submit_attached", true ); | |
} | |
}); | |
// return undefined since we don't need an event listener | |
}, | |
postDispatch: function( event ) { | |
// If form was submitted by the user, bubble the event up the tree | |
if ( event._submit_bubble ) { | |
delete event._submit_bubble; | |
if ( this.parentNode && !event.isTrigger ) { | |
jQuery.event.simulate( "submit", this.parentNode, event, true ); | |
} | |
} | |
}, | |
teardown: function() { | |
// Only need this for delegated form submit events | |
if ( jQuery.nodeName( this, "form" ) ) { | |
return false; | |
} | |
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above | |
jQuery.event.remove( this, "._submit" ); | |
} | |
}; | |
} | |
// IE change delegation and checkbox/radio fix | |
if ( !jQuery.support.changeBubbles ) { | |
jQuery.event.special.change = { | |
setup: function() { | |
if ( rformElems.test( this.nodeName ) ) { | |
// IE doesn't fire change on a check/radio until blur; trigger it on click | |
// after a propertychange. Eat the blur-change in special.change.handle. | |
// This still fires onchange a second time for check/radio after blur. | |
if ( this.type === "checkbox" || this.type === "radio" ) { | |
jQuery.event.add( this, "propertychange._change", function( event ) { | |
if ( event.originalEvent.propertyName === "checked" ) { | |
this._just_changed = true; | |
} | |
}); | |
jQuery.event.add( this, "click._change", function( event ) { | |
if ( this._just_changed && !event.isTrigger ) { | |
this._just_changed = false; | |
} | |
// Allow triggered, simulated change events (#11500) | |
jQuery.event.simulate( "change", this, event, true ); | |
}); | |
} | |
return false; | |
} | |
// Delegated event; lazy-add a change handler on descendant inputs | |
jQuery.event.add( this, "beforeactivate._change", function( e ) { | |
var elem = e.target; | |
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) { | |
jQuery.event.add( elem, "change._change", function( event ) { | |
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { | |
jQuery.event.simulate( "change", this.parentNode, event, true ); | |
} | |
}); | |
jQuery._data( elem, "_change_attached", true ); | |
} | |
}); | |
}, | |
handle: function( event ) { | |
var elem = event.target; | |
// Swallow native change events from checkbox/radio, we already triggered them above | |
if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { | |
return event.handleObj.handler.apply( this, arguments ); | |
} | |
}, | |
teardown: function() { | |
jQuery.event.remove( this, "._change" ); | |
return !rformElems.test( this.nodeName ); | |
} | |
}; | |
} | |
// Create "bubbling" focus and blur events | |
if ( !jQuery.support.focusinBubbles ) { | |
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { | |
// Attach a single capturing handler while someone wants focusin/focusout | |
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, /*INTERNAL*/ one ) { | |
var origFn, type; | |
// Types can be a map of types/handlers | |
if ( typeof types === "object" ) { | |
// ( types-Object, selector, data ) | |
if ( typeof selector !== "string" ) { // && selector != null | |
// ( types-Object, data ) | |
data = data || selector; | |
selector = undefined; | |
} | |
for ( type in types ) { | |
this.on( type, selector, data, types[ type ], one ); | |
} | |
return this; | |
} | |
if ( data == null && fn == null ) { | |
// ( types, fn ) | |
fn = selector; | |
data = selector = undefined; | |
} else if ( fn == null ) { | |
if ( typeof selector === "string" ) { | |
// ( types, selector, fn ) | |
fn = data; | |
data = undefined; | |
} else { | |
// ( types, data, fn ) | |
fn = data; | |
data = selector; | |
selector = undefined; | |
} | |
} | |
if ( fn === false ) { | |
fn = returnFalse; | |
} else if ( !fn ) { | |
return this; | |
} | |
if ( one === 1 ) { | |
origFn = fn; | |
fn = function( event ) { | |
// Can use an empty set, since event contains the info | |
jQuery().off( event ); | |
return origFn.apply( this, arguments ); | |
}; | |
// Use same guid so caller can remove using origFn | |
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 ) { | |
// ( event ) dispatched jQuery.Event | |
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" ) { | |
// ( types-object [, selector] ) | |
for ( type in types ) { | |
this.off( type, selector, types[ type ] ); | |
} | |
return this; | |
} | |
if ( selector === false || typeof selector === "function" ) { | |
// ( types [, fn] ) | |
fn = selector; | |
selector = undefined; | |
} | |
if ( fn === false ) { | |
fn = returnFalse; | |
} | |
return this.each(function() { | |
jQuery.event.remove( this, types, fn, selector ); | |
}); | |
}, | |
bind: function( types, data, fn ) { | |
return this.on( types, null, data, fn ); | |
}, | |
unbind: function( types, fn ) { | |
return this.off( types, null, fn ); | |
}, | |
live: function( types, data, fn ) { | |
jQuery( this.context ).on( types, this.selector, data, fn ); | |
return this; | |
}, | |
die: function( types, fn ) { | |
jQuery( this.context ).off( types, this.selector || "**", fn ); | |
return this; | |
}, | |
delegate: function( selector, types, data, fn ) { | |
return this.on( types, selector, data, fn ); | |
}, | |
undelegate: function( selector, types, fn ) { | |
// ( namespace ) or ( selector, types [, fn] ) | |
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); | |
}, | |
trigger: function( type, data ) { | |
return this.each(function() { | |
jQuery.event.trigger( type, data, this ); | |
}); | |
}, | |
triggerHandler: function( type, data ) { | |
if ( this[0] ) { | |
return jQuery.event.trigger( type, data, this[0], true ); | |
} | |
}, | |
toggle: function( fn ) { | |
// Save reference to arguments for access in closure | |
var args = arguments, | |
guid = fn.guid || jQuery.guid++, | |
i = 0, | |
toggler = function( event ) { | |
// Figure out which function to execute | |
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; | |
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); | |
// Make sure that clicks stop | |
event.preventDefault(); | |
// and execute the function | |
return args[ lastToggle ].apply( this, arguments ) || false; | |
}; | |
// link all the functions, so any of them can unbind this click handler | |
toggler.guid = guid; | |
while ( i < args.length ) { | |
args[ i++ ].guid = guid; | |
} | |
return this.click( toggler ); | |
}, | |
hover: function( fnOver, fnOut ) { | |
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); | |
} | |
}); | |
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 ) { | |
// Handle event binding | |
jQuery.fn[ name ] = function( data, fn ) { | |
if ( fn == null ) { | |
fn = data; | |
data = null; | |
} | |
return arguments.length > 0 ? | |
this.on( name, null, data, fn ) : | |
this.trigger( name ); | |
}; | |
if ( rkeyEvent.test( name ) ) { | |
jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; | |
} | |
if ( rmouseEvent.test( name ) ) { | |
jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; | |
} | |
}); | |
/*! | |
* Sizzle CSS Selector Engine | |
* Copyright 2012 jQuery Foundation and other contributors | |
* Released under the MIT license | |
* http://sizzlejs.com/ | |
*/ | |
(function( window, undefined ) { | |
var cachedruns, | |
assertGetIdNotName, | |
Expr, | |
getText, | |
isXML, | |
contains, | |
compile, | |
sortOrder, | |
hasDuplicate, | |
outermostContext, | |
baseHasDuplicate = true, | |
strundefined = "undefined", | |
expando = ( "sizcache" + Math.random() ).replace( ".", "" ), | |
Token = String, | |
document = window.document, | |
docElem = document.documentElement, | |
dirruns = 0, | |
done = 0, | |
pop = [].pop, | |
push = [].push, | |
slice = [].slice, | |
// Use a stripped-down indexOf if a native one is unavailable | |
indexOf = [].indexOf || function( elem ) { | |
var i = 0, | |
len = this.length; | |
for ( ; i < len; i++ ) { | |
if ( this[i] === elem ) { | |
return i; | |
} | |
} | |
return -1; | |
}, | |
// Augment a function for special use by Sizzle | |
markFunction = function( fn, value ) { | |
fn[ expando ] = value == null || value; | |
return fn; | |
}, | |
createCache = function() { | |
var cache = {}, | |
keys = []; | |
return markFunction(function( key, value ) { | |
// Only keep the most recent entries | |
if ( keys.push( key ) > Expr.cacheLength ) { | |
delete cache[ keys.shift() ]; | |
} | |
return (cache[ key ] = value); | |
}, cache ); | |
}, | |
classCache = createCache(), | |
tokenCache = createCache(), | |
compilerCache = createCache(), | |
// Regex | |
// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace | |
whitespace = "[\\x20\\t\\r\\n\\f]", | |
// http://www.w3.org/TR/css3-syntax/#characters | |
characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+", | |
// Loosely modeled on CSS identifier characters | |
// An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors) | |
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier | |
identifier = characterEncoding.replace( "w", "w#" ), | |
// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors | |
operators = "([*^$|!~]?=)", | |
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + | |
"*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", | |
// Prefer arguments not in parens/brackets, | |
// then attribute selectors and non-pseudos (denoted by :), | |
// then anything else | |
// These preferences are here to reduce the number of selectors | |
// needing tokenize in the PSEUDO preFilter | |
pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)", | |
// For matchExpr.POS and matchExpr.needsContext | |
pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + | |
"*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", | |
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter | |
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), | |
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), | |
rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), | |
rpseudo = new RegExp( pseudos ), | |
// Easily-parseable/retrievable ID or TAG or CLASS selectors | |
rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, | |
rnot = /^:not/, | |
rsibling = /[\x20\t\r\n\f]*[+~]/, | |
rendsWithNot = /:not\($/, | |
rheader = /h\d/i, | |
rinputs = /input|select|textarea|button/i, | |
rbackslash = /\\(?!\\)/g, | |
matchExpr = { | |
"ID": new RegExp( "^#(" + characterEncoding + ")" ), | |
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), | |
"NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), | |
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), | |
"ATTR": new RegExp( "^" + attributes ), | |
"PSEUDO": new RegExp( "^" + pseudos ), | |
"POS": new RegExp( pos, "i" ), | |
"CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace + | |
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + | |
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ), | |
// For use in libraries implementing .is() | |
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" ) | |
}, | |
// Support | |
// Used for testing something on an element | |
assert = function( fn ) { | |
var div = document.createElement("div"); | |
try { | |
return fn( div ); | |
} catch (e) { | |
return false; | |
} finally { | |
// release memory in IE | |
div = null; | |
} | |
}, | |
// Check if getElementsByTagName("*") returns only elements | |
assertTagNameNoComments = assert(function( div ) { | |
div.appendChild( document.createComment("") ); | |
return !div.getElementsByTagName("*").length; | |
}), | |
// Check if getAttribute returns normalized href attributes | |
assertHrefNotNormalized = assert(function( div ) { | |
div.innerHTML = "<a href='#'></a>"; | |
return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && | |
div.firstChild.getAttribute("href") === "#"; | |
}), | |
// Check if attributes should be retrieved by attribute nodes | |
assertAttributes = assert(function( div ) { | |
div.innerHTML = "<select></select>"; | |
var type = typeof div.lastChild.getAttribute("multiple"); | |
// IE8 returns a string for some attributes even when not present | |
return type !== "boolean" && type !== "string"; | |
}), | |
// Check if getElementsByClassName can be trusted | |
assertUsableClassName = assert(function( div ) { | |
// Opera can't find a second classname (in 9.6) | |
div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>"; | |
if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { | |
return false; | |
} | |
// Safari 3.2 caches class attributes and doesn't catch changes | |
div.lastChild.className = "e"; | |
return div.getElementsByClassName("e").length === 2; | |
}), | |
// Check if getElementById returns elements by name | |
// Check if getElementsByName privileges form controls or returns elements by ID | |
assertUsableName = assert(function( div ) { | |
// Inject content | |
div.id = expando + 0; | |
div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>"; | |
docElem.insertBefore( div, docElem.firstChild ); | |
// Test | |
var pass = document.getElementsByName && | |
// buggy browsers will return fewer than the correct 2 | |
document.getElementsByName( expando ).length === 2 + | |
// buggy browsers will return more than the correct 0 | |
document.getElementsByName( expando + 0 ).length; | |
assertGetIdNotName = !document.getElementById( expando ); | |
// Cleanup | |
docElem.removeChild( div ); | |
return pass; | |
}); | |
// If slice is not available, provide a backup | |
try { | |
slice.call( docElem.childNodes, 0 )[0].nodeType; | |
} catch ( e ) { | |
slice = function( i ) { | |
var elem, | |
results = []; | |
for ( ; (elem = this[i]); i++ ) { | |
results.push( elem ); | |
} | |
return results; | |
}; | |
} | |
function Sizzle( selector, context, results, seed ) { | |
results = results || []; | |
context = context || document; | |
var match, elem, xml, m, | |
nodeType = context.nodeType; | |
if ( !selector || typeof selector !== "string" ) { | |
return results; | |
} | |
if ( nodeType !== 1 && nodeType !== 9 ) { | |
return []; | |
} | |
xml = isXML( context ); | |
if ( !xml && !seed ) { | |
if ( (match = rquickExpr.exec( selector )) ) { | |
// Speed-up: Sizzle("#ID") | |
if ( (m = match[1]) ) { | |
if ( nodeType === 9 ) { | |
elem = context.getElementById( m ); | |
// Check parentNode to catch when Blackberry 4.6 returns | |
// nodes that are no longer in the document #6963 | |
if ( elem && elem.parentNode ) { | |
// Handle the case where IE, Opera, and Webkit return items | |
// by name instead of ID | |
if ( elem.id === m ) { | |
results.push( elem ); | |
return results; | |
} | |
} else { | |
return results; | |
} | |
} else { | |
// Context is not a document | |
if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && | |
contains( context, elem ) && elem.id === m ) { | |
results.push( elem ); | |
return results; | |
} | |
} | |
// Speed-up: Sizzle("TAG") | |
} else if ( match[2] ) { | |
push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); | |
return results; | |
// Speed-up: Sizzle(".CLASS") | |
} else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) { | |
push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); | |
return results; | |
} | |
} | |
} | |
// All others | |
return select( selector.replace( rtrim, "$1" ), context, results, seed, xml ); | |
} | |
Sizzle.matches = function( expr, elements ) { | |
return Sizzle( expr, null, null, elements ); | |
}; | |
Sizzle.matchesSelector = function( elem, expr ) { | |
return Sizzle( expr, null, null, [ elem ] ).length > 0; | |
}; | |
// Returns a function to use in pseudos for input types | |
function createInputPseudo( type ) { | |
return function( elem ) { | |
var name = elem.nodeName.toLowerCase(); | |
return name === "input" && elem.type === type; | |
}; | |
} | |
// Returns a function to use in pseudos for buttons | |
function createButtonPseudo( type ) { | |
return function( elem ) { | |
var name = elem.nodeName.toLowerCase(); | |
return (name === "input" || name === "button") && elem.type === type; | |
}; | |
} | |
// Returns a function to use in pseudos for positionals | |
function createPositionalPseudo( fn ) { | |
return markFunction(function( argument ) { | |
argument = +argument; | |
return markFunction(function( seed, matches ) { | |
var j, | |
matchIndexes = fn( [], seed.length, argument ), | |
i = matchIndexes.length; | |
// Match elements found at the specified indexes | |
while ( i-- ) { | |
if ( seed[ (j = matchIndexes[i]) ] ) { | |
seed[j] = !(matches[j] = seed[j]); | |
} | |
} | |
}); | |
}); | |
} | |
/** | |
* Utility function for retrieving the text value of an array of DOM nodes | |
* @param {Array|Element} elem | |
*/ | |
getText = Sizzle.getText = function( elem ) { | |
var node, | |
ret = "", | |
i = 0, | |
nodeType = elem.nodeType; | |
if ( nodeType ) { | |
if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { | |
// Use textContent for elements | |
// innerText usage removed for consistency of new lines (see #11153) | |
if ( typeof elem.textContent === "string" ) { | |
return elem.textContent; | |
} else { | |
// Traverse its children | |
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { | |
ret += getText( elem ); | |
} | |
} | |
} else if ( nodeType === 3 || nodeType === 4 ) { | |
return elem.nodeValue; | |
} | |
// Do not include comment or processing instruction nodes | |
} else { | |
// If no nodeType, this is expected to be an array | |
for ( ; (node = elem[i]); i++ ) { | |
// Do not traverse comment nodes | |
ret += getText( node ); | |
} | |
} | |
return ret; | |
}; | |
isXML = Sizzle.isXML = function( elem ) { | |
// documentElement is verified for cases where it doesn't yet exist | |
// (such as loading iframes in IE - #4833) | |
var documentElement = elem && (elem.ownerDocument || elem).documentElement; | |
return documentElement ? documentElement.nodeName !== "HTML" : false; | |
}; | |
// Element contains another | |
contains = Sizzle.contains = docElem.contains ? | |
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) ); | |
} : | |
docElem.compareDocumentPosition ? | |
function( a, b ) { | |
return b && !!( a.compareDocumentPosition( b ) & 16 ); | |
} : | |
function( a, b ) { | |
while ( (b = b.parentNode) ) { | |
if ( b === a ) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
Sizzle.attr = function( elem, name ) { | |
var val, | |
xml = isXML( elem ); | |
if ( !xml ) { | |
name = name.toLowerCase(); | |
} | |
if ( (val = Expr.attrHandle[ name ]) ) { | |
return val( elem ); | |
} | |
if ( xml || assertAttributes ) { | |
return elem.getAttribute( name ); | |
} | |
val = elem.getAttributeNode( name ); | |
return val ? | |
typeof elem[ name ] === "boolean" ? | |
elem[ name ] ? name : null : | |
val.specified ? val.value : null : | |
null; | |
}; | |
Expr = Sizzle.selectors = { | |
// Can be adjusted by the user | |
cacheLength: 50, | |
createPseudo: markFunction, | |
match: matchExpr, | |
// IE6/7 return a modified href | |
attrHandle: assertHrefNotNormalized ? | |
{} : | |
{ | |
"href": function( elem ) { | |
return elem.getAttribute( "href", 2 ); | |
}, | |
"type": function( elem ) { | |
return elem.getAttribute("type"); | |
} | |
}, | |
find: { | |
"ID": assertGetIdNotName ? | |
function( id, context, xml ) { | |
if ( typeof context.getElementById !== strundefined && !xml ) { | |
var m = context.getElementById( id ); | |
// Check parentNode to catch when Blackberry 4.6 returns | |
// nodes that are no longer in the document #6963 | |
return m && m.parentNode ? [m] : []; | |
} | |
} : | |
function( id, context, xml ) { | |
if ( typeof context.getElementById !== strundefined && !xml ) { | |
var m = context.getElementById( id ); | |
return m ? | |
m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? | |
[m] : | |
undefined : | |
[]; | |
} | |
}, | |
"TAG": assertTagNameNoComments ? | |
function( tag, context ) { | |
if ( typeof context.getElementsByTagName !== strundefined ) { | |
return context.getElementsByTagName( tag ); | |
} | |
} : | |
function( tag, context ) { | |
var results = context.getElementsByTagName( tag ); | |
// Filter out possible comments | |
if ( tag === "*" ) { | |
var elem, | |
tmp = [], | |
i = 0; | |
for ( ; (elem = results[i]); i++ ) { | |
if ( elem.nodeType === 1 ) { | |
tmp.push( elem ); | |
} | |
} | |
return tmp; | |
} | |
return results; | |
}, | |
"NAME": assertUsableName && function( tag, context ) { | |
if ( typeof context.getElementsByName !== strundefined ) { | |
return context.getElementsByName( name ); | |
} | |
}, | |
"CLASS": assertUsableClassName && function( className, context, xml ) { | |
if ( typeof context.getElementsByClassName !== strundefined && !xml ) { | |
return context.getElementsByClassName( className ); | |
} | |
} | |
}, | |
relative: { | |
">": { dir: "parentNode", first: true }, | |
" ": { dir: "parentNode" }, | |
"+": { dir: "previousSibling", first: true }, | |
"~": { dir: "previousSibling" } | |
}, | |
preFilter: { | |
"ATTR": function( match ) { | |
match[1] = match[1].replace( rbackslash, "" ); | |
// Move the given value to match[3] whether quoted or unquoted | |
match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" ); | |
if ( match[2] === "~=" ) { | |
match[3] = " " + match[3] + " "; | |
} | |
return match.slice( 0, 4 ); | |
}, | |
"CHILD": function( match ) { | |
/* matches from matchExpr["CHILD"] | |
1 type (only|nth|...) | |
2 argument (even|odd|\d*|\d*n([+-]\d+)?|...) | |
3 xn-component of xn+y argument ([+-]?\d*n|) | |
4 sign of xn-component | |
5 x of xn-component | |
6 sign of y-component | |
7 y of y-component | |
*/ | |
match[1] = match[1].toLowerCase(); | |
if ( match[1] === "nth" ) { | |
// nth-child requires argument | |
if ( !match[2] ) { | |
Sizzle.error( match[0] ); | |
} | |
// numeric x and y parameters for Expr.filter.CHILD | |
// remember that false/true cast respectively to 0/1 | |
match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) ); | |
match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" ); | |
// other types prohibit arguments | |
} else if ( match[2] ) { | |
Sizzle.error( match[0] ); | |
} | |
return match; | |
}, | |
"PSEUDO": function( match ) { | |
var unquoted, excess; | |
if ( matchExpr["CHILD"].test( match[0] ) ) { | |
return null; | |
} | |
if ( match[3] ) { | |
match[2] = match[3]; | |
} else if ( (unquoted = match[4]) ) { | |
// Only check arguments that contain a pseudo | |
if ( rpseudo.test(unquoted) && | |
// Get excess from tokenize (recursively) | |
(excess = tokenize( unquoted, true )) && | |
// advance to the next closing parenthesis | |
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { | |
// excess is a negative index | |
unquoted = unquoted.slice( 0, excess ); | |
match[0] = match[0].slice( 0, excess ); | |
} | |
match[2] = unquoted; | |
} | |
// Return only captures needed by the pseudo filter method (type and argument) | |
return match.slice( 0, 3 ); | |
} | |
}, | |
filter: { | |
"ID": assertGetIdNotName ? | |
function( id ) { | |
id = id.replace( rbackslash, "" ); | |
return function( elem ) { | |
return elem.getAttribute("id") === id; | |
}; | |
} : | |
function( id ) { | |
id = id.replace( rbackslash, "" ); | |
return function( elem ) { | |
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); | |
return node && node.value === id; | |
}; | |
}, | |
"TAG": function( nodeName ) { | |
if ( nodeName === "*" ) { | |
return function() { return true; }; | |
} | |
nodeName = nodeName.replace( rbackslash, "" ).toLowerCase(); | |
return function( elem ) { | |
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; | |
}; | |
}, | |
"CLASS": function( className ) { | |
var pattern = classCache[ expando ][ className ]; | |
if ( !pattern ) { | |
pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") ); | |
} | |
return function( elem ) { | |
return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); | |
}; | |
}, | |
"ATTR": function( name, operator, check ) { | |
return function( elem, context ) { | |
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.substr( result.length - check.length ) === check : | |
operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : | |
operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" : | |
false; | |
}; | |
}, | |
"CHILD": function( type, argument, first, last ) { | |
if ( type === "nth" ) { | |
return function( elem ) { | |
var node, diff, | |
parent = elem.parentNode; | |
if ( first === 1 && last === 0 ) { | |
return true; | |
} | |
if ( parent ) { | |
diff = 0; | |
for ( node = parent.firstChild; node; node = node.nextSibling ) { | |
if ( node.nodeType === 1 ) { | |
diff++; | |
if ( elem === node ) { | |
break; | |
} | |
} | |
} | |
} | |
// Incorporate the offset (or cast to NaN), then check against cycle size | |
diff -= last; | |
return diff === first || ( diff % first === 0 && diff / first >= 0 ); | |
}; | |
} | |
return function( elem ) { | |
var node = elem; | |
switch ( type ) { | |
case "only": | |
case "first": | |
while ( (node = node.previousSibling) ) { | |
if ( node.nodeType === 1 ) { | |
return false; | |
} | |
} | |
if ( type === "first" ) { | |
return true; | |
} | |
node = elem; | |
/* falls through */ | |
case "last": | |
while ( (node = node.nextSibling) ) { | |
if ( node.nodeType === 1 ) { | |
return false; | |
} | |
} | |
return true; | |
} | |
}; | |
}, | |
"PSEUDO": function( pseudo, argument ) { | |
// pseudo-class names are case-insensitive | |
// http://www.w3.org/TR/selectors/#pseudo-classes | |
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters | |
// Remember that setFilters inherits from pseudos | |
var args, | |
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || | |
Sizzle.error( "unsupported pseudo: " + pseudo ); | |
// The user may use createPseudo to indicate that | |
// arguments are needed to create the filter function | |
// just as Sizzle does | |
if ( fn[ expando ] ) { | |
return fn( argument ); | |
} | |
// But maintain support for old signatures | |
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 ) { | |
// Trim the selector passed to compile | |
// to avoid treating leading and trailing | |
// spaces as combinators | |
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; | |
// Match elements unmatched by `matcher` | |
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; | |
}; | |
}), | |
"enabled": function( elem ) { | |
return elem.disabled === false; | |
}, | |
"disabled": function( elem ) { | |
return elem.disabled === true; | |
}, | |
"checked": function( elem ) { | |
// In CSS3, :checked should return both checked and selected elements | |
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked | |
var nodeName = elem.nodeName.toLowerCase(); | |
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); | |
}, | |
"selected": function( elem ) { | |
// Accessing this property makes selected-by-default | |
// options in Safari work properly | |
if ( elem.parentNode ) { | |
elem.parentNode.selectedIndex; | |
} | |
return elem.selected === true; | |
}, | |
"parent": function( elem ) { | |
return !Expr.pseudos["empty"]( elem ); | |
}, | |
"empty": function( elem ) { | |
// http://www.w3.org/TR/selectors/#empty-pseudo | |
// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), | |
// not comment, processing instructions, or others | |
// Thanks to Diego Perini for the nodeName shortcut | |
// Greater than "@" means alpha characters (specifically not starting with "#" or "?") | |
var nodeType; | |
elem = elem.firstChild; | |
while ( elem ) { | |
if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) { | |
return false; | |
} | |
elem = elem.nextSibling; | |
} | |
return true; | |
}, | |
"header": function( elem ) { | |
return rheader.test( elem.nodeName ); | |
}, | |
"text": function( elem ) { | |
var type, attr; | |
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) | |
// use getAttribute instead to test this case | |
return elem.nodeName.toLowerCase() === "input" && | |
(type = elem.type) === "text" && | |
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type ); | |
}, | |
// Input types | |
"radio": createInputPseudo("radio"), | |
"checkbox": createInputPseudo("checkbox"), | |
"file": createInputPseudo("file"), | |
"password": createInputPseudo("password"), | |
"image": createInputPseudo("image"), | |
"submit": createButtonPseudo("submit"), | |
"reset": createButtonPseudo("reset"), | |
"button": function( elem ) { | |
var name = elem.nodeName.toLowerCase(); | |
return name === "input" && elem.type === "button" || name === "button"; | |
}, | |
"input": function( elem ) { | |
return rinputs.test( elem.nodeName ); | |
}, | |
"focus": function( elem ) { | |
var doc = elem.ownerDocument; | |
return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href); | |
}, | |
"active": function( elem ) { | |
return elem === elem.ownerDocument.activeElement; | |
}, | |
// Positional types | |
"first": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
return [ 0 ]; | |
}), | |
"last": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
return [ length - 1 ]; | |
}), | |
"eq": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
return [ argument < 0 ? argument + length : argument ]; | |
}), | |
"even": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
for ( var i = 0; i < length; i += 2 ) { | |
matchIndexes.push( i ); | |
} | |
return matchIndexes; | |
}), | |
"odd": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
for ( var i = 1; i < length; i += 2 ) { | |
matchIndexes.push( i ); | |
} | |
return matchIndexes; | |
}), | |
"lt": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) { | |
matchIndexes.push( i ); | |
} | |
return matchIndexes; | |
}), | |
"gt": createPositionalPseudo(function( matchIndexes, length, argument ) { | |
for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) { | |
matchIndexes.push( i ); | |
} | |
return matchIndexes; | |
}) | |
} | |
}; | |
function siblingCheck( a, b, ret ) { | |
if ( a === b ) { | |
return ret; | |
} | |
var cur = a.nextSibling; | |
while ( cur ) { | |
if ( cur === b ) { | |
return -1; | |
} | |
cur = cur.nextSibling; | |
} | |
return 1; | |
} | |
sortOrder = docElem.compareDocumentPosition ? | |
function( a, b ) { | |
if ( a === b ) { | |
hasDuplicate = true; | |
return 0; | |
} | |
return ( !a.compareDocumentPosition || !b.compareDocumentPosition ? | |
a.compareDocumentPosition : | |
a.compareDocumentPosition(b) & 4 | |
) ? -1 : 1; | |
} : | |
function( a, b ) { | |
// The nodes are identical, we can exit early | |
if ( a === b ) { | |
hasDuplicate = true; | |
return 0; | |
// Fallback to using sourceIndex (in IE) if it's available on both nodes | |
} else if ( a.sourceIndex && b.sourceIndex ) { | |
return a.sourceIndex - b.sourceIndex; | |
} | |
var al, bl, | |
ap = [], | |
bp = [], | |
aup = a.parentNode, | |
bup = b.parentNode, | |
cur = aup; | |
// If the nodes are siblings (or identical) we can do a quick check | |
if ( aup === bup ) { | |
return siblingCheck( a, b ); | |
// If no parents were found then the nodes are disconnected | |
} else if ( !aup ) { | |
return -1; | |
} else if ( !bup ) { | |
return 1; | |
} | |
// Otherwise they're somewhere else in the tree so we need | |
// to build up a full list of the parentNodes for comparison | |
while ( cur ) { | |
ap.unshift( cur ); | |
cur = cur.parentNode; | |
} | |
cur = bup; | |
while ( cur ) { | |
bp.unshift( cur ); | |
cur = cur.parentNode; | |
} | |
al = ap.length; | |
bl = bp.length; | |
// Start walking down the tree looking for a discrepancy | |
for ( var i = 0; i < al && i < bl; i++ ) { | |
if ( ap[i] !== bp[i] ) { | |
return siblingCheck( ap[i], bp[i] ); | |
} | |
} | |
// We ended someplace up the tree so do a sibling check | |
return i === al ? | |
siblingCheck( a, bp[i], -1 ) : | |
siblingCheck( ap[i], b, 1 ); | |
}; | |
// Always assume the presence of duplicates if sort doesn't | |
// pass them to our comparison function (as in Google Chrome). | |
[0, 0].sort( sortOrder ); | |
baseHasDuplicate = !hasDuplicate; | |
// Document sorting and removing duplicates | |
Sizzle.uniqueSort = function( results ) { | |
var elem, | |
i = 1; | |
hasDuplicate = baseHasDuplicate; | |
results.sort( sortOrder ); | |
if ( hasDuplicate ) { | |
for ( ; (elem = results[i]); i++ ) { | |
if ( elem === results[ i - 1 ] ) { | |
results.splice( i--, 1 ); | |
} | |
} | |
} | |
return results; | |
}; | |
Sizzle.error = function( msg ) { | |
throw new Error( "Syntax error, unrecognized expression: " + msg ); | |
}; | |
function tokenize( selector, parseOnly ) { | |
var matched, match, tokens, type, soFar, groups, preFilters, | |
cached = tokenCache[ expando ][ selector ]; | |
if ( cached ) { | |
return parseOnly ? 0 : cached.slice( 0 ); | |
} | |
soFar = selector; | |
groups = []; | |
preFilters = Expr.preFilter; | |
while ( soFar ) { | |
// Comma and first run | |
if ( !matched || (match = rcomma.exec( soFar )) ) { | |
if ( match ) { | |
soFar = soFar.slice( match[0].length ); | |
} | |
groups.push( tokens = [] ); | |
} | |
matched = false; | |
// Combinators | |
if ( (match = rcombinators.exec( soFar )) ) { | |
tokens.push( matched = new Token( match.shift() ) ); | |
soFar = soFar.slice( matched.length ); | |
// Cast descendant combinators to space | |
matched.type = match[0].replace( rtrim, " " ); | |
} | |
// Filters | |
for ( type in Expr.filter ) { | |
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || | |
// The last two arguments here are (context, xml) for backCompat | |
(match = preFilters[ type ]( match, document, true ))) ) { | |
tokens.push( matched = new Token( match.shift() ) ); | |
soFar = soFar.slice( matched.length ); | |
matched.type = type; | |
matched.matches = match; | |
} | |
} | |
if ( !matched ) { | |
break; | |
} | |
} | |
// Return the length of the invalid excess | |
// if we're just parsing | |
// Otherwise, throw an error or return tokens | |
return parseOnly ? | |
soFar.length : | |
soFar ? | |
Sizzle.error( selector ) : | |
// Cache the tokens | |
tokenCache( selector, groups ).slice( 0 ); | |
} | |
function addCombinator( matcher, combinator, base ) { | |
var dir = combinator.dir, | |
checkNonElements = base && combinator.dir === "parentNode", | |
doneName = done++; | |
return combinator.first ? | |
// Check against closest ancestor/preceding element | |
function( elem, context, xml ) { | |
while ( (elem = elem[ dir ]) ) { | |
if ( checkNonElements || elem.nodeType === 1 ) { | |
return matcher( elem, context, xml ); | |
} | |
} | |
} : | |
// Check against all ancestor/preceding elements | |
function( elem, context, xml ) { | |
// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching | |
if ( !xml ) { | |
var cache, | |
dirkey = dirruns + " " + doneName + " ", | |
cachedkey = dirkey + cachedruns; | |
while ( (elem = elem[ dir ]) ) { | |
if ( checkNonElements || elem.nodeType === 1 ) { | |
if ( (cache = elem[ expando ]) === cachedkey ) { | |
return elem.sizset; | |
} else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) { | |
if ( elem.sizset ) { | |
return elem; | |
} | |
} else { | |
elem[ expando ] = cachedkey; | |
if ( matcher( elem, context, xml ) ) { | |
elem.sizset = true; | |
return elem; | |
} | |
elem.sizset = false; | |
} | |
} | |
} | |
} else { | |
while ( (elem = elem[ dir ]) ) { | |
if ( checkNonElements || elem.nodeType === 1 ) { | |
if ( matcher( elem, context, xml ) ) { | |
return elem; | |
} | |
} | |
} | |
} | |
}; | |
} | |
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 ) { | |
// Positional selectors apply to seed elements, so it is invalid to follow them with relative ones | |
if ( seed && postFinder ) { | |
return; | |
} | |
var i, elem, postFilterIn, | |
preMap = [], | |
postMap = [], | |
preexisting = results.length, | |
// Get initial elements from seed or context | |
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ), | |
// Prefilter to get matcher input, preserving a map for seed-results synchronization | |
matcherIn = preFilter && ( seed || !selector ) ? | |
condense( elems, preMap, preFilter, context, xml ) : | |
elems, | |
matcherOut = matcher ? | |
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, | |
postFinder || ( seed ? preFilter : preexisting || postFilter ) ? | |
// ...intermediate processing is necessary | |
[] : | |
// ...otherwise use results directly | |
results : | |
matcherIn; | |
// Find primary matches | |
if ( matcher ) { | |
matcher( matcherIn, matcherOut, context, xml ); | |
} | |
// Apply postFilter | |
if ( postFilter ) { | |
postFilterIn = condense( matcherOut, postMap ); | |
postFilter( postFilterIn, [], context, xml ); | |
// Un-match failing elements by moving them back to matcherIn | |
i = postFilterIn.length; | |
while ( i-- ) { | |
if ( (elem = postFilterIn[i]) ) { | |
matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); | |
} | |
} | |
} | |
// Keep seed and results synchronized | |
if ( seed ) { | |
// Ignore postFinder because it can't coexist with seed | |
i = preFilter && matcherOut.length; | |
while ( i-- ) { | |
if ( (elem = matcherOut[i]) ) { | |
seed[ preMap[i] ] = !(results[ preMap[i] ] = 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, | |
// The foundational matcher ensures that elements are reachable from top-level context(s) | |
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 { | |
// The concatenated values are (context, xml) for backCompat | |
matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); | |
// Return special upon seeing a positional matcher | |
if ( matcher[ expando ] ) { | |
// Find the next relative operator (if any) for proper handling | |
j = ++i; | |
for ( ; j < len; j++ ) { | |
if ( Expr.relative[ tokens[j].type ] ) { | |
break; | |
} | |
} | |
return setMatcher( | |
i > 1 && elementMatcher( matchers ), | |
i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ), | |
matcher, | |
i < j && matcherFromTokens( tokens.slice( i, j ) ), | |
j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), | |
j < len && tokens.join("") | |
); | |
} | |
matchers.push( matcher ); | |
} | |
} | |
return elementMatcher( matchers ); | |
} | |
function matcherFromGroupMatchers( elementMatchers, setMatchers ) { | |
var 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, | |
// We must always have either seed elements or context | |
elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), | |
// Nested matchers should use non-integer dirruns | |
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E); | |
if ( outermost ) { | |
outermostContext = context !== document && context; | |
cachedruns = superMatcher.el; | |
} | |
// Add elements passing elementMatchers directly to results | |
for ( ; (elem = elems[i]) != null; i++ ) { | |
if ( byElement && elem ) { | |
for ( j = 0; (matcher = elementMatchers[j]); j++ ) { | |
if ( matcher( elem, context, xml ) ) { | |
results.push( elem ); | |
break; | |
} | |
} | |
if ( outermost ) { | |
dirruns = dirrunsUnique; | |
cachedruns = ++superMatcher.el; | |
} | |
} | |
// Track unmatched elements for set filters | |
if ( bySet ) { | |
// They will have gone through all possible matchers | |
if ( (elem = !matcher && elem) ) { | |
matchedCount--; | |
} | |
// Lengthen the array for every element, matched or not | |
if ( seed ) { | |
unmatched.push( elem ); | |
} | |
} | |
} | |
// Apply set filters to unmatched elements | |
matchedCount += i; | |
if ( bySet && i !== matchedCount ) { | |
for ( j = 0; (matcher = setMatchers[j]); j++ ) { | |
matcher( unmatched, setMatched, context, xml ); | |
} | |
if ( seed ) { | |
// Reintegrate element matches to eliminate the need for sorting | |
if ( matchedCount > 0 ) { | |
while ( i-- ) { | |
if ( !(unmatched[i] || setMatched[i]) ) { | |
setMatched[i] = pop.call( results ); | |
} | |
} | |
} | |
// Discard index placeholder values to get only actual matches | |
setMatched = condense( setMatched ); | |
} | |
// Add matches to results | |
push.apply( results, setMatched ); | |
// Seedless set matches succeeding multiple successful matchers stipulate sorting | |
if ( outermost && !seed && setMatched.length > 0 && | |
( matchedCount + setMatchers.length ) > 1 ) { | |
Sizzle.uniqueSort( results ); | |
} | |
} | |
// Override manipulation of globals by nested matchers | |
if ( outermost ) { | |
dirruns = dirrunsUnique; | |
outermostContext = contextBackup; | |
} | |
return unmatched; | |
}; | |
superMatcher.el = 0; | |
return bySet ? | |
markFunction( superMatcher ) : | |
superMatcher; | |
} | |
compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { | |
var i, | |
setMatchers = [], | |
elementMatchers = [], | |
cached = compilerCache[ expando ][ selector ]; | |
if ( !cached ) { | |
// Generate a function of recursive functions that can be used to check each element | |
if ( !group ) { | |
group = tokenize( selector ); | |
} | |
i = group.length; | |
while ( i-- ) { | |
cached = matcherFromTokens( group[i] ); | |
if ( cached[ expando ] ) { | |
setMatchers.push( cached ); | |
} else { | |
elementMatchers.push( cached ); | |
} | |
} | |
// Cache the compiled function | |
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); | |
} | |
return cached; | |
}; | |
function multipleContexts( selector, contexts, results, seed ) { | |
var i = 0, | |
len = contexts.length; | |
for ( ; i < len; i++ ) { | |
Sizzle( selector, contexts[i], results, seed ); | |
} | |
return results; | |
} | |
function select( selector, context, results, seed, xml ) { | |
var i, tokens, token, type, find, | |
match = tokenize( selector ), | |
j = match.length; | |
if ( !seed ) { | |
// Try to minimize operations if there is only one group | |
if ( match.length === 1 ) { | |
// Take a shortcut and set the context if the root selector is an ID | |
tokens = match[0] = match[0].slice( 0 ); | |
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && | |
context.nodeType === 9 && !xml && | |
Expr.relative[ tokens[1].type ] ) { | |
context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0]; | |
if ( !context ) { | |
return results; | |
} | |
selector = selector.slice( tokens.shift().length ); | |
} | |
// Fetch a seed set for right-to-left matching | |
for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) { | |
token = tokens[i]; | |
// Abort if we hit a combinator | |
if ( Expr.relative[ (type = token.type) ] ) { | |
break; | |
} | |
if ( (find = Expr.find[ type ]) ) { | |
// Search, expanding context for leading sibling combinators | |
if ( (seed = find( | |
token.matches[0].replace( rbackslash, "" ), | |
rsibling.test( tokens[0].type ) && context.parentNode || context, | |
xml | |
)) ) { | |
// If seed is empty or no tokens remain, we can return early | |
tokens.splice( i, 1 ); | |
selector = seed.length && tokens.join(""); | |
if ( !selector ) { | |
push.apply( results, slice.call( seed, 0 ) ); | |
return results; | |
} | |
break; | |
} | |
} | |
} | |
} | |
} | |
// Compile and execute a filtering function | |
// Provide `match` to avoid retokenization if we modified the selector above | |
compile( selector, match )( | |
seed, | |
context, | |
xml, | |
results, | |
rsibling.test( selector ) | |
); | |
return results; | |
} | |
if ( document.querySelectorAll ) { | |
(function() { | |
var disconnectedMatch, | |
oldSelect = select, | |
rescape = /'|\\/g, | |
rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, | |
// qSa(:focus) reports false when true (Chrome 21), | |
// A support test would require too much code (would include document ready) | |
rbuggyQSA = [":focus"], | |
// matchesSelector(:focus) reports false when true (Chrome 21), | |
// matchesSelector(:active) reports false when true (IE9/Opera 11.5) | |
// A support test would require too much code (would include document ready) | |
// just skip matchesSelector for :active | |
rbuggyMatches = [ ":active", ":focus" ], | |
matches = docElem.matchesSelector || | |
docElem.mozMatchesSelector || | |
docElem.webkitMatchesSelector || | |
docElem.oMatchesSelector || | |
docElem.msMatchesSelector; | |
// Build QSA regex | |
// Regex strategy adopted from Diego Perini | |
assert(function( div ) { | |
// Select is set to empty string on purpose | |
// This is to test IE's treatment of not explictly | |
// setting a boolean content attribute, | |
// since its presence should be enough | |
// http://bugs.jquery.com/ticket/12359 | |
div.innerHTML = "<select><option selected=''></option></select>"; | |
// IE8 - Some boolean attributes are not treated correctly | |
if ( !div.querySelectorAll("[selected]").length ) { | |
rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); | |
} | |
// Webkit/Opera - :checked should return selected option elements | |
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked | |
// IE8 throws error here (do not put tests after this one) | |
if ( !div.querySelectorAll(":checked").length ) { | |
rbuggyQSA.push(":checked"); | |
} | |
}); | |
assert(function( div ) { | |
// Opera 10-12/IE9 - ^= $= *= and empty values | |
// Should not select anything | |
div.innerHTML = "<p test=''></p>"; | |
if ( div.querySelectorAll("[test^='']").length ) { | |
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); | |
} | |
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) | |
// IE8 throws error here (do not put tests after this one) | |
div.innerHTML = "<input type='hidden'/>"; | |
if ( !div.querySelectorAll(":enabled").length ) { | |
rbuggyQSA.push(":enabled", ":disabled"); | |
} | |
}); | |
// rbuggyQSA always contains :focus, so no need for a length check | |
rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") ); | |
select = function( selector, context, results, seed, xml ) { | |
// Only use querySelectorAll when not filtering, | |
// when this is not xml, | |
// and when no QSA bugs apply | |
if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { | |
var groups, i, | |
old = true, | |
nid = expando, | |
newContext = context, | |
newSelector = context.nodeType === 9 && selector; | |
// qSA works strangely on Element-rooted queries | |
// We can work around this by specifying an extra ID on the root | |
// and working up from there (Thanks to Andrew Dupont for the technique) | |
// IE 8 doesn't work on object elements | |
if ( context.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 + groups[i].join(""); | |
} | |
newContext = rsibling.test( selector ) && context.parentNode || context; | |
newSelector = groups.join(","); | |
} | |
if ( newSelector ) { | |
try { | |
push.apply( results, slice.call( newContext.querySelectorAll( | |
newSelector | |
), 0 ) ); | |
return results; | |
} catch(qsaError) { | |
} finally { | |
if ( !old ) { | |
context.removeAttribute("id"); | |
} | |
} | |
} | |
} | |
return oldSelect( selector, context, results, seed, xml ); | |
}; | |
if ( matches ) { | |
assert(function( div ) { | |
// Check to see if it's possible to do matchesSelector | |
// on a disconnected node (IE 9) | |
disconnectedMatch = matches.call( div, "div" ); | |
// This should fail with an exception | |
// Gecko does not error, returns false instead | |
try { | |
matches.call( div, "[test!='']:sizzle" ); | |
rbuggyMatches.push( "!=", pseudos ); | |
} catch ( e ) {} | |
}); | |
// rbuggyMatches always contains :active and :focus, so no need for a length check | |
rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") ); | |
Sizzle.matchesSelector = function( elem, expr ) { | |
// Make sure that attribute selectors are quoted | |
expr = expr.replace( rattributeQuotes, "='$1']" ); | |
// rbuggyMatches always contains :active, so no need for an existence check | |
if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) { | |
try { | |
var ret = matches.call( elem, expr ); | |
// IE 9's matchesSelector returns false on disconnected nodes | |
if ( ret || disconnectedMatch || | |
// As well, disconnected nodes are said to be in a document | |
// fragment in IE 9 | |
elem.document && elem.document.nodeType !== 11 ) { | |
return ret; | |
} | |
} catch(e) {} | |
} | |
return Sizzle( expr, null, null, [ elem ] ).length > 0; | |
}; | |
} | |
})(); | |
} | |
// Deprecated | |
Expr.pseudos["nth"] = Expr.pseudos["eq"]; | |
// Back-compat | |
function setFilters() {} | |
Expr.filters = setFilters.prototype = Expr.pseudos; | |
Expr.setFilters = new setFilters(); | |
// Override sizzle attribute retrieval | |
Sizzle.attr = jQuery.attr; | |
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 runtil = /Until$/, | |
rparentsprev = /^(?:parents|prev(?:Until|All))/, | |
isSimple = /^.[^:#\[\.,]*$/, | |
rneedsContext = jQuery.expr.match.needsContext, | |
// methods guaranteed to produce a unique set when starting from a unique set | |
guaranteedUnique = { | |
children: true, | |
contents: true, | |
next: true, | |
prev: true | |
}; | |
jQuery.fn.extend({ | |
find: function( selector ) { | |
var i, l, length, n, r, ret, | |
self = this; | |
if ( typeof selector !== "string" ) { | |
return jQuery( selector ).filter(function() { | |
for ( i = 0, l = self.length; i < l; i++ ) { | |
if ( jQuery.contains( self[ i ], this ) ) { | |
return true; | |
} | |
} | |
}); | |
} | |
ret = this.pushStack( "", "find", selector ); | |
for ( i = 0, l = this.length; i < l; i++ ) { | |
length = ret.length; | |
jQuery.find( selector, this[i], ret ); | |
if ( i > 0 ) { | |
// Make sure that the results are unique | |
for ( n = length; n < ret.length; n++ ) { | |
for ( r = 0; r < length; r++ ) { | |
if ( ret[r] === ret[n] ) { | |
ret.splice(n--, 1); | |
break; | |
} | |
} | |
} | |
} | |
} | |
return ret; | |
}, | |
has: function( target ) { | |
var i, | |
targets = jQuery( target, this ), | |
len = targets.length; | |
return this.filter(function() { | |
for ( i = 0; i < len; i++ ) { | |
if ( jQuery.contains( this, targets[i] ) ) { | |
return true; | |
} | |
} | |
}); | |
}, | |
not: function( selector ) { | |
return this.pushStack( winnow(this, selector, false), "not", selector); | |
}, | |
filter: function( selector ) { | |
return this.pushStack( winnow(this, selector, true), "filter", selector ); | |
}, | |
is: function( selector ) { | |
return !!selector && ( | |
typeof selector === "string" ? | |
// If this is a positional/relative selector, check membership in the returned set | |
// so $("p:first").is("p:last") won't return true for a doc with two "p". | |
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, | |
ret = [], | |
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? | |
jQuery( selectors, context || this.context ) : | |
0; | |
for ( ; i < l; i++ ) { | |
cur = this[i]; | |
while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { | |
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { | |
ret.push( cur ); | |
break; | |
} | |
cur = cur.parentNode; | |
} | |
} | |
ret = ret.length > 1 ? jQuery.unique( ret ) : ret; | |
return this.pushStack( ret, "closest", selectors ); | |
}, | |
// Determine the position of an element within | |
// the matched set of elements | |
index: function( elem ) { | |
// No argument, return index in parent | |
if ( !elem ) { | |
return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; | |
} | |
// index in selector | |
if ( typeof elem === "string" ) { | |
return jQuery.inArray( this[0], jQuery( elem ) ); | |
} | |
// Locate the position of the desired element | |
return jQuery.inArray( | |
// If it receives a jQuery object, the first element is used | |
elem.jquery ? elem[0] : elem, this ); | |
}, | |
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( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? | |
all : | |
jQuery.unique( all ) ); | |
}, | |
addBack: function( selector ) { | |
return this.add( selector == null ? | |
this.prevObject : this.prevObject.filter(selector) | |
); | |
} | |
}); | |
jQuery.fn.andSelf = jQuery.fn.addBack; | |
// A painfully simple check to see if an element is disconnected | |
// from a document (should be improved, where feasible). | |
function isDisconnected( node ) { | |
return !node || !node.parentNode || node.parentNode.nodeType === 11; | |
} | |
function sibling( cur, dir ) { | |
do { | |
cur = cur[ dir ]; | |
} while ( cur && 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 ret = jQuery.map( this, fn, until ); | |
if ( !runtil.test( name ) ) { | |
selector = until; | |
} | |
if ( selector && typeof selector === "string" ) { | |
ret = jQuery.filter( selector, ret ); | |
} | |
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; | |
if ( this.length > 1 && rparentsprev.test( name ) ) { | |
ret = ret.reverse(); | |
} | |
return this.pushStack( ret, name, core_slice.call( arguments ).join(",") ); | |
}; | |
}); | |
jQuery.extend({ | |
filter: function( expr, elems, not ) { | |
if ( not ) { | |
expr = ":not(" + expr + ")"; | |
} | |
return elems.length === 1 ? | |
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : | |
jQuery.find.matches(expr, elems); | |
}, | |
dir: function( elem, dir, until ) { | |
var matched = [], | |
cur = elem[ dir ]; | |
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { | |
if ( cur.nodeType === 1 ) { | |
matched.push( cur ); | |
} | |
cur = cur[dir]; | |
} | |
return matched; | |
}, | |
sibling: function( n, elem ) { | |
var r = []; | |
for ( ; n; n = n.nextSibling ) { | |
if ( n.nodeType === 1 && n !== elem ) { | |
r.push( n ); | |
} | |
} | |
return r; | |
} | |
}); | |
// Implement the identical functionality for filter and not | |
function winnow( elements, qualifier, keep ) { | |
// Can't pass null or undefined to indexOf in Firefox 4 | |
// Set to 0 to skip string check | |
qualifier = qualifier || 0; | |
if ( jQuery.isFunction( qualifier ) ) { | |
return jQuery.grep(elements, function( elem, i ) { | |
var retVal = !!qualifier.call( elem, i, elem ); | |
return retVal === keep; | |
}); | |
} else if ( qualifier.nodeType ) { | |
return jQuery.grep(elements, function( elem, i ) { | |
return ( elem === qualifier ) === keep; | |
}); | |
} else if ( typeof qualifier === "string" ) { | |
var filtered = jQuery.grep(elements, function( elem ) { | |
return elem.nodeType === 1; | |
}); | |
if ( isSimple.test( qualifier ) ) { | |
return jQuery.filter(qualifier, filtered, !keep); | |
} else { | |
qualifier = jQuery.filter( qualifier, filtered ); | |
} | |
} | |
return jQuery.grep(elements, function( elem, i ) { | |
return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; | |
}); | |
} | |
function createSafeFragment( document ) { | |
var list = nodeNames.split( "|" ), | |
safeFrag = document.createDocumentFragment(); | |
if ( safeFrag.createElement ) { | |
while ( list.length ) { | |
safeFrag.createElement( | |
list.pop() | |
); | |
} | |
} | |
return safeFrag; | |
} | |
var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + | |
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", | |
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, | |
rleadingWhitespace = /^\s+/, | |
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, | |
rtagName = /<([\w:]+)/, | |
rtbody = /<tbody/i, | |
rhtml = /<|&#?\w+;/, | |
rnoInnerhtml = /<(?:script|style|link)/i, | |
rnocache = /<(?:script|object|embed|option|style)/i, | |
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), | |
rcheckableType = /^(?:checkbox|radio)$/, | |
// checked="checked" or checked | |
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | |
rscriptType = /\/(java|ecma)script/i, | |
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g, | |
wrapMap = { | |
option: [ 1, "<select multiple='multiple'>", "</select>" ], | |
legend: [ 1, "<fieldset>", "</fieldset>" ], | |
thead: [ 1, "<table>", "</table>" ], | |
tr: [ 2, "<table><tbody>", "</tbody></table>" ], | |
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], | |
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], | |
area: [ 1, "<map>", "</map>" ], | |
_default: [ 0, "", "" ] | |
}, | |
safeFragment = createSafeFragment( document ), | |
fragmentDiv = safeFragment.appendChild( document.createElement("div") ); | |
wrapMap.optgroup = wrapMap.option; | |
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; | |
wrapMap.th = wrapMap.td; | |
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, | |
// unless wrapped in a div with non-breaking characters in front of it. | |
if ( !jQuery.support.htmlSerialize ) { | |
wrapMap._default = [ 1, "X<div>", "</div>" ]; | |
} | |
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 ); | |
}, | |
wrapAll: function( html ) { | |
if ( jQuery.isFunction( html ) ) { | |
return this.each(function(i) { | |
jQuery(this).wrapAll( html.call(this, i) ); | |
}); | |
} | |
if ( this[0] ) { | |
// The elements to wrap the target around | |
var 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.firstChild && elem.firstChild.nodeType === 1 ) { | |
elem = elem.firstChild; | |
} | |
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(); | |
}, | |
append: function() { | |
return this.domManip(arguments, true, function( elem ) { | |
if ( this.nodeType === 1 || this.nodeType === 11 ) { | |
this.appendChild( elem ); | |
} | |
}); | |
}, | |
prepend: function() { | |
return this.domManip(arguments, true, function( elem ) { | |
if ( this.nodeType === 1 || this.nodeType === 11 ) { | |
this.insertBefore( elem, this.firstChild ); | |
} | |
}); | |
}, | |
before: function() { | |
if ( !isDisconnected( this[0] ) ) { | |
return this.domManip(arguments, false, function( elem ) { | |
this.parentNode.insertBefore( elem, this ); | |
}); | |
} | |
if ( arguments.length ) { | |
var set = jQuery.clean( arguments ); | |
return this.pushStack( jQuery.merge( set, this ), "before", this.selector ); | |
} | |
}, | |
after: function() { | |
if ( !isDisconnected( this[0] ) ) { | |
return this.domManip(arguments, false, function( elem ) { | |
this.parentNode.insertBefore( elem, this.nextSibling ); | |
}); | |
} | |
if ( arguments.length ) { | |
var set = jQuery.clean( arguments ); | |
return this.pushStack( jQuery.merge( this, set ), "after", this.selector ); | |
} | |
}, | |
// keepData is for internal use only--do not document | |
remove: function( selector, keepData ) { | |
var elem, | |
i = 0; | |
for ( ; (elem = this[i]) != null; i++ ) { | |
if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { | |
if ( !keepData && elem.nodeType === 1 ) { | |
jQuery.cleanData( elem.getElementsByTagName("*") ); | |
jQuery.cleanData( [ elem ] ); | |
} | |
if ( elem.parentNode ) { | |
elem.parentNode.removeChild( elem ); | |
} | |
} | |
} | |
return this; | |
}, | |
empty: function() { | |
var elem, | |
i = 0; | |
for ( ; (elem = this[i]) != null; i++ ) { | |
// Remove element nodes and prevent memory leaks | |
if ( elem.nodeType === 1 ) { | |
jQuery.cleanData( elem.getElementsByTagName("*") ); | |
} | |
// Remove any remaining nodes | |
while ( elem.firstChild ) { | |
elem.removeChild( elem.firstChild ); | |
} | |
} | |
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 ) { | |
return elem.nodeType === 1 ? | |
elem.innerHTML.replace( rinlinejQuery, "" ) : | |
undefined; | |
} | |
// See if we can take a shortcut and just use innerHTML | |
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && | |
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && | |
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && | |
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { | |
value = value.replace( rxhtmlTag, "<$1></$2>" ); | |
try { | |
for (; i < l; i++ ) { | |
// Remove element nodes and prevent memory leaks | |
elem = this[i] || {}; | |
if ( elem.nodeType === 1 ) { | |
jQuery.cleanData( elem.getElementsByTagName( "*" ) ); | |
elem.innerHTML = value; | |
} | |
} | |
elem = 0; | |
// If using innerHTML throws an exception, use the fallback method | |
} catch(e) {} | |
} | |
if ( elem ) { | |
this.empty().append( value ); | |
} | |
}, null, value, arguments.length ); | |
}, | |
replaceWith: function( value ) { | |
if ( !isDisconnected( this[0] ) ) { | |
// Make sure that the elements are removed from the DOM before they are inserted | |
// this can help fix replacing a parent with child elements | |
if ( jQuery.isFunction( value ) ) { | |
return this.each(function(i) { | |
var self = jQuery(this), old = self.html(); | |
self.replaceWith( value.call( this, i, old ) ); | |
}); | |
} | |
if ( typeof value !== "string" ) { | |
value = jQuery( value ).detach(); | |
} | |
return this.each(function() { | |
var next = this.nextSibling, | |
parent = this.parentNode; | |
jQuery( this ).remove(); | |
if ( next ) { | |
jQuery(next).before( value ); | |
} else { | |
jQuery(parent).append( value ); | |
} | |
}); | |
} | |
return this.length ? | |
this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : | |
this; | |
}, | |
detach: function( selector ) { | |
return this.remove( selector, true ); | |
}, | |
domManip: function( args, table, callback ) { | |
// Flatten any nested arrays | |
args = [].concat.apply( [], args ); | |
var results, first, fragment, iNoClone, | |
i = 0, | |
value = args[0], | |
scripts = [], | |
l = this.length; | |
// We can't cloneNode fragments that contain checked, in WebKit | |
if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) { | |
return this.each(function() { | |
jQuery(this).domManip( args, table, callback ); | |
}); | |
} | |
if ( jQuery.isFunction(value) ) { | |
return this.each(function(i) { | |
var self = jQuery(this); | |
args[0] = value.call( this, i, table ? self.html() : undefined ); | |
self.domManip( args, table, callback ); | |
}); | |
} | |
if ( this[0] ) { | |
results = jQuery.buildFragment( args, this, scripts ); | |
fragment = results.fragment; | |
first = fragment.firstChild; | |
if ( fragment.childNodes.length === 1 ) { | |
fragment = first; | |
} | |
if ( first ) { | |
table = table && jQuery.nodeName( first, "tr" ); | |
// Use the original fragment for the last item instead of the first because it can end up | |
// being emptied incorrectly in certain situations (#8070). | |
// Fragments from the fragment cache must always be cloned and never used in place. | |
for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) { | |
callback.call( | |
table && jQuery.nodeName( this[i], "table" ) ? | |
findOrAppend( this[i], "tbody" ) : | |
this[i], | |
i === iNoClone ? | |
fragment : | |
jQuery.clone( fragment, true, true ) | |
); | |
} | |
} | |
// Fix #11809: Avoid leaking memory | |
fragment = first = null; | |
if ( scripts.length ) { | |
jQuery.each( scripts, function( i, elem ) { | |
if ( elem.src ) { | |
if ( jQuery.ajax ) { | |
jQuery.ajax({ | |
url: elem.src, | |
type: "GET", | |
dataType: "script", | |
async: false, | |
global: false, | |
"throws": true | |
}); | |
} else { | |
jQuery.error("no ajax"); | |
} | |
} else { | |
jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) ); | |
} | |
if ( elem.parentNode ) { | |
elem.parentNode.removeChild( elem ); | |
} | |
}); | |
} | |
} | |
return this; | |
} | |
}); | |
function findOrAppend( elem, tag ) { | |
return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); | |
} | |
function cloneCopyEvent( src, dest ) { | |
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { | |
return; | |
} | |
var type, i, l, | |
oldData = jQuery._data( src ), | |
curData = jQuery._data( dest, oldData ), | |
events = oldData.events; | |
if ( events ) { | |
delete curData.handle; | |
curData.events = {}; | |
for ( type in events ) { | |
for ( i = 0, l = events[ type ].length; i < l; i++ ) { | |
jQuery.event.add( dest, type, events[ type ][ i ] ); | |
} | |
} | |
} | |
// make the cloned public data object a copy from the original | |
if ( curData.data ) { | |
curData.data = jQuery.extend( {}, curData.data ); | |
} | |
} | |
function cloneFixAttributes( src, dest ) { | |
var nodeName; | |
// We do not need to do anything for non-Elements | |
if ( dest.nodeType !== 1 ) { | |
return; | |
} | |
// clearAttributes removes the attributes, which we don't want, | |
// but also removes the attachEvent events, which we *do* want | |
if ( dest.clearAttributes ) { | |
dest.clearAttributes(); | |
} | |
// mergeAttributes, in contrast, only merges back on the | |
// original attributes, not the events | |
if ( dest.mergeAttributes ) { | |
dest.mergeAttributes( src ); | |
} | |
nodeName = dest.nodeName.toLowerCase(); | |
if ( nodeName === "object" ) { | |
// IE6-10 improperly clones children of object elements using classid. | |
// IE10 throws NoModificationAllowedError if parent is null, #12132. | |
if ( dest.parentNode ) { | |
dest.outerHTML = src.outerHTML; | |
} | |
// This path appears unavoidable for IE9. When cloning an object | |
// element in IE9, the outerHTML strategy above is not sufficient. | |
// If the src has innerHTML and the destination does not, | |
// copy the src.innerHTML into the dest.innerHTML. #10324 | |
if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) { | |
dest.innerHTML = src.innerHTML; | |
} | |
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { | |
// IE6-8 fails to persist the checked state of a cloned checkbox | |
// or radio button. Worse, IE6-7 fail to give the cloned element | |
// a checked appearance if the defaultChecked value isn't also set | |
dest.defaultChecked = dest.checked = src.checked; | |
// IE6-7 get confused and end up setting the value of a cloned | |
// checkbox/radio button to an empty string instead of "on" | |
if ( dest.value !== src.value ) { | |
dest.value = src.value; | |
} | |
// IE6-8 fails to return the selected option to the default selected | |
// state when cloning options | |
} else if ( nodeName === "option" ) { | |
dest.selected = src.defaultSelected; | |
// IE6-8 fails to set the defaultValue to the correct value when | |
// cloning other types of input fields | |
} else if ( nodeName === "input" || nodeName === "textarea" ) { | |
dest.defaultValue = src.defaultValue; | |
// IE blanks contents when cloning scripts | |
} else if ( nodeName === "script" && dest.text !== src.text ) { | |
dest.text = src.text; | |
} | |
// Event data gets referenced instead of copied if the expando | |
// gets copied too | |
dest.removeAttribute( jQuery.expando ); | |
} | |
jQuery.buildFragment = function( args, context, scripts ) { | |
var fragment, cacheable, cachehit, | |
first = args[ 0 ]; | |
// Set context from what may come in as undefined or a jQuery collection or a node | |
// Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 & | |
// also doubles as fix for #8950 where plain objects caused createDocumentFragment exception | |
context = context || document; | |
context = !context.nodeType && context[0] || context; | |
context = context.ownerDocument || context; | |
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document | |
// Cloning options loses the selected state, so don't cache them | |
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment | |
// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache | |
// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 | |
if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document && | |
first.charAt(0) === "<" && !rnocache.test( first ) && | |
(jQuery.support.checkClone || !rchecked.test( first )) && | |
(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { | |
// Mark cacheable and look for a hit | |
cacheable = true; | |
fragment = jQuery.fragments[ first ]; | |
cachehit = fragment !== undefined; | |
} | |
if ( !fragment ) { | |
fragment = context.createDocumentFragment(); | |
jQuery.clean( args, context, fragment, scripts ); | |
// Update the cache, but only store false | |
// unless this is a second parsing of the same content | |
if ( cacheable ) { | |
jQuery.fragments[ first ] = cachehit && fragment; | |
} | |
} | |
return { fragment: fragment, cacheable: cacheable }; | |
}; | |
jQuery.fragments = {}; | |
jQuery.each({ | |
appendTo: "append", | |
prependTo: "prepend", | |
insertBefore: "before", | |
insertAfter: "after", | |
replaceAll: "replaceWith" | |
}, function( name, original ) { | |
jQuery.fn[ name ] = function( selector ) { | |
var elems, | |
i = 0, | |
ret = [], | |
insert = jQuery( selector ), | |
l = insert.length, | |
parent = this.length === 1 && this[0].parentNode; | |
if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) { | |
insert[ original ]( this[0] ); | |
return this; | |
} else { | |
for ( ; i < l; i++ ) { | |
elems = ( i > 0 ? this.clone(true) : this ).get(); | |
jQuery( insert[i] )[ original ]( elems ); | |
ret = ret.concat( elems ); | |
} | |
return this.pushStack( ret, name, insert.selector ); | |
} | |
}; | |
}); | |
function getAll( elem ) { | |
if ( typeof elem.getElementsByTagName !== "undefined" ) { | |
return elem.getElementsByTagName( "*" ); | |
} else if ( typeof elem.querySelectorAll !== "undefined" ) { | |
return elem.querySelectorAll( "*" ); | |
} else { | |
return []; | |
} | |
} | |
// Used in clean, fixes the defaultChecked property | |
function fixDefaultChecked( elem ) { | |
if ( rcheckableType.test( elem.type ) ) { | |
elem.defaultChecked = elem.checked; | |
} | |
} | |
jQuery.extend({ | |
clone: function( elem, dataAndEvents, deepDataAndEvents ) { | |
var srcElements, | |
destElements, | |
i, | |
clone; | |
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { | |
clone = elem.cloneNode( true ); | |
// IE<=8 does not properly clone detached, unknown element nodes | |
} else { | |
fragmentDiv.innerHTML = elem.outerHTML; | |
fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); | |
} | |
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && | |
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { | |
// IE copies events bound via attachEvent when using cloneNode. | |
// Calling detachEvent on the clone will also remove the events | |
// from the original. In order to get around this, we use some | |
// proprietary methods to clear the events. Thanks to MooTools | |
// guys for this hotness. | |
cloneFixAttributes( elem, clone ); | |
// Using Sizzle here is crazy slow, so we use getElementsByTagName instead | |
srcElements = getAll( elem ); | |
destElements = getAll( clone ); | |
// Weird iteration because IE will replace the length property | |
// with an element if you are cloning the body and one of the | |
// elements on the page has a name or id of "length" | |
for ( i = 0; srcElements[i]; ++i ) { | |
// Ensure that the destination node is not null; Fixes #9587 | |
if ( destElements[i] ) { | |
cloneFixAttributes( srcElements[i], destElements[i] ); | |
} | |
} | |
} | |
// Copy the events from the original to the clone | |
if ( dataAndEvents ) { | |
cloneCopyEvent( elem, clone ); | |
if ( deepDataAndEvents ) { | |
srcElements = getAll( elem ); | |
destElements = getAll( clone ); | |
for ( i = 0; srcElements[i]; ++i ) { | |
cloneCopyEvent( srcElements[i], destElements[i] ); | |
} | |
} | |
} | |
srcElements = destElements = null; | |
// Return the cloned set | |
return clone; | |
}, | |
clean: function( elems, context, fragment, scripts ) { | |
var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags, | |
safe = context === document && safeFragment, | |
ret = []; | |
// Ensure that context is a document | |
if ( !context || typeof context.createDocumentFragment === "undefined" ) { | |
context = document; | |
} | |
// Use the already-created safe fragment if context permits | |
for ( i = 0; (elem = elems[i]) != null; i++ ) { | |
if ( typeof elem === "number" ) { | |
elem += ""; | |
} | |
if ( !elem ) { | |
continue; | |
} | |
// Convert html string into DOM nodes | |
if ( typeof elem === "string" ) { | |
if ( !rhtml.test( elem ) ) { | |
elem = context.createTextNode( elem ); | |
} else { | |
// Ensure a safe container in which to render the html | |
safe = safe || createSafeFragment( context ); | |
div = context.createElement("div"); | |
safe.appendChild( div ); | |
// Fix "XHTML"-style tags in all browsers | |
elem = elem.replace(rxhtmlTag, "<$1></$2>"); | |
// Go to html and back, then peel off extra wrappers | |
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); | |
wrap = wrapMap[ tag ] || wrapMap._default; | |
depth = wrap[0]; | |
div.innerHTML = wrap[1] + elem + wrap[2]; | |
// Move to the right depth | |
while ( depth-- ) { | |
div = div.lastChild; | |
} | |
// Remove IE's autoinserted <tbody> from table fragments | |
if ( !jQuery.support.tbody ) { | |
// String was a <table>, *may* have spurious <tbody> | |
hasBody = rtbody.test(elem); | |
tbody = tag === "table" && !hasBody ? | |
div.firstChild && div.firstChild.childNodes : | |
// String was a bare <thead> or <tfoot> | |
wrap[1] === "<table>" && !hasBody ? | |
div.childNodes : | |
[]; | |
for ( j = tbody.length - 1; j >= 0 ; --j ) { | |
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { | |
tbody[ j ].parentNode.removeChild( tbody[ j ] ); | |
} | |
} | |
} | |
// IE completely kills leading whitespace when innerHTML is used | |
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { | |
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); | |
} | |
elem = div.childNodes; | |
// Take out of fragment container (we need a fresh div each time) | |
div.parentNode.removeChild( div ); | |
} | |
} | |
if ( elem.nodeType ) { | |
ret.push( elem ); | |
} else { | |
jQuery.merge( ret, elem ); | |
} | |
} | |
// Fix #11356: Clear elements from safeFragment | |
if ( div ) { | |
elem = div = safe = null; | |
} | |
// Reset defaultChecked for any radios and checkboxes | |
// about to be appended to the DOM in IE 6/7 (#8060) | |
if ( !jQuery.support.appendChecked ) { | |
for ( i = 0; (elem = ret[i]) != null; i++ ) { | |
if ( jQuery.nodeName( elem, "input" ) ) { | |
fixDefaultChecked( elem ); | |
} else if ( typeof elem.getElementsByTagName !== "undefined" ) { | |
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); | |
} | |
} | |
} | |
// Append elements to a provided document fragment | |
if ( fragment ) { | |
// Special handling of each script element | |
handleScript = function( elem ) { | |
// Check if we consider it executable | |
if ( !elem.type || rscriptType.test( elem.type ) ) { | |
// Detach the script and store it in the scripts array (if provided) or the fragment | |
// Return truthy to indicate that it has been handled | |
return scripts ? | |
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : | |
fragment.appendChild( elem ); | |
} | |
}; | |
for ( i = 0; (elem = ret[i]) != null; i++ ) { | |
// Check if we're done after handling an executable script | |
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { | |
// Append to fragment and handle embedded scripts | |
fragment.appendChild( elem ); | |
if ( typeof elem.getElementsByTagName !== "undefined" ) { | |
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration | |
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); | |
// Splice the scripts into ret after their former ancestor and advance our index beyond them | |
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); | |
i += jsTags.length; | |
} | |
} | |
} | |
} | |
return ret; | |
}, | |
cleanData: function( elems, /* internal */ acceptData ) { | |
var data, id, elem, type, | |
i = 0, | |
internalKey = jQuery.expando, | |
cache = jQuery.cache, | |
deleteExpando = jQuery.support.deleteExpando, | |
special = jQuery.event.special; | |
for ( ; (elem = elems[i]) != null; i++ ) { | |
if ( acceptData || jQuery.acceptData( elem ) ) { | |
id = elem[ internalKey ]; | |
data = id && cache[ id ]; | |
if ( data ) { | |
if ( data.events ) { | |
for ( type in data.events ) { | |
if ( special[ type ] ) { | |
jQuery.event.remove( elem, type ); | |
// This is a shortcut to avoid jQuery.event.remove's overhead | |
} else { | |
jQuery.removeEvent( elem, type, data.handle ); | |
} | |
} | |
} | |
// Remove cache only if it was not already removed by jQuery.event.remove | |
if ( cache[ id ] ) { | |
delete cache[ id ]; | |
// IE does not allow us to delete expando properties from nodes, | |
// nor does it have a removeAttribute function on Document nodes; | |
// we must handle all of these cases | |
if ( deleteExpando ) { | |
delete elem[ internalKey ]; | |
} else if ( elem.removeAttribute ) { | |
elem.removeAttribute( internalKey ); | |
} else { | |
elem[ internalKey ] = null; | |
} | |
jQuery.deletedIds.push( id ); | |
} | |
} | |
} | |
} | |
} | |
}); | |
// Limit scope pollution from any deprecated API | |
(function() { | |
var matched, browser; | |
// Use of jQuery.browser is frowned upon. | |
// More details: http://api.jquery.com/jQuery.browser | |
// jQuery.uaMatch maintained for back-compat | |
jQuery.uaMatch = function( ua ) { | |
ua = ua.toLowerCase(); | |
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || | |
/(webkit)[ \/]([\w.]+)/.exec( ua ) || | |
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || | |
/(msie) ([\w.]+)/.exec( ua ) || | |
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || | |
[]; | |
return { | |
browser: match[ 1 ] || "", | |
version: match[ 2 ] || "0" | |
}; | |
}; | |
matched = jQuery.uaMatch( navigator.userAgent ); | |
browser = {}; | |
if ( matched.browser ) { | |
browser[ matched.browser ] = true; | |
browser.version = matched.version; | |
} | |
// Chrome is Webkit, but Webkit is also Safari. | |
if ( browser.chrome ) { | |
browser.webkit = true; | |
} else if ( browser.webkit ) { | |
browser.safari = true; | |
} | |
jQuery.browser = browser; | |
jQuery.sub = function() { | |
function jQuerySub( selector, context ) { | |
return new jQuerySub.fn.init( selector, context ); | |
} | |
jQuery.extend( true, jQuerySub, this ); | |
jQuerySub.superclass = this; | |
jQuerySub.fn = jQuerySub.prototype = this(); | |
jQuerySub.fn.constructor = jQuerySub; | |
jQuerySub.sub = this.sub; | |
jQuerySub.fn.init = function init( selector, context ) { | |
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { | |
context = jQuerySub( context ); | |
} | |
return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); | |
}; | |
jQuerySub.fn.init.prototype = jQuerySub.fn; | |
var rootjQuerySub = jQuerySub(document); | |
return jQuerySub; | |
}; | |
})(); | |
var curCSS, iframe, iframeDoc, | |
ralpha = /alpha\([^)]*\)/i, | |
ropacity = /opacity=([^)]*)/, | |
rposition = /^(top|right|bottom|left)$/, | |
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption" | |
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display | |
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 = {}, | |
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, | |
cssNormalTransform = { | |
letterSpacing: 0, | |
fontWeight: 400 | |
}, | |
cssExpand = [ "Top", "Right", "Bottom", "Left" ], | |
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], | |
eventsToggle = jQuery.fn.toggle; | |
// return a css property mapped to a potentially vendor prefixed property | |
function vendorPropName( style, name ) { | |
// shortcut for names that are not vendor prefixed | |
if ( name in style ) { | |
return name; | |
} | |
// check for vendor prefixed names | |
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 showHide( elements, show ) { | |
var elem, display, | |
values = [], | |
index = 0, | |
length = elements.length; | |
for ( ; index < length; index++ ) { | |
elem = elements[ index ]; | |
if ( !elem.style ) { | |
continue; | |
} | |
values[ index ] = jQuery._data( elem, "olddisplay" ); | |
if ( show ) { | |
// Reset the inline display of this element to learn if it is | |
// being hidden by cascaded rules or not | |
if ( !values[ index ] && elem.style.display === "none" ) { | |
elem.style.display = ""; | |
} | |
// Set elements which have been overridden with display: none | |
// in a stylesheet to whatever the default browser style is | |
// for such an element | |
if ( elem.style.display === "" && isHidden( elem ) ) { | |
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); | |
} | |
} else { | |
display = curCSS( elem, "display" ); | |
if ( !values[ index ] && display !== "none" ) { | |
jQuery._data( elem, "olddisplay", display ); | |
} | |
} | |
} | |
// Set the display of most of the elements in a second loop | |
// to avoid the constant reflow | |
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 ) { | |
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, fn2 ) { | |
var bool = typeof state === "boolean"; | |
if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { | |
return eventsToggle.apply( this, arguments ); | |
} | |
return this.each(function() { | |
if ( bool ? state : isHidden( this ) ) { | |
jQuery( this ).show(); | |
} else { | |
jQuery( this ).hide(); | |
} | |
}); | |
} | |
}); | |
jQuery.extend({ | |
// Add in style property hooks for overriding the default | |
// behavior of getting and setting a style property | |
cssHooks: { | |
opacity: { | |
get: function( elem, computed ) { | |
if ( computed ) { | |
// We should always get a number back from opacity | |
var ret = curCSS( elem, "opacity" ); | |
return ret === "" ? "1" : ret; | |
} | |
} | |
} | |
}, | |
// Exclude the following css properties to add px | |
cssNumber: { | |
"fillOpacity": true, | |
"fontWeight": true, | |
"lineHeight": true, | |
"opacity": true, | |
"orphans": true, | |
"widows": true, | |
"zIndex": true, | |
"zoom": true | |
}, | |
// Add in properties whose names you wish to fix before | |
// setting or getting the value | |
cssProps: { | |
// normalize float css property | |
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" | |
}, | |
// Get and set the style property on a DOM Node | |
style: function( elem, name, value, extra ) { | |
// Don't set styles on text and comment nodes | |
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { | |
return; | |
} | |
// Make sure that we're working with the right name | |
var ret, type, hooks, | |
origName = jQuery.camelCase( name ), | |
style = elem.style; | |
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); | |
// gets hook for the prefixed version | |
// followed by the unprefixed version | |
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
// Check if we're setting a value | |
if ( value !== undefined ) { | |
type = typeof value; | |
// convert relative number strings (+= or -=) to relative numbers. #7345 | |
if ( type === "string" && (ret = rrelNum.exec( value )) ) { | |
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); | |
// Fixes bug #9237 | |
type = "number"; | |
} | |
// Make sure that NaN and null values aren't set. See: #7116 | |
if ( value == null || type === "number" && isNaN( value ) ) { | |
return; | |
} | |
// If a number was passed in, add 'px' to the (except for certain CSS properties) | |
if ( type === "number" && !jQuery.cssNumber[ origName ] ) { | |
value += "px"; | |
} | |
// If a hook was provided, use that value, otherwise just set the specified value | |
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { | |
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided | |
// Fixes bug #5509 | |
try { | |
style[ name ] = value; | |
} catch(e) {} | |
} | |
} else { | |
// If a hook was provided get the non-computed value from there | |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { | |
return ret; | |
} | |
// Otherwise just get the value from the style object | |
return style[ name ]; | |
} | |
}, | |
css: function( elem, name, numeric, extra ) { | |
var val, num, hooks, | |
origName = jQuery.camelCase( name ); | |
// Make sure that we're working with the right name | |
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); | |
// gets hook for the prefixed version | |
// followed by the unprefixed version | |
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; | |
// If a hook was provided get the computed value from there | |
if ( hooks && "get" in hooks ) { | |
val = hooks.get( elem, true, extra ); | |
} | |
// Otherwise, if a way to get the computed value exists, use that | |
if ( val === undefined ) { | |
val = curCSS( elem, name ); | |
} | |
//convert "normal" to computed value | |
if ( val === "normal" && name in cssNormalTransform ) { | |
val = cssNormalTransform[ name ]; | |
} | |
// Return, converting to number if forced or a qualifier was provided and val looks numeric | |
if ( numeric || extra !== undefined ) { | |
num = parseFloat( val ); | |
return numeric || jQuery.isNumeric( num ) ? num || 0 : val; | |
} | |
return val; | |
}, | |
// A method for quickly swapping in/out CSS properties to get correct calculations | |
swap: function( elem, options, callback ) { | |
var ret, name, | |
old = {}; | |
// Remember the old values, and insert the new ones | |
for ( name in options ) { | |
old[ name ] = elem.style[ name ]; | |
elem.style[ name ] = options[ name ]; | |
} | |
ret = callback.call( elem ); | |
// Revert the old values | |
for ( name in options ) { | |
elem.style[ name ] = old[ name ]; | |
} | |
return ret; | |
} | |
}); | |
// NOTE: To any future maintainer, we've window.getComputedStyle | |
// because jsdom on node.js will break without it. | |
if ( window.getComputedStyle ) { | |
curCSS = function( elem, name ) { | |
var ret, width, minWidth, maxWidth, | |
computed = window.getComputedStyle( elem, null ), | |
style = elem.style; | |
if ( computed ) { | |
ret = computed[ name ]; | |
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { | |
ret = jQuery.style( elem, name ); | |
} | |
// A tribute to the "awesome hack by Dean Edwards" | |
// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right | |
// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels | |
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values | |
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; | |
}; | |
} else if ( document.documentElement.currentStyle ) { | |
curCSS = function( elem, name ) { | |
var left, rsLeft, | |
ret = elem.currentStyle && elem.currentStyle[ name ], | |
style = elem.style; | |
// Avoid setting ret to empty string here | |
// so we don't default to auto | |
if ( ret == null && style && style[ name ] ) { | |
ret = style[ name ]; | |
} | |
// From the awesome hack by Dean Edwards | |
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 | |
// If we're not dealing with a regular pixel number | |
// but a number that has a weird ending, we need to convert it to pixels | |
// but not position css attributes, as those are proportional to the parent element instead | |
// and we can't measure the parent instead because it might trigger a "stacking dolls" problem | |
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { | |
// Remember the original values | |
left = style.left; | |
rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; | |
// Put in the new values to get a computed value out | |
if ( rsLeft ) { | |
elem.runtimeStyle.left = elem.currentStyle.left; | |
} | |
style.left = name === "fontSize" ? "1em" : ret; | |
ret = style.pixelLeft + "px"; | |
// Revert the changed values | |
style.left = left; | |
if ( rsLeft ) { | |
elem.runtimeStyle.left = rsLeft; | |
} | |
} | |
return ret === "" ? "auto" : 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 ) { | |
var i = extra === ( isBorderBox ? "border" : "content" ) ? | |
// If we already have the right measurement, avoid augmentation | |
4 : | |
// Otherwise initialize for horizontal or vertical properties | |
name === "width" ? 1 : 0, | |
val = 0; | |
for ( ; i < 4; i += 2 ) { | |
// both box models exclude margin, so add it if we want it | |
if ( extra === "margin" ) { | |
// we use jQuery.css instead of curCSS here | |
// because of the reliableMarginRight CSS hook! | |
val += jQuery.css( elem, extra + cssExpand[ i ], true ); | |
} | |
// From this point on we use curCSS for maximum performance (relevant in animations) | |
if ( isBorderBox ) { | |
// border-box includes padding, so remove it if we want content | |
if ( extra === "content" ) { | |
val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; | |
} | |
// at this point, extra isn't border nor margin, so remove border | |
if ( extra !== "margin" ) { | |
val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; | |
} | |
} else { | |
// at this point, extra isn't content, so add padding | |
val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; | |
// at this point, extra isn't content nor padding, so add border | |
if ( extra !== "padding" ) { | |
val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; | |
} | |
} | |
} | |
return val; | |
} | |
function getWidthOrHeight( elem, name, extra ) { | |
// Start with offset property, which is equivalent to the border-box value | |
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | |
valueIsBorderBox = true, | |
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"; | |
// some non-html elements return undefined for offsetWidth, so check for null/undefined | |
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 | |
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 | |
if ( val <= 0 || val == null ) { | |
// Fall back to computed then uncomputed css if necessary | |
val = curCSS( elem, name ); | |
if ( val < 0 || val == null ) { | |
val = elem.style[ name ]; | |
} | |
// Computed unit is not pixels. Stop here and return. | |
if ( rnumnonpx.test(val) ) { | |
return val; | |
} | |
// we need the check for style in case a browser which returns unreliable values | |
// for getComputedStyle silently falls back to the reliable elem.style | |
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); | |
// Normalize "", auto, and prepare for extra | |
val = parseFloat( val ) || 0; | |
} | |
// use the active box-sizing model to add/subtract irrelevant styles | |
return ( val + | |
augmentWidthOrHeight( | |
elem, | |
name, | |
extra || ( isBorderBox ? "border" : "content" ), | |
valueIsBorderBox | |
) | |
) + "px"; | |
} | |
// Try to determine the default display value of an element | |
function css_defaultDisplay( nodeName ) { | |
if ( elemdisplay[ nodeName ] ) { | |
return elemdisplay[ nodeName ]; | |
} | |
var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ), | |
display = elem.css("display"); | |
elem.remove(); | |
// If the simple way fails, | |
// get element's real default display by attaching it to a temp iframe | |
if ( display === "none" || display === "" ) { | |
// Use the already-created iframe if possible | |
iframe = document.body.appendChild( | |
iframe || jQuery.extend( document.createElement("iframe"), { | |
frameBorder: 0, | |
width: 0, | |
height: 0 | |
}) | |
); | |
// Create a cacheable copy of the iframe document on first call. | |
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML | |
// document to it; WebKit & Firefox won't allow reusing the iframe document. | |
if ( !iframeDoc || !iframe.createElement ) { | |
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; | |
iframeDoc.write("<!doctype html><html><body>"); | |
iframeDoc.close(); | |
} | |
elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) ); | |
display = curCSS( elem, "display" ); | |
document.body.removeChild( iframe ); | |
} | |
// Store the correct default display | |
elemdisplay[ nodeName ] = display; | |
return display; | |
} | |
jQuery.each([ "height", "width" ], function( i, name ) { | |
jQuery.cssHooks[ name ] = { | |
get: function( elem, computed, extra ) { | |
if ( computed ) { | |
// certain elements can have dimension info if we invisibly show them | |
// however, it must have a current display style that would benefit from this | |
if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) { | |
return jQuery.swap( elem, cssShow, function() { | |
return getWidthOrHeight( elem, name, extra ); | |
}); | |
} else { | |
return getWidthOrHeight( elem, name, extra ); | |
} | |
} | |
}, | |
set: function( elem, value, extra ) { | |
return setPositiveNumber( elem, value, extra ? | |
augmentWidthOrHeight( | |
elem, | |
name, | |
extra, | |
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box" | |
) : 0 | |
); | |
} | |
}; | |
}); | |
if ( !jQuery.support.opacity ) { | |
jQuery.cssHooks.opacity = { | |
get: function( elem, computed ) { | |
// IE uses filters for opacity | |
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? | |
( 0.01 * parseFloat( RegExp.$1 ) ) + "" : | |
computed ? "1" : ""; | |
}, | |
set: function( elem, value ) { | |
var style = elem.style, | |
currentStyle = elem.currentStyle, | |
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", | |
filter = currentStyle && currentStyle.filter || style.filter || ""; | |
// IE has trouble with opacity if it does not have layout | |
// Force it by setting the zoom level | |
style.zoom = 1; | |
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 | |
if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" && | |
style.removeAttribute ) { | |
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText | |
// if "filter:" is present at all, clearType is disabled, we want to avoid this | |
// style.removeAttribute is IE Only, but so apparently is this code path... | |
style.removeAttribute( "filter" ); | |
// if there there is no filter style applied in a css rule, we are done | |
if ( currentStyle && !currentStyle.filter ) { | |
return; | |
} | |
} | |
// otherwise, set new filter values | |
style.filter = ralpha.test( filter ) ? | |
filter.replace( ralpha, opacity ) : | |
filter + " " + opacity; | |
} | |
}; | |
} | |
// These hooks cannot be added until DOM ready because the support test | |
// for it is not run until after DOM ready | |
jQuery(function() { | |
if ( !jQuery.support.reliableMarginRight ) { | |
jQuery.cssHooks.marginRight = { | |
get: function( elem, computed ) { | |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | |
// Work around by temporarily setting element display to inline-block | |
return jQuery.swap( elem, { "display": "inline-block" }, function() { | |
if ( computed ) { | |
return curCSS( elem, "marginRight" ); | |
} | |
}); | |
} | |
}; | |
} | |
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 | |
// getComputedStyle returns percent when specified for top/left/bottom/right | |
// rather than make the css module depend on the offset module, we just check for it here | |
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { | |
jQuery.each( [ "top", "left" ], function( i, prop ) { | |
jQuery.cssHooks[ prop ] = { | |
get: function( elem, computed ) { | |
if ( computed ) { | |
var ret = curCSS( elem, prop ); | |
// if curCSS returns percentage, fallback to offset | |
return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret; | |
} | |
} | |
}; | |
}); | |
} | |
}); | |
if ( jQuery.expr && jQuery.expr.filters ) { | |
jQuery.expr.filters.hidden = function( elem ) { | |
return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none"); | |
}; | |
jQuery.expr.filters.visible = function( elem ) { | |
return !jQuery.expr.filters.hidden( elem ); | |
}; | |
} | |
// These hooks are used by animate to expand properties | |
jQuery.each({ | |
margin: "", | |
padding: "", | |
border: "Width" | |
}, function( prefix, suffix ) { | |
jQuery.cssHooks[ prefix + suffix ] = { | |
expand: function( value ) { | |
var i, | |
// assumes a single number if not a string | |
parts = typeof value === "string" ? value.split(" ") : [ value ], | |
expanded = {}; | |
for ( i = 0; 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, | |
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, | |
rselectTextarea = /^(?:select|textarea)/i; | |
jQuery.fn.extend({ | |
serialize: function() { | |
return jQuery.param( this.serializeArray() ); | |
}, | |
serializeArray: function() { | |
return this.map(function(){ | |
return this.elements ? jQuery.makeArray( this.elements ) : this; | |
}) | |
.filter(function(){ | |
return this.name && !this.disabled && | |
( this.checked || rselectTextarea.test( this.nodeName ) || | |
rinput.test( this.type ) ); | |
}) | |
.map(function( i, elem ){ | |
var val = jQuery( this ).val(); | |
return val == null ? | |
null : | |
jQuery.isArray( val ) ? | |
jQuery.map( val, function( val, i ){ | |
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; | |
}) : | |
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; | |
}).get(); | |
} | |
}); | |
//Serialize an array of form elements or a set of | |
//key/values into a query string | |
jQuery.param = function( a, traditional ) { | |
var prefix, | |
s = [], | |
add = function( key, value ) { | |
// If value is a function, invoke it and return its value | |
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); | |
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); | |
}; | |
// Set traditional to true for jQuery <= 1.3.2 behavior. | |
if ( traditional === undefined ) { | |
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; | |
} | |
// If an array was passed in, assume that it is an array of form elements. | |
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { | |
// Serialize the form elements | |
jQuery.each( a, function() { | |
add( this.name, this.value ); | |
}); | |
} else { | |
// If traditional, encode the "old" way (the way 1.3.2 or older | |
// did it), otherwise encode params recursively. | |
for ( prefix in a ) { | |
buildParams( prefix, a[ prefix ], traditional, add ); | |
} | |
} | |
// Return the resulting serialization | |
return s.join( "&" ).replace( r20, "+" ); | |
}; | |
function buildParams( prefix, obj, traditional, add ) { | |
var name; | |
if ( jQuery.isArray( obj ) ) { | |
// Serialize array item. | |
jQuery.each( obj, function( i, v ) { | |
if ( traditional || rbracket.test( prefix ) ) { | |
// Treat each array item as a scalar. | |
add( prefix, v ); | |
} else { | |
// If array item is non-scalar (array or object), encode its | |
// numeric index to resolve deserialization ambiguity issues. | |
// Note that rack (as of 1.0.0) can't currently deserialize | |
// nested arrays properly, and attempting to do so may cause | |
// a server error. Possible fixes are to modify rack's | |
// deserialization algorithm or to provide an option or flag | |
// to force array serialization to be shallow. | |
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); | |
} | |
}); | |
} else if ( !traditional && jQuery.type( obj ) === "object" ) { | |
// Serialize object item. | |
for ( name in obj ) { | |
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); | |
} | |
} else { | |
// Serialize scalar item. | |
add( prefix, obj ); | |
} | |
} | |
var | |
// Document location | |
ajaxLocParts, | |
ajaxLocation, | |
rhash = /#.*$/, | |
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL | |
// #7653, #8125, #8152: local protocol detection | |
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, | |
rnoContent = /^(?:GET|HEAD)$/, | |
rprotocol = /^\/\//, | |
rquery = /\?/, | |
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, | |
rts = /([?&])_=[^&]*/, | |
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, | |
// Keep a copy of the old load method | |
_load = jQuery.fn.load, | |
/* Prefilters | |
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) | |
* 2) These are called: | |
* - BEFORE asking for a transport | |
* - AFTER param serialization (s.data is a string if s.processData is true) | |
* 3) key is the dataType | |
* 4) the catchall symbol "*" can be used | |
* 5) execution will start with transport dataType and THEN continue down to "*" if needed | |
*/ | |
prefilters = {}, | |
/* Transports bindings | |
* 1) key is the dataType | |
* 2) the catchall symbol "*" can be used | |
* 3) selection will start with transport dataType and THEN go to "*" if needed | |
*/ | |
transports = {}, | |
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression | |
allTypes = ["*/"] + ["*"]; | |
// #8138, IE may throw an exception when accessing | |
// a field from window.location if document.domain has been set | |
try { | |
ajaxLocation = location.href; | |
} catch( e ) { | |
// Use the href attribute of an A element | |
// since IE will modify it given document.location | |
ajaxLocation = document.createElement( "a" ); | |
ajaxLocation.href = ""; | |
ajaxLocation = ajaxLocation.href; | |
} | |
// Segment location into parts | |
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; | |
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport | |
function addToPrefiltersOrTransports( structure ) { | |
// dataTypeExpression is optional and defaults to "*" | |
return function( dataTypeExpression, func ) { | |
if ( typeof dataTypeExpression !== "string" ) { | |
func = dataTypeExpression; | |
dataTypeExpression = "*"; | |
} | |
var dataType, list, placeBefore, | |
dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ), | |
i = 0, | |
length = dataTypes.length; | |
if ( jQuery.isFunction( func ) ) { | |
// For each dataType in the dataTypeExpression | |
for ( ; i < length; i++ ) { | |
dataType = dataTypes[ i ]; | |
// We control if we're asked to add before | |
// any existing element | |
placeBefore = /^\+/.test( dataType ); | |
if ( placeBefore ) { | |
dataType = dataType.substr( 1 ) || "*"; | |
} | |
list = structure[ dataType ] = structure[ dataType ] || []; | |
// then we add to the structure accordingly | |
list[ placeBefore ? "unshift" : "push" ]( func ); | |
} | |
} | |
}; | |
} | |
// Base inspection function for prefilters and transports | |
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, | |
dataType /* internal */, inspected /* internal */ ) { | |
dataType = dataType || options.dataTypes[ 0 ]; | |
inspected = inspected || {}; | |
inspected[ dataType ] = true; | |
var selection, | |
list = structure[ dataType ], | |
i = 0, | |
length = list ? list.length : 0, | |
executeOnly = ( structure === prefilters ); | |
for ( ; i < length && ( executeOnly || !selection ); i++ ) { | |
selection = list[ i ]( options, originalOptions, jqXHR ); | |
// If we got redirected to another dataType | |
// we try there if executing only and not done already | |
if ( typeof selection === "string" ) { | |
if ( !executeOnly || inspected[ selection ] ) { | |
selection = undefined; | |
} else { | |
options.dataTypes.unshift( selection ); | |
selection = inspectPrefiltersOrTransports( | |
structure, options, originalOptions, jqXHR, selection, inspected ); | |
} | |
} | |
} | |
// If we're only executing or nothing was selected | |
// we try the catchall dataType if not done already | |
if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { | |
selection = inspectPrefiltersOrTransports( | |
structure, options, originalOptions, jqXHR, "*", inspected ); | |
} | |
// unnecessary when only executing (prefilters) | |
// but it'll be ignored by the caller in that case | |
return selection; | |
} | |
// A special extend for ajax options | |
// that takes "flat" options (not to be deep extended) | |
// Fixes #9887 | |
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 ); | |
} | |
} | |
jQuery.fn.load = function( url, params, callback ) { | |
if ( typeof url !== "string" && _load ) { | |
return _load.apply( this, arguments ); | |
} | |
// Don't do a request if no elements are being requested | |
if ( !this.length ) { | |
return this; | |
} | |
var selector, type, response, | |
self = this, | |
off = url.indexOf(" "); | |
if ( off >= 0 ) { | |
selector = url.slice( off, url.length ); | |
url = url.slice( 0, off ); | |
} | |
// If it's a function | |
if ( jQuery.isFunction( params ) ) { | |
// We assume that it's the callback | |
callback = params; | |
params = undefined; | |
// Otherwise, build a param string | |
} else if ( params && typeof params === "object" ) { | |
type = "POST"; | |
} | |
// Request the remote document | |
jQuery.ajax({ | |
url: url, | |
// if "type" variable is undefined, then "GET" method will be used | |
type: type, | |
dataType: "html", | |
data: params, | |
complete: function( jqXHR, status ) { | |
if ( callback ) { | |
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); | |
} | |
} | |
}).done(function( responseText ) { | |
// Save response for use in complete callback | |
response = arguments; | |
// See if a selector was specified | |
self.html( selector ? | |
// Create a dummy div to hold the results | |
jQuery("<div>") | |
// inject the contents of the document in, removing the scripts | |
// to avoid any 'Permission Denied' errors in IE | |
.append( responseText.replace( rscript, "" ) ) | |
// Locate the specified elements | |
.find( selector ) : | |
// If not, just inject the full result | |
responseText ); | |
}); | |
return this; | |
}; | |
// Attach a bunch of functions for handling common AJAX events | |
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ | |
jQuery.fn[ o ] = function( f ){ | |
return this.on( o, f ); | |
}; | |
}); | |
jQuery.each( [ "get", "post" ], function( i, method ) { | |
jQuery[ method ] = function( url, data, callback, type ) { | |
// shift arguments if data argument was omitted | |
if ( jQuery.isFunction( data ) ) { | |
type = type || callback; | |
callback = data; | |
data = undefined; | |
} | |
return jQuery.ajax({ | |
type: method, | |
url: url, | |
data: data, | |
success: callback, | |
dataType: type | |
}); | |
}; | |
}); | |
jQuery.extend({ | |
getScript: function( url, callback ) { | |
return jQuery.get( url, undefined, callback, "script" ); | |
}, | |
getJSON: function( url, data, callback ) { | |
return jQuery.get( url, data, callback, "json" ); | |
}, | |
// Creates a full fledged settings object into target | |
// with both ajaxSettings and settings fields. | |
// If target is omitted, writes into ajaxSettings. | |
ajaxSetup: function( target, settings ) { | |
if ( settings ) { | |
// Building a settings object | |
ajaxExtend( target, jQuery.ajaxSettings ); | |
} else { | |
// Extending ajaxSettings | |
settings = target; | |
target = jQuery.ajaxSettings; | |
} | |
ajaxExtend( target, settings ); | |
return target; | |
}, | |
ajaxSettings: { | |
url: ajaxLocation, | |
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), | |
global: true, | |
type: "GET", | |
contentType: "application/x-www-form-urlencoded; charset=UTF-8", | |
processData: true, | |
async: true, | |
/* | |
timeout: 0, | |
data: null, | |
dataType: null, | |
username: null, | |
password: null, | |
cache: null, | |
throws: false, | |
traditional: false, | |
headers: {}, | |
*/ | |
accepts: { | |
xml: "application/xml, text/xml", | |
html: "text/html", | |
text: "text/plain", | |
json: "application/json, text/javascript", | |
"*": allTypes | |
}, | |
contents: { | |
xml: /xml/, | |
html: /html/, | |
json: /json/ | |
}, | |
responseFields: { | |
xml: "responseXML", | |
text: "responseText" | |
}, | |
// List of data converters | |
// 1) key format is "source_type destination_type" (a single space in-between) | |
// 2) the catchall symbol "*" can be used for source_type | |
converters: { | |
// Convert anything to text | |
"* text": window.String, | |
// Text to html (true = no transformation) | |
"text html": true, | |
// Evaluate text as a json expression | |
"text json": jQuery.parseJSON, | |
// Parse text as xml | |
"text xml": jQuery.parseXML | |
}, | |
// For options that shouldn't be deep extended: | |
// you can add your own custom options here if | |
// and when you create one that shouldn't be | |
// deep extended (see ajaxExtend) | |
flatOptions: { | |
context: true, | |
url: true | |
} | |
}, | |
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), | |
ajaxTransport: addToPrefiltersOrTransports( transports ), | |
// Main method | |
ajax: function( url, options ) { | |
// If url is an object, simulate pre-1.5 signature | |
if ( typeof url === "object" ) { | |
options = url; | |
url = undefined; | |
} | |
// Force options to be an object | |
options = options || {}; | |
var // ifModified key | |
ifModifiedKey, | |
// Response headers | |
responseHeadersString, | |
responseHeaders, | |
// transport | |
transport, | |
// timeout handle | |
timeoutTimer, | |
// Cross-domain detection vars | |
parts, | |
// To know if global events are to be dispatched | |
fireGlobals, | |
// Loop variable | |
i, | |
// Create the final options object | |
s = jQuery.ajaxSetup( {}, options ), | |
// Callbacks context | |
callbackContext = s.context || s, | |
// Context for global events | |
// It's the callbackContext if one was provided in the options | |
// and if it's a DOM node or a jQuery collection | |
globalEventContext = callbackContext !== s && | |
( callbackContext.nodeType || callbackContext instanceof jQuery ) ? | |
jQuery( callbackContext ) : jQuery.event, | |
// Deferreds | |
deferred = jQuery.Deferred(), | |
completeDeferred = jQuery.Callbacks( "once memory" ), | |
// Status-dependent callbacks | |
statusCode = s.statusCode || {}, | |
// Headers (they are sent all at once) | |
requestHeaders = {}, | |
requestHeadersNames = {}, | |
// The jqXHR state | |
state = 0, | |
// Default abort message | |
strAbort = "canceled", | |
// Fake xhr | |
jqXHR = { | |
readyState: 0, | |
// Caches the header | |
setRequestHeader: function( name, value ) { | |
if ( !state ) { | |
var lname = name.toLowerCase(); | |
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; | |
requestHeaders[ name ] = value; | |
} | |
return this; | |
}, | |
// Raw string | |
getAllResponseHeaders: function() { | |
return state === 2 ? responseHeadersString : null; | |
}, | |
// Builds headers hashtable if needed | |
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 === undefined ? null : match; | |
}, | |
// Overrides response content-type header | |
overrideMimeType: function( type ) { | |
if ( !state ) { | |
s.mimeType = type; | |
} | |
return this; | |
}, | |
// Cancel the request | |
abort: function( statusText ) { | |
statusText = statusText || strAbort; | |
if ( transport ) { | |
transport.abort( statusText ); | |
} | |
done( 0, statusText ); | |
return this; | |
} | |
}; | |
// Callback for when everything is done | |
// It is defined here because jslint complains if it is declared | |
// at the end of the function (which would be more logical and readable) | |
function done( status, nativeStatusText, responses, headers ) { | |
var isSuccess, success, error, response, modified, | |
statusText = nativeStatusText; | |
// Called once | |
if ( state === 2 ) { | |
return; | |
} | |
// State is "done" now | |
state = 2; | |
// Clear timeout if it exists | |
if ( timeoutTimer ) { | |
clearTimeout( timeoutTimer ); | |
} | |
// Dereference transport for early garbage collection | |
// (no matter how long the jqXHR object will be used) | |
transport = undefined; | |
// Cache response headers | |
responseHeadersString = headers || ""; | |
// Set readyState | |
jqXHR.readyState = status > 0 ? 4 : 0; | |
// Get response data | |
if ( responses ) { | |
response = ajaxHandleResponses( s, jqXHR, responses ); | |
} | |
// If successful, handle type chaining | |
if ( status >= 200 && status < 300 || status === 304 ) { | |
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. | |
if ( s.ifModified ) { | |
modified = jqXHR.getResponseHeader("Last-Modified"); | |
if ( modified ) { | |
jQuery.lastModified[ ifModifiedKey ] = modified; | |
} | |
modified = jqXHR.getResponseHeader("Etag"); | |
if ( modified ) { | |
jQuery.etag[ ifModifiedKey ] = modified; | |
} | |
} | |
// If not modified | |
if ( status === 304 ) { | |
statusText = "notmodified"; | |
isSuccess = true; | |
// If we have data | |
} else { | |
isSuccess = ajaxConvert( s, response ); | |
statusText = isSuccess.state; | |
success = isSuccess.data; | |
error = isSuccess.error; | |
isSuccess = !error; | |
} | |
} else { | |
// We extract error from statusText | |
// then normalize statusText and status for non-aborts | |
error = statusText; | |
if ( !statusText || status ) { | |
statusText = "error"; | |
if ( status < 0 ) { | |
status = 0; | |
} | |
} | |
} | |
// Set data for the fake xhr object | |
jqXHR.status = status; | |
jqXHR.statusText = ( nativeStatusText || statusText ) + ""; | |
// Success/Error | |
if ( isSuccess ) { | |
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); | |
} else { | |
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); | |
} | |
// Status-dependent callbacks | |
jqXHR.statusCode( statusCode ); | |
statusCode = undefined; | |
if ( fireGlobals ) { | |
globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), | |
[ jqXHR, s, isSuccess ? success : error ] ); | |
} | |
// Complete | |
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); | |
if ( fireGlobals ) { | |
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); | |
// Handle the global AJAX counter | |
if ( !( --jQuery.active ) ) { | |
jQuery.event.trigger( "ajaxStop" ); | |
} | |
} | |
} | |
// Attach deferreds | |
deferred.promise( jqXHR ); | |
jqXHR.success = jqXHR.done; | |
jqXHR.error = jqXHR.fail; | |
jqXHR.complete = completeDeferred.add; | |
// Status-dependent callbacks | |
jqXHR.statusCode = function( map ) { | |
if ( map ) { | |
var tmp; | |
if ( state < 2 ) { | |
for ( tmp in map ) { | |
statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; | |
} | |
} else { | |
tmp = map[ jqXHR.status ]; | |
jqXHR.always( tmp ); | |
} | |
} | |
return this; | |
}; | |
// Remove hash character (#7531: and string promotion) | |
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls) | |
// We also use the url parameter if available | |
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); | |
// Extract dataTypes list | |
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); | |
// A cross-domain request is in order when we have a protocol:host:port mismatch | |
if ( s.crossDomain == null ) { | |
parts = rurl.exec( s.url.toLowerCase() ) || false; | |
s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !== | |
( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ); | |
} | |
// Convert data if not already a string | |
if ( s.data && s.processData && typeof s.data !== "string" ) { | |
s.data = jQuery.param( s.data, s.traditional ); | |
} | |
// Apply prefilters | |
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); | |
// If request was aborted inside a prefilter, stop there | |
if ( state === 2 ) { | |
return jqXHR; | |
} | |
// We can fire global events as of now if asked to | |
fireGlobals = s.global; | |
// Uppercase the type | |
s.type = s.type.toUpperCase(); | |
// Determine if request has content | |
s.hasContent = !rnoContent.test( s.type ); | |
// Watch for a new set of requests | |
if ( fireGlobals && jQuery.active++ === 0 ) { | |
jQuery.event.trigger( "ajaxStart" ); | |
} | |
// More options handling for requests with no content | |
if ( !s.hasContent ) { | |
// If data is available, append data to url | |
if ( s.data ) { | |
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; | |
// #9682: remove data so that it's not used in an eventual retry | |
delete s.data; | |
} | |
// Get ifModifiedKey before adding the anti-cache parameter | |
ifModifiedKey = s.url; | |
// Add anti-cache in url if needed | |
if ( s.cache === false ) { | |
var ts = jQuery.now(), | |
// try replacing _= if it is there | |
ret = s.url.replace( rts, "$1_=" + ts ); | |
// if nothing was replaced, add timestamp to the end | |
s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); | |
} | |
} | |
// Set the correct header, if data is being sent | |
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { | |
jqXHR.setRequestHeader( "Content-Type", s.contentType ); | |
} | |
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. | |
if ( s.ifModified ) { | |
ifModifiedKey = ifModifiedKey || s.url; | |
if ( jQuery.lastModified[ ifModifiedKey ] ) { | |
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); | |
} | |
if ( jQuery.etag[ ifModifiedKey ] ) { | |
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); | |
} | |
} | |
// Set the Accepts header for the server, depending on the dataType | |
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[ "*" ] | |
); | |
// Check for headers option | |
for ( i in s.headers ) { | |
jqXHR.setRequestHeader( i, s.headers[ i ] ); | |
} | |
// Allow custom headers/mimetypes and early abort | |
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { | |
// Abort if not done already and return | |
return jqXHR.abort(); | |
} | |
// aborting is no longer a cancellation | |
strAbort = "abort"; | |
// Install callbacks on deferreds | |
for ( i in { success: 1, error: 1, complete: 1 } ) { | |
jqXHR[ i ]( s[ i ] ); | |
} | |
// Get transport | |
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); | |
// If no transport, we auto-abort | |
if ( !transport ) { | |
done( -1, "No Transport" ); | |
} else { | |
jqXHR.readyState = 1; | |
// Send global event | |
if ( fireGlobals ) { | |
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); | |
} | |
// Timeout | |
if ( s.async && s.timeout > 0 ) { | |
timeoutTimer = setTimeout( function(){ | |
jqXHR.abort( "timeout" ); | |
}, s.timeout ); | |
} | |
try { | |
state = 1; | |
transport.send( requestHeaders, done ); | |
} catch (e) { | |
// Propagate exception as error if not done | |
if ( state < 2 ) { | |
done( -1, e ); | |
// Simply rethrow otherwise | |
} else { | |
throw e; | |
} | |
} | |
} | |
return jqXHR; | |
}, | |
// Counter for holding the number of active queries | |
active: 0, | |
// Last-Modified header cache for next request | |
lastModified: {}, | |
etag: {} | |
}); | |
/* Handles responses to an ajax request: | |
* - sets all responseXXX fields accordingly | |
* - finds the right dataType (mediates between content-type and expected dataType) | |
* - returns the corresponding response | |
*/ | |
function ajaxHandleResponses( s, jqXHR, responses ) { | |
var ct, type, finalDataType, firstDataType, | |
contents = s.contents, | |
dataTypes = s.dataTypes, | |
responseFields = s.responseFields; | |
// Fill responseXXX fields | |
for ( type in responseFields ) { | |
if ( type in responses ) { | |
jqXHR[ responseFields[type] ] = responses[ type ]; | |
} | |
} | |
// Remove auto dataType and get content-type in the process | |
while( dataTypes[ 0 ] === "*" ) { | |
dataTypes.shift(); | |
if ( ct === undefined ) { | |
ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); | |
} | |
} | |
// Check if we're dealing with a known content-type | |
if ( ct ) { | |
for ( type in contents ) { | |
if ( contents[ type ] && contents[ type ].test( ct ) ) { | |
dataTypes.unshift( type ); | |
break; | |
} | |
} | |
} | |
// Check to see if we have a response for the expected dataType | |
if ( dataTypes[ 0 ] in responses ) { | |
finalDataType = dataTypes[ 0 ]; | |
} else { | |
// Try convertible dataTypes | |
for ( type in responses ) { | |
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { | |
finalDataType = type; | |
break; | |
} | |
if ( !firstDataType ) { | |
firstDataType = type; | |
} | |
} | |
// Or just use first one | |
finalDataType = finalDataType || firstDataType; | |
} | |
// If we found a dataType | |
// We add the dataType to the list if needed | |
// and return the corresponding response | |
if ( finalDataType ) { | |
if ( finalDataType !== dataTypes[ 0 ] ) { | |
dataTypes.unshift( finalDataType ); | |
} | |
return responses[ finalDataType ]; | |
} | |
} | |
// Chain conversions given the request and the original response | |
function ajaxConvert( s, response ) { | |
var conv, conv2, current, tmp, | |
// Work with a copy of dataTypes in case we need to modify it for conversion | |
dataTypes = s.dataTypes.slice(), | |
prev = dataTypes[ 0 ], | |
converters = {}, | |
i = 0; | |
// Apply the dataFilter if provided | |
if ( s.dataFilter ) { | |
response = s.dataFilter( response, s.dataType ); | |
} | |
// Create converters map with lowercased keys | |
if ( dataTypes[ 1 ] ) { | |
for ( conv in s.converters ) { | |
converters[ conv.toLowerCase() ] = s.converters[ conv ]; | |
} | |
} | |
// Convert to each sequential dataType, tolerating list modification | |
for ( ; (current = dataTypes[++i]); ) { | |
// There's only work to do if current dataType is non-auto | |
if ( current !== "*" ) { | |
// Convert response if prev dataType is non-auto and differs from current | |
if ( prev !== "*" && prev !== current ) { | |
// Seek a direct converter | |
conv = converters[ prev + " " + current ] || converters[ "* " + current ]; | |
// If none found, seek a pair | |
if ( !conv ) { | |
for ( conv2 in converters ) { | |
// If conv2 outputs current | |
tmp = conv2.split(" "); | |
if ( tmp[ 1 ] === current ) { | |
// If prev can be converted to accepted input | |
conv = converters[ prev + " " + tmp[ 0 ] ] || | |
converters[ "* " + tmp[ 0 ] ]; | |
if ( conv ) { | |
// Condense equivalence converters | |
if ( conv === true ) { | |
conv = converters[ conv2 ]; | |
// Otherwise, insert the intermediate dataType | |
} else if ( converters[ conv2 ] !== true ) { | |
current = tmp[ 0 ]; | |
dataTypes.splice( i--, 0, current ); | |
} | |
break; | |
} | |
} | |
} | |
} | |
// Apply converter (if not an equivalence) | |
if ( conv !== true ) { | |
// Unless errors are allowed to bubble, catch and return them | |
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 }; | |
} | |
} | |
} | |
} | |
// Update prev for next iteration | |
prev = current; | |
} | |
} | |
return { state: "success", data: response }; | |
} | |
var oldCallbacks = [], | |
rquestion = /\?/, | |
rjsonp = /(=)\?(?=&|$)|\?\?/, | |
nonce = jQuery.now(); | |
// Default jsonp settings | |
jQuery.ajaxSetup({ | |
jsonp: "callback", | |
jsonpCallback: function() { | |
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); | |
this[ callback ] = true; | |
return callback; | |
} | |
}); | |
// Detect, normalize options and install callbacks for jsonp requests | |
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { | |
var callbackName, overwritten, responseContainer, | |
data = s.data, | |
url = s.url, | |
hasCallback = s.jsonp !== false, | |
replaceInUrl = hasCallback && rjsonp.test( url ), | |
replaceInData = hasCallback && !replaceInUrl && typeof data === "string" && | |
!( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && | |
rjsonp.test( data ); | |
// Handle iff the expected data type is "jsonp" or we have a parameter to set | |
if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) { | |
// Get callback name, remembering preexisting value associated with it | |
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? | |
s.jsonpCallback() : | |
s.jsonpCallback; | |
overwritten = window[ callbackName ]; | |
// Insert callback into url or form data | |
if ( replaceInUrl ) { | |
s.url = url.replace( rjsonp, "$1" + callbackName ); | |
} else if ( replaceInData ) { | |
s.data = data.replace( rjsonp, "$1" + callbackName ); | |
} else if ( hasCallback ) { | |
s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; | |
} | |
// Use data converter to retrieve json after script execution | |
s.converters["script json"] = function() { | |
if ( !responseContainer ) { | |
jQuery.error( callbackName + " was not called" ); | |
} | |
return responseContainer[ 0 ]; | |
}; | |
// force json dataType | |
s.dataTypes[ 0 ] = "json"; | |
// Install callback | |
window[ callbackName ] = function() { | |
responseContainer = arguments; | |
}; | |
// Clean-up function (fires after converters) | |
jqXHR.always(function() { | |
// Restore preexisting value | |
window[ callbackName ] = overwritten; | |
// Save back as free | |
if ( s[ callbackName ] ) { | |
// make sure that re-using the options doesn't screw things around | |
s.jsonpCallback = originalSettings.jsonpCallback; | |
// save the callback name for future use | |
oldCallbacks.push( callbackName ); | |
} | |
// Call if it was a function and we have a response | |
if ( responseContainer && jQuery.isFunction( overwritten ) ) { | |
overwritten( responseContainer[ 0 ] ); | |
} | |
responseContainer = overwritten = undefined; | |
}); | |
// Delegate to script | |
return "script"; | |
} | |
}); | |
// Install script dataType | |
jQuery.ajaxSetup({ | |
accepts: { | |
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" | |
}, | |
contents: { | |
script: /javascript|ecmascript/ | |
}, | |
converters: { | |
"text script": function( text ) { | |
jQuery.globalEval( text ); | |
return text; | |
} | |
} | |
}); | |
// Handle cache's special case and global | |
jQuery.ajaxPrefilter( "script", function( s ) { | |
if ( s.cache === undefined ) { | |
s.cache = false; | |
} | |
if ( s.crossDomain ) { | |
s.type = "GET"; | |
s.global = false; | |
} | |
}); | |
// Bind script tag hack transport | |
jQuery.ajaxTransport( "script", function(s) { | |
// This transport only deals with cross domain requests | |
if ( s.crossDomain ) { | |
var script, | |
head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; | |
return { | |
send: function( _, callback ) { | |
script = document.createElement( "script" ); | |
script.async = "async"; | |
if ( s.scriptCharset ) { | |
script.charset = s.scriptCharset; | |
} | |
script.src = s.url; | |
// Attach handlers for all browsers | |
script.onload = script.onreadystatechange = function( _, isAbort ) { | |
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { | |
// Handle memory leak in IE | |
script.onload = script.onreadystatechange = null; | |
// Remove the script | |
if ( head && script.parentNode ) { | |
head.removeChild( script ); | |
} | |
// Dereference the script | |
script = undefined; | |
// Callback if not abort | |
if ( !isAbort ) { | |
callback( 200, "success" ); | |
} | |
} | |
}; | |
// Use insertBefore instead of appendChild to circumvent an IE6 bug. | |
// This arises when a base node is used (#2709 and #4378). | |
head.insertBefore( script, head.firstChild ); | |
}, | |
abort: function() { | |
if ( script ) { | |
script.onload( 0, 1 ); | |
} | |
} | |
}; | |
} | |
}); | |
var xhrCallbacks, | |
// #5280: Internet Explorer will keep connections alive if we don't abort on unload | |
xhrOnUnloadAbort = window.ActiveXObject ? function() { | |
// Abort all pending requests | |
for ( var key in xhrCallbacks ) { | |
xhrCallbacks[ key ]( 0, 1 ); | |
} | |
} : false, | |
xhrId = 0; | |
// Functions to create xhrs | |
function createStandardXHR() { | |
try { | |
return new window.XMLHttpRequest(); | |
} catch( e ) {} | |
} | |
function createActiveXHR() { | |
try { | |
return new window.ActiveXObject( "Microsoft.XMLHTTP" ); | |
} catch( e ) {} | |
} | |
// Create the request object | |
// (This is still attached to ajaxSettings for backward compatibility) | |
jQuery.ajaxSettings.xhr = window.ActiveXObject ? | |
/* Microsoft failed to properly | |
* implement the XMLHttpRequest in IE7 (can't request local files), | |
* so we use the ActiveXObject when it is available | |
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so | |
* we need a fallback. | |
*/ | |
function() { | |
return !this.isLocal && createStandardXHR() || createActiveXHR(); | |
} : | |
// For all other browsers, use the standard XMLHttpRequest object | |
createStandardXHR; | |
// Determine support properties | |
(function( xhr ) { | |
jQuery.extend( jQuery.support, { | |
ajax: !!xhr, | |
cors: !!xhr && ( "withCredentials" in xhr ) | |
}); | |
})( jQuery.ajaxSettings.xhr() ); | |
// Create transport if the browser can provide an xhr | |
if ( jQuery.support.ajax ) { | |
jQuery.ajaxTransport(function( s ) { | |
// Cross domain only allowed if supported through XMLHttpRequest | |
if ( !s.crossDomain || jQuery.support.cors ) { | |
var callback; | |
return { | |
send: function( headers, complete ) { | |
// Get a new xhr | |
var handle, i, | |
xhr = s.xhr(); | |
// Open the socket | |
// Passing null username, generates a login popup on Opera (#2865) | |
if ( s.username ) { | |
xhr.open( s.type, s.url, s.async, s.username, s.password ); | |
} else { | |
xhr.open( s.type, s.url, s.async ); | |
} | |
// Apply custom fields if provided | |
if ( s.xhrFields ) { | |
for ( i in s.xhrFields ) { | |
xhr[ i ] = s.xhrFields[ i ]; | |
} | |
} | |
// Override mime type if needed | |
if ( s.mimeType && xhr.overrideMimeType ) { | |
xhr.overrideMimeType( s.mimeType ); | |
} | |
// X-Requested-With header | |
// For cross-domain requests, seeing as conditions for a preflight are | |
// akin to a jigsaw puzzle, we simply never set it to be sure. | |
// (it can always be set on a per-request basis or even using ajaxSetup) | |
// For same-domain requests, won't change header if already provided. | |
if ( !s.crossDomain && !headers["X-Requested-With"] ) { | |
headers[ "X-Requested-With" ] = "XMLHttpRequest"; | |
} | |
// Need an extra try/catch for cross domain requests in Firefox 3 | |
try { | |
for ( i in headers ) { | |
xhr.setRequestHeader( i, headers[ i ] ); | |
} | |
} catch( _ ) {} | |
// Do send the request | |
// This may raise an exception which is actually | |
// handled in jQuery.ajax (so no try/catch here) | |
xhr.send( ( s.hasContent && s.data ) || null ); | |
// Listener | |
callback = function( _, isAbort ) { | |
var status, | |
statusText, | |
responseHeaders, | |
responses, | |
xml; | |
// Firefox throws exceptions when accessing properties | |
// of an xhr when a network error occurred | |
// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) | |
try { | |
// Was never called and is aborted or complete | |
if ( callback && ( isAbort || xhr.readyState === 4 ) ) { | |
// Only called once | |
callback = undefined; | |
// Do not keep as active anymore | |
if ( handle ) { | |
xhr.onreadystatechange = jQuery.noop; | |
if ( xhrOnUnloadAbort ) { | |
delete xhrCallbacks[ handle ]; | |
} | |
} | |
// If it's an abort | |
if ( isAbort ) { | |
// Abort it manually if needed | |
if ( xhr.readyState !== 4 ) { | |
xhr.abort(); | |
} | |
} else { | |
status = xhr.status; | |
responseHeaders = xhr.getAllResponseHeaders(); | |
responses = {}; | |
xml = xhr.responseXML; | |
// Construct response list | |
if ( xml && xml.documentElement /* #4958 */ ) { | |
responses.xml = xml; | |
} | |
// When requesting binary data, IE6-9 will throw an exception | |
// on any attempt to access responseText (#11426) | |
try { | |
responses.text = xhr.responseText; | |
} catch( _ ) { | |
} | |
// Firefox throws an exception when accessing | |
// statusText for faulty cross-domain requests | |
try { | |
statusText = xhr.statusText; | |
} catch( e ) { | |
// We normalize with Webkit giving an empty statusText | |
statusText = ""; | |
} | |
// Filter status for non standard behaviors | |
// If the request is local and we have data: assume a success | |
// (success with no data won't get notified, that's the best we | |
// can do given current implementations) | |
if ( !status && s.isLocal && !s.crossDomain ) { | |
status = responses.text ? 200 : 404; | |
// IE - #1450: sometimes returns 1223 when it should be 204 | |
} else if ( status === 1223 ) { | |
status = 204; | |
} | |
} | |
} | |
} catch( firefoxAccessException ) { | |
if ( !isAbort ) { | |
complete( -1, firefoxAccessException ); | |
} | |
} | |
// Call complete if needed | |
if ( responses ) { | |
complete( status, statusText, responses, responseHeaders ); | |
} | |
}; | |
if ( !s.async ) { | |
// if we're in sync mode we fire the callback | |
callback(); | |
} else if ( xhr.readyState === 4 ) { | |
// (IE6 & IE7) if it's in cache and has been | |
// retrieved directly we need to fire the callback | |
setTimeout( callback, 0 ); | |
} else { | |
handle = ++xhrId; | |
if ( xhrOnUnloadAbort ) { | |
// Create the active xhrs callbacks list if needed | |
// and attach the unload handler | |
if ( !xhrCallbacks ) { | |
xhrCallbacks = {}; | |
jQuery( window ).unload( xhrOnUnloadAbort ); | |
} | |
// Add to list of active xhrs callbacks | |
xhrCallbacks[ handle ] = callback; | |
} | |
xhr.onreadystatechange = callback; | |
} | |
}, | |
abort: function() { | |
if ( callback ) { | |
callback(0,1); | |
} | |
} | |
}; | |
} | |
}); | |
} | |
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" ); | |
// We need to compute starting value | |
if ( unit !== "px" && start ) { | |
// Iteratively approximate from a nonzero starting point | |
// Prefer the current property, because this process will be trivial if it uses the same units | |
// Fallback to end or a simple constant | |
start = jQuery.css( tween.elem, prop, true ) || end || 1; | |
do { | |
// If previous iteration zeroed out, double until we get *something* | |
// Use a string for doubling factor so we don't accidentally see scale as unchanged below | |
scale = scale || ".5"; | |
// Adjust and apply | |
start = start / scale; | |
jQuery.style( tween.elem, prop, start + unit ); | |
// Update scale, tolerating zero or NaN from tween.cur() | |
// And breaking the loop if scale is unchanged or perfect, or if we've just had enough | |
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); | |
} | |
tween.unit = unit; | |
tween.start = start; | |
// If a +=/-= token was provided, we're doing a relative animation | |
tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end; | |
} | |
return tween; | |
}] | |
}; | |
// Animations created synchronously will run synchronously | |
function createFxNow() { | |
setTimeout(function() { | |
fxNow = undefined; | |
}, 0 ); | |
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 ) ) { | |
// we're done with this property | |
return; | |
} | |
} | |
}); | |
} | |
function Animation( elem, properties, options ) { | |
var result, | |
index = 0, | |
tweenerIndex = 0, | |
length = animationPrefilters.length, | |
deferred = jQuery.Deferred().always( function() { | |
// don't match elem in the :animated selector | |
delete tick.elem; | |
}), | |
tick = function() { | |
var currentTime = fxNow || createFxNow(), | |
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), | |
percent = 1 - ( remaining / animation.duration || 0 ), | |
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, easing ) { | |
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, | |
// if we are going to the end, we want to run all the tweens | |
// otherwise we skip this part | |
length = gotoEnd ? animation.tweens.length : 0; | |
for ( ; index < length ; index++ ) { | |
animation.tweens[ index ].run( 1 ); | |
} | |
// resolve when we played the last frame | |
// otherwise, reject | |
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, { | |
anim: animation, | |
queue: animation.opts.queue, | |
elem: elem | |
}) | |
); | |
// attach callbacks from options | |
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; | |
// camelCase, specialEasing and expand cssHook pass | |
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 ]; | |
// not quite $.extend, this wont overwrite keys already present. | |
// also - reusing 'index' from above because we have the correct "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, tween, hooks, oldfire, | |
anim = this, | |
style = elem.style, | |
orig = {}, | |
handled = [], | |
hidden = elem.nodeType && isHidden( elem ); | |
// handle queue: false promises | |
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() { | |
// doing this makes sure that the complete handler will be called | |
// before this completes | |
anim.always(function() { | |
hooks.unqueued--; | |
if ( !jQuery.queue( elem, "fx" ).length ) { | |
hooks.empty.fire(); | |
} | |
}); | |
}); | |
} | |
// height/width overflow pass | |
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { | |
// Make sure that nothing sneaks out | |
// Record all 3 overflow attributes because IE does not | |
// change the overflow attribute when overflowX and | |
// overflowY are set to the same value | |
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; | |
// Set display property to inline-block for height/width | |
// animations on inline elements that are having width/height animated | |
if ( jQuery.css( elem, "display" ) === "inline" && | |
jQuery.css( elem, "float" ) === "none" ) { | |
// inline-level elements accept inline-block; | |
// block-level elements need to be inline with layout | |
if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) { | |
style.display = "inline-block"; | |
} else { | |
style.zoom = 1; | |
} | |
} | |
} | |
if ( opts.overflow ) { | |
style.overflow = "hidden"; | |
if ( !jQuery.support.shrinkWrapBlocks ) { | |
anim.done(function() { | |
style.overflow = opts.overflow[ 0 ]; | |
style.overflowX = opts.overflow[ 1 ]; | |
style.overflowY = opts.overflow[ 2 ]; | |
}); | |
} | |
} | |
// show/hide pass | |
for ( index in props ) { | |
value = props[ index ]; | |
if ( rfxtypes.exec( value ) ) { | |
delete props[ index ]; | |
if ( value === ( hidden ? "hide" : "show" ) ) { | |
continue; | |
} | |
handled.push( index ); | |
} | |
} | |
length = handled.length; | |
if ( length ) { | |
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} ); | |
if ( hidden ) { | |
jQuery( elem ).show(); | |
} else { | |
anim.done(function() { | |
jQuery( elem ).hide(); | |
}); | |
} | |
anim.done(function() { | |
var prop; | |
jQuery.removeData( elem, "fxshow", true ); | |
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 ]; | |
} | |
// passing any value as a 4th parameter to .css will automatically | |
// attempt a parseFloat and fallback to a string if the parse fails | |
// so, simple values such as "10px" are parsed to Float. | |
// complex values such as "rotate(1rad)" are returned as is. | |
result = jQuery.css( tween.elem, tween.prop, false, "" ); | |
// Empty strings, null, undefined and "auto" are converted to 0. | |
return !result || result === "auto" ? 0 : result; | |
}, | |
set: function( tween ) { | |
// use step hook for back compat - use cssHook if its there - use .style if its | |
// available and use plain properties where available | |
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; | |
} | |
} | |
} | |
}; | |
// Remove in 2.0 - this supports IE8's panic based approach | |
// to setting things on disconnected nodes | |
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" || | |
// special check for .toggle( handler, handler, ... ) | |
( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ? | |
cssFn.apply( this, arguments ) : | |
this.animate( genFx( name, true ), speed, easing, callback ); | |
}; | |
}); | |
jQuery.fn.extend({ | |
fadeTo: function( speed, to, easing, callback ) { | |
// show any hidden elements after setting opacity to 0 | |
return this.filter( isHidden ).css( "opacity", 0 ).show() | |
// animate to the value specified | |
.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() { | |
// Operate on a copy of prop so per-property easing won't be lost | |
var anim = Animation( this, jQuery.extend( {}, prop ), optall ); | |
// Empty animations resolve immediately | |
if ( empty ) { | |
anim.stop( true ); | |
} | |
}; | |
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 = jQuery._data( 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 ); | |
} | |
} | |
// start the next in the queue if the last step wasn't forced | |
// timers currently will call their complete callbacks, which will dequeue | |
// but only if they were gotoEnd | |
if ( dequeue || !gotoEnd ) { | |
jQuery.dequeue( this, type ); | |
} | |
}); | |
} | |
}); | |
// Generate parameters to create a standard animation | |
function genFx( type, includeWidth ) { | |
var which, | |
attrs = { height: type }, | |
i = 0; | |
// if we include width, step value is 1 to do all cssExpand values, | |
// if we don't include width, step value is 2 to skip over Left and Right | |
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; | |
} | |
// Generate shortcuts for custom animations | |
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; | |
// normalize opt.queue - true/undefined/null -> "fx" | |
if ( opt.queue == null || opt.queue === true ) { | |
opt.queue = "fx"; | |
} | |
// Queueing | |
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; | |
for ( ; i < timers.length; i++ ) { | |
timer = timers[ i ]; | |
// Checks the timer has not already been removed | |
if ( !timer() && timers[ i ] === timer ) { | |
timers.splice( i--, 1 ); | |
} | |
} | |
if ( !timers.length ) { | |
jQuery.fx.stop(); | |
} | |
}; | |
jQuery.fx.timer = function( timer ) { | |
if ( timer() && jQuery.timers.push( timer ) && !timerId ) { | |
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); | |
} | |
}; | |
jQuery.fx.interval = 13; | |
jQuery.fx.stop = function() { | |
clearInterval( timerId ); | |
timerId = null; | |
}; | |
jQuery.fx.speeds = { | |
slow: 600, | |
fast: 200, | |
// Default speed | |
_default: 400 | |
}; | |
// Back Compat <1.8 extension point | |
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; | |
}; | |
} | |
var rroot = /^(?:body|html)$/i; | |
jQuery.fn.offset = function( options ) { | |
if ( arguments.length ) { | |
return options === undefined ? | |
this : | |
this.each(function( i ) { | |
jQuery.offset.setOffset( this, options, i ); | |
}); | |
} | |
var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, | |
box = { top: 0, left: 0 }, | |
elem = this[ 0 ], | |
doc = elem && elem.ownerDocument; | |
if ( !doc ) { | |
return; | |
} | |
if ( (body = doc.body) === elem ) { | |
return jQuery.offset.bodyOffset( elem ); | |
} | |
docElem = doc.documentElement; | |
// Make sure it's not a disconnected DOM node | |
if ( !jQuery.contains( docElem, elem ) ) { | |
return box; | |
} | |
// If we don't have gBCR, just use 0,0 rather than error | |
// BlackBerry 5, iOS 3 (original iPhone) | |
if ( typeof elem.getBoundingClientRect !== "undefined" ) { | |
box = elem.getBoundingClientRect(); | |
} | |
win = getWindow( doc ); | |
clientTop = docElem.clientTop || body.clientTop || 0; | |
clientLeft = docElem.clientLeft || body.clientLeft || 0; | |
scrollTop = win.pageYOffset || docElem.scrollTop; | |
scrollLeft = win.pageXOffset || docElem.scrollLeft; | |
return { | |
top: box.top + scrollTop - clientTop, | |
left: box.left + scrollLeft - clientLeft | |
}; | |
}; | |
jQuery.offset = { | |
bodyOffset: function( body ) { | |
var top = body.offsetTop, | |
left = body.offsetLeft; | |
if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { | |
top += parseFloat( jQuery.css(body, "marginTop") ) || 0; | |
left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; | |
} | |
return { top: top, left: left }; | |
}, | |
setOffset: function( elem, options, i ) { | |
var position = jQuery.css( elem, "position" ); | |
// set position first, in-case top/left are set even on static elem | |
if ( position === "static" ) { | |
elem.style.position = "relative"; | |
} | |
var curElem = jQuery( elem ), | |
curOffset = curElem.offset(), | |
curCSSTop = jQuery.css( elem, "top" ), | |
curCSSLeft = jQuery.css( elem, "left" ), | |
calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, | |
props = {}, curPosition = {}, curTop, curLeft; | |
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed | |
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 elem = this[0], | |
// Get *real* offsetParent | |
offsetParent = this.offsetParent(), | |
// Get correct offsets | |
offset = this.offset(), | |
parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); | |
// Subtract element margins | |
// note: when an element has margin: auto the offsetLeft and marginLeft | |
// are the same in Safari causing offset.left to incorrectly be 0 | |
offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; | |
offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; | |
// Add offsetParent borders | |
parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; | |
parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; | |
// Subtract the two offsets | |
return { | |
top: offset.top - parentOffset.top, | |
left: offset.left - parentOffset.left | |
}; | |
}, | |
offsetParent: function() { | |
return this.map(function() { | |
var offsetParent = this.offsetParent || document.body; | |
while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { | |
offsetParent = offsetParent.offsetParent; | |
} | |
return offsetParent || document.body; | |
}); | |
} | |
}); | |
// Create scrollLeft and scrollTop methods | |
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { | |
var top = /Y/.test( prop ); | |
jQuery.fn[ method ] = function( val ) { | |
return jQuery.access( this, function( elem, method, val ) { | |
var win = getWindow( elem ); | |
if ( val === undefined ) { | |
return win ? (prop in win) ? win[ prop ] : | |
win.document.documentElement[ method ] : | |
elem[ method ]; | |
} | |
if ( win ) { | |
win.scrollTo( | |
!top ? val : jQuery( win ).scrollLeft(), | |
top ? val : jQuery( win ).scrollTop() | |
); | |
} else { | |
elem[ method ] = val; | |
} | |
}, method, val, arguments.length, null ); | |
}; | |
}); | |
function getWindow( elem ) { | |
return jQuery.isWindow( elem ) ? | |
elem : | |
elem.nodeType === 9 ? | |
elem.defaultView || elem.parentWindow : | |
false; | |
} | |
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods | |
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { | |
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { | |
// margin is only for outerHeight, outerWidth | |
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 ) ) { | |
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there | |
// isn't a whole lot we can do. See pull request at this URL for discussion: | |
// https://github.com/jquery/jquery/pull/764 | |
return elem.document.documentElement[ "client" + name ]; | |
} | |
// Get document width or height | |
if ( elem.nodeType === 9 ) { | |
doc = elem.documentElement; | |
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest | |
// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. | |
return Math.max( | |
elem.body[ "scroll" + name ], doc[ "scroll" + name ], | |
elem.body[ "offset" + name ], doc[ "offset" + name ], | |
doc[ "client" + name ] | |
); | |
} | |
return value === undefined ? | |
// Get width or height on the element, requesting but not forcing parseFloat | |
jQuery.css( elem, type, value, extra ) : | |
// Set width or height on the element | |
jQuery.style( elem, type, value, extra ); | |
}, type, chainable ? margin : undefined, chainable, null ); | |
}; | |
}); | |
}); | |
// Expose jQuery to the global object | |
window.jQuery = window.$ = jQuery; | |
// Expose jQuery as an AMD module, but only for AMD loaders that | |
// understand the issues with loading multiple versions of jQuery | |
// in a page that all might call define(). The loader will indicate | |
// they have special allowances for multiple jQuery versions by | |
// specifying define.amd.jQuery = true. Register as a named module, | |
// since jQuery can be concatenated with other files that may use define, | |
// but not use a proper concatenation script that understands anonymous | |
// AMD modules. A named AMD is safest and most robust way to register. | |
// Lowercase jquery is used because AMD module names are derived from | |
// file names, and jQuery is normally delivered in a lowercase file name. | |
// Do this after creating the global so that if an AMD module wants to call | |
// noConflict to hide this version of jQuery, it will work. | |
if ( typeof define === "function" && define.amd && define.amd.jQuery ) { | |
define( "jquery", [], function () { return jQuery; } ); | |
} | |
})( window ); |
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
/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.core.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.24",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;return a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a("<a>").outerWidth(1).jquery||a.each(["Width","Height"],function(c,d){function h(b,c,d,f){return a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return typeof b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:a.expr.createPseudo?a.expr.createPseudo(function(b){return function(c){return!!a.data(c,b)}}):function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.curCSS||(a.curCSS=a.css),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var e=0;e<d.length;e++)a.options[d[e][0]]&&d[e][1].apply(a.element,c)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var d=c&&c==="left"?"scrollLeft":"scrollTop",e=!1;return b[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return a>b&&a<b+c},isOver:function(b,c,d,e,f,g){return a.ui.isOverAxis(b,d,f)&&a.ui.isOverAxis(c,e,g)}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.widget.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var d=0,e;(e=b[d])!=null;d++)try{a(e).triggerHandler("remove")}catch(f){}c(b)}}else{var d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){return c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}}),d.call(a(this),b,c)})}}a.widget=function(b,c,d){var e=b.split(".")[0],f;b=b.split(".")[1],f=e+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][f]=function(c){return!!a.data(c,b)},a[e]=a[e]||{},a[e][b]=function(a,b){arguments.length&&this._createWidget(a,b)};var g=new c;g.options=a.extend(!0,{},g.options),a[e][b].prototype=a.extend(!0,g,{namespace:e,widgetName:b,widgetEventPrefix:a[e][b].prototype.widgetEventPrefix||b,widgetBaseClass:f},d),a.widget.bridge(b,a[e][b])},a.widget.bridge=function(c,d){a.fn[c]=function(e){var f=typeof e=="string",g=Array.prototype.slice.call(arguments,1),h=this;return e=!f&&g.length?a.extend.apply(null,[!0,e].concat(g)):e,f&&e.charAt(0)==="_"?h:(f?this.each(function(){var d=a.data(this,c),f=d&&a.isFunction(d[e])?d[e].apply(d,g):d;if(f!==d&&f!==b)return h=f,!1}):this.each(function(){var b=a.data(this,c);b?b.option(e||{})._init():a.data(this,c,new d(e,this))}),h)}},a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)},a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this),this.element=a(c),this.options=a.extend(!0,{},this.options,this._getCreateOptions(),b);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(c,d){var e=c;if(arguments.length===0)return a.extend({},this.options);if(typeof c=="string"){if(d===b)return this.options[c];e={},e[c]=d}return this._setOptions(e),this},_setOptions:function(b){var c=this;return a.each(b,function(a,b){c._setOption(a,b)}),this},_setOption:function(a,b){return this.options[a]=b,a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",b),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(b,c,d){var e,f,g=this.options[b];d=d||{},c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),c.target=this.element[0],f=c.originalEvent;if(f)for(e in f)e in c||(c[e]=f[e]);return this.element.trigger(c,d),!(a.isFunction(g)&&g.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.mouse.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){var c=!1;a(document).mouseup(function(a){c=!1}),a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(a){return b._mouseDown(a)}).bind("click."+this.widgetName,function(c){if(!0===a.data(c.target,b.widgetName+".preventClickEvent"))return a.removeData(c.target,b.widgetName+".preventClickEvent"),c.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(b){if(c)return;this._mouseStarted&&this._mouseUp(b),this._mouseDownEvent=b;var d=this,e=b.which==1,f=typeof this.options.cancel=="string"&&b.target.nodeName?a(b.target).closest(this.options.cancel).length:!1;if(!e||f||!this._mouseCapture(b))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){d.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=this._mouseStart(b)!==!1;if(!this._mouseStarted)return b.preventDefault(),!0}return!0===a.data(b.target,this.widgetName+".preventClickEvent")&&a.removeData(b.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(a){return d._mouseMove(a)},this._mouseUpDelegate=function(a){return d._mouseUp(a)},a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),b.preventDefault(),c=!0,!0},_mouseMove:function(b){return!a.browser.msie||document.documentMode>=9||!!b.button?this._mouseStarted?(this._mouseDrag(b),b.preventDefault()):(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b)),!this._mouseStarted):this._mouseUp(b)},_mouseUp:function(b){return a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b)),!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.position.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return g.apply(this,arguments);b=a.extend({},b);var h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" "):[0,0],l,m,n;return i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1],this.each(function(){var c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]===e)return;var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0},top:function(b,c){if(c.at[1]===e)return;var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];return!c||!c.ownerDocument?null:b?a.isFunction(b)?this.each(function(c){a(this).offset(b.call(this,c,a(this).offset()))}):this.each(function(){a.offset.setOffset(this,b)}):h.call(this)}),a.curCSS||(a.curCSS=a.css),function(){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&a.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var j in g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",h=a(c).offset(function(a,b){return b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.draggable.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},destroy:function(){if(!this.element.data("draggable"))return;return this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy(),this},_mouseCapture:function(b){var c=this.options;return this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(b),this.handle?(c.iframeFix&&a(c.iframeFix===!0?"iframe":c.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(a(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(b){var c=this.options;return this.helper=this._createHelper(b),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),a.ui.ddmanager&&(a.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt),c.containment&&this._setContainment(),this._trigger("start",b)===!1?(this._clear(),!1):(this._cacheHelperProportions(),a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this._mouseDrag(b,!0),a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,b),!0)},_mouseDrag:function(b,c){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute");if(!c){var d=this._uiHash();if(this._trigger("drag",b,d)===!1)return this._mouseUp({}),!1;this.position=d.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),!1},_mouseStop:function(b){var c=!1;a.ui.ddmanager&&!this.options.dropBehaviour&&(c=a.ui.ddmanager.drop(this,b)),this.dropped&&(c=this.dropped,this.dropped=!1);var d=this.element[0],e=!1;while(d&&(d=d.parentNode))d==document&&(e=!0);if(!e&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!c||this.options.revert=="valid"&&c||this.options.revert===!0||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,c)){var f=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){f._trigger("stop",b)!==!1&&f._clear()})}else this._trigger("stop",b)!==!1&&this._clear();return!1},_mouseUp:function(b){return a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,b),a.ui.mouse.prototype._mouseUp.call(this,b)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(b){var c=!this.options.handle||!a(this.options.handle,this.element).length?!0:!1;return a(this.options.handle,this.element).find("*").andSelf().each(function(){this==b.target&&(c=!0)}),c},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b])):c.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return d.parents("body").length||d.appendTo(c.appendTo=="parent"?this.element[0].parentNode:c.appendTo),d[0]!=this.element[0]&&!/(fixed|absolute)/.test(d.css("position"))&&d.css("position","absolute"),d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[b.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,b.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(b.containment=="document"?0:a(window).scrollLeft())+a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b.containment=="document"?0:a(window).scrollTop())+(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)&&b.containment.constructor!=Array){var c=a(b.containment),d=c[0];if(!d)return;var e=c.offset(),f=a(d).css("overflow")!="hidden";this.containment=[(parseInt(a(d).css("borderLeftWidth"),10)||0)+(parseInt(a(d).css("paddingLeft"),10)||0),(parseInt(a(d).css("borderTopWidth"),10)||0)+(parseInt(a(d).css("paddingTop"),10)||0),(f?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(a(d).css("borderLeftWidth"),10)||0)-(parseInt(a(d).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(f?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(a(d).css("borderTopWidth"),10)||0)-(parseInt(a(d).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=c}else b.containment.constructor==Array&&(this.containment=b.containment)},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName),f=b.pageX,g=b.pageY;if(this.originalPosition){var h;if(this.containment){if(this.relative_container){var i=this.relative_container.offset();h=[this.containment[0]+i.left,this.containment[1]+i.top,this.containment[2]+i.left,this.containment[3]+i.top]}else h=this.containment;b.pageX-this.offset.click.left<h[0]&&(f=h[0]+this.offset.click.left),b.pageY-this.offset.click.top<h[1]&&(g=h[1]+this.offset.click.top),b.pageX-this.offset.click.left>h[2]&&(f=h[2]+this.offset.click.left),b.pageY-this.offset.click.top>h[3]&&(g=h[3]+this.offset.click.top)}if(c.grid){var j=c.grid[1]?this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1]:this.originalPageY;g=h?j-this.offset.click.top<h[1]||j-this.offset.click.top>h[3]?j-this.offset.click.top<h[1]?j+c.grid[1]:j-c.grid[1]:j:j;var k=c.grid[0]?this.originalPageX+Math.round((f-this.originalPageX)/c.grid[0])*c.grid[0]:this.originalPageX;f=h?k-this.offset.click.left<h[0]||k-this.offset.click.left>h[2]?k-this.offset.click.left<h[0]?k+c.grid[0]:k-c.grid[0]:k:k}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:d.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(b,c,d){return d=d||this._uiHash(),a.ui.plugin.call(this,b,[c,d]),b=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),a.Widget.prototype._trigger.call(this,b,c,d)},plugins:{},_uiHash:function(a){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),a.extend(a.ui.draggable,{version:"1.8.24"}),a.ui.plugin.add("draggable","connectToSortable",{start:function(b,c){var d=a(this).data("draggable"),e=d.options,f=a.extend({},c,{item:d.element});d.sortables=[],a(e.connectToSortable).each(function(){var c=a.data(this,"sortable");c&&!c.options.disabled&&(d.sortables.push({instance:c,shouldRevert:c.options.revert}),c.refreshPositions(),c._trigger("activate",b,f))})},stop:function(b,c){var d=a(this).data("draggable"),e=a.extend({},c,{item:d.element});a.each(d.sortables,function(){this.instance.isOver?(this.instance.isOver=0,d.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(b),this.instance.options.helper=this.instance.options._helper,d.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",b,e))})},drag:function(b,c){var d=a(this).data("draggable"),e=this,f=function(b){var c=this.offset.click.top,d=this.offset.click.left,e=this.positionAbs.top,f=this.positionAbs.left,g=b.height,h=b.width,i=b.top,j=b.left;return a.ui.isOver(e+c,f+d,i,j,g,h)};a.each(d.sortables,function(f){this.instance.positionAbs=d.positionAbs,this.instance.helperProportions=d.helperProportions,this.instance.offset.click=d.offset.click,this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(e).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return c.helper[0]},b.target=this.instance.currentItem[0],this.instance._mouseCapture(b,!0),this.instance._mouseStart(b,!0,!0),this.instance.offset.click.top=d.offset.click.top,this.instance.offset.click.left=d.offset.click.left,this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top,d._trigger("toSortable",b),d.dropped=this.instance.element,d.currentItem=d.element,this.instance.fromOutside=d),this.instance.currentItem&&this.instance._mouseDrag(b)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",b,this.instance._uiHash(this.instance)),this.instance._mouseStop(b,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),d._trigger("fromSortable",b),d.dropped=!1)})}}),a.ui.plugin.add("draggable","cursor",{start:function(b,c){var d=a("body"),e=a(this).data("draggable").options;d.css("cursor")&&(e._cursor=d.css("cursor")),d.css("cursor",e.cursor)},stop:function(b,c){var d=a(this).data("draggable").options;d._cursor&&a("body").css("cursor",d._cursor)}}),a.ui.plugin.add("draggable","opacity",{start:function(b,c){var d=a(c.helper),e=a(this).data("draggable").options;d.css("opacity")&&(e._opacity=d.css("opacity")),d.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("draggable").options;d._opacity&&a(c.helper).css("opacity",d._opacity)}}),a.ui.plugin.add("draggable","scroll",{start:function(b,c){var d=a(this).data("draggable");d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"&&(d.overflowOffset=d.scrollParent.offset())},drag:function(b,c){var d=a(this).data("draggable"),e=d.options,f=!1;if(d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"){if(!e.axis||e.axis!="x")d.overflowOffset.top+d.scrollParent[0].offsetHeight-b.pageY<e.scrollSensitivity?d.scrollParent[0].scrollTop=f=d.scrollParent[0].scrollTop+e.scrollSpeed:b.pageY-d.overflowOffset.top<e.scrollSensitivity&&(d.scrollParent[0].scrollTop=f=d.scrollParent[0].scrollTop-e.scrollSpeed);if(!e.axis||e.axis!="y")d.overflowOffset.left+d.scrollParent[0].offsetWidth-b.pageX<e.scrollSensitivity?d.scrollParent[0].scrollLeft=f=d.scrollParent[0].scrollLeft+e.scrollSpeed:b.pageX-d.overflowOffset.left<e.scrollSensitivity&&(d.scrollParent[0].scrollLeft=f=d.scrollParent[0].scrollLeft-e.scrollSpeed)}else{if(!e.axis||e.axis!="x")b.pageY-a(document).scrollTop()<e.scrollSensitivity?f=a(document).scrollTop(a(document).scrollTop()-e.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<e.scrollSensitivity&&(f=a(document).scrollTop(a(document).scrollTop()+e.scrollSpeed));if(!e.axis||e.axis!="y")b.pageX-a(document).scrollLeft()<e.scrollSensitivity?f=a(document).scrollLeft(a(document).scrollLeft()-e.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<e.scrollSensitivity&&(f=a(document).scrollLeft(a(document).scrollLeft()+e.scrollSpeed))}f!==!1&&a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(d,b)}}),a.ui.plugin.add("draggable","snap",{start:function(b,c){var d=a(this).data("draggable"),e=d.options;d.snapElements=[],a(e.snap.constructor!=String?e.snap.items||":data(draggable)":e.snap).each(function(){var b=a(this),c=b.offset();this!=d.element[0]&&d.snapElements.push({item:this,width:b.outerWidth(),height:b.outerHeight(),top:c.top,left:c.left})})},drag:function(b,c){var d=a(this).data("draggable"),e=d.options,f=e.snapTolerance,g=c.offset.left,h=g+d.helperProportions.width,i=c.offset.top,j=i+d.helperProportions.height;for(var k=d.snapElements.length-1;k>=0;k--){var l=d.snapElements[k].left,m=l+d.snapElements[k].width,n=d.snapElements[k].top,o=n+d.snapElements[k].height;if(!(l-f<g&&g<m+f&&n-f<i&&i<o+f||l-f<g&&g<m+f&&n-f<j&&j<o+f||l-f<h&&h<m+f&&n-f<i&&i<o+f||l-f<h&&h<m+f&&n-f<j&&j<o+f)){d.snapElements[k].snapping&&d.options.snap.release&&d.options.snap.release.call(d.element,b,a.extend(d._uiHash(),{snapItem:d.snapElements[k].item})),d.snapElements[k].snapping=!1;continue}if(e.snapMode!="inner"){var p=Math.abs(n-j)<=f,q=Math.abs(o-i)<=f,r=Math.abs(l-h)<=f,s=Math.abs(m-g)<=f;p&&(c.position.top=d._convertPositionTo("relative",{top:n-d.helperProportions.height,left:0}).top-d.margins.top),q&&(c.position.top=d._convertPositionTo("relative",{top:o,left:0}).top-d.margins.top),r&&(c.position.left=d._convertPositionTo("relative",{top:0,left:l-d.helperProportions.width}).left-d.margins.left),s&&(c.position.left=d._convertPositionTo("relative",{top:0,left:m}).left-d.margins.left)}var t=p||q||r||s;if(e.snapMode!="outer"){var p=Math.abs(n-i)<=f,q=Math.abs(o-j)<=f,r=Math.abs(l-g)<=f,s=Math.abs(m-h)<=f;p&&(c.position.top=d._convertPositionTo("relative",{top:n,left:0}).top-d.margins.top),q&&(c.position.top=d._convertPositionTo("relative",{top:o-d.helperProportions.height,left:0}).top-d.margins.top),r&&(c.position.left=d._convertPositionTo("relative",{top:0,left:l}).left-d.margins.left),s&&(c.position.left=d._convertPositionTo("relative",{top:0,left:m-d.helperProportions.width}).left-d.margins.left)}!d.snapElements[k].snapping&&(p||q||r||s||t)&&d.options.snap.snap&&d.options.snap.snap.call(d.element,b,a.extend(d._uiHash(),{snapItem:d.snapElements[k].item})),d.snapElements[k].snapping=p||q||r||s||t}}}),a.ui.plugin.add("draggable","stack",{start:function(b,c){var d=a(this).data("draggable").options,e=a.makeArray(a(d.stack)).sort(function(b,c){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(c).css("zIndex"),10)||0)});if(!e.length)return;var f=parseInt(e[0].style.zIndex)||0;a(e).each(function(a){this.style.zIndex=f+a}),this[0].style.zIndex=f+e.length}}),a.ui.plugin.add("draggable","zIndex",{start:function(b,c){var d=a(c.helper),e=a(this).data("draggable").options;d.css("zIndex")&&(e._zIndex=d.css("zIndex")),d.css("zIndex",e.zIndex)},stop:function(b,c){var d=a(this).data("draggable").options;d._zIndex&&a(c.helper).css("zIndex",d._zIndex)}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.droppable.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var b=this.options,c=b.accept;this.isover=0,this.isout=1,this.accept=a.isFunction(c)?c:function(a){return a.is(c)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},a.ui.ddmanager.droppables[b.scope]=a.ui.ddmanager.droppables[b.scope]||[],a.ui.ddmanager.droppables[b.scope].push(this),b.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){var b=a.ui.ddmanager.droppables[this.options.scope];for(var c=0;c<b.length;c++)b[c]==this&&b.splice(c,1);return this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable"),this},_setOption:function(b,c){b=="accept"&&(this.accept=a.isFunction(c)?c:function(a){return a.is(c)}),a.Widget.prototype._setOption.apply(this,arguments)},_activate:function(b){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),c&&this._trigger("activate",b,this.ui(c))},_deactivate:function(b){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),c&&this._trigger("deactivate",b,this.ui(c))},_over:function(b){var c=a.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return;this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",b,this.ui(c)))},_out:function(b){var c=a.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return;this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",b,this.ui(c)))},_drop:function(b,c){var d=c||a.ui.ddmanager.current;if(!d||(d.currentItem||d.element)[0]==this.element[0])return!1;var e=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var b=a.data(this,"droppable");if(b.options.greedy&&!b.options.disabled&&b.options.scope==d.options.scope&&b.accept.call(b.element[0],d.currentItem||d.element)&&a.ui.intersect(d,a.extend(b,{offset:b.element.offset()}),b.options.tolerance))return e=!0,!1}),e?!1:this.accept.call(this.element[0],d.currentItem||d.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",b,this.ui(d)),this.element):!1},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}}),a.extend(a.ui.droppable,{version:"1.8.24"}),a.ui.intersect=function(b,c,d){if(!c.offset)return!1;var e=(b.positionAbs||b.position.absolute).left,f=e+b.helperProportions.width,g=(b.positionAbs||b.position.absolute).top,h=g+b.helperProportions.height,i=c.offset.left,j=i+c.proportions.width,k=c.offset.top,l=k+c.proportions.height;switch(d){case"fit":return i<=e&&f<=j&&k<=g&&h<=l;case"intersect":return i<e+b.helperProportions.width/2&&f-b.helperProportions.width/2<j&&k<g+b.helperProportions.height/2&&h-b.helperProportions.height/2<l;case"pointer":var m=(b.positionAbs||b.position.absolute).left+(b.clickOffset||b.offset.click).left,n=(b.positionAbs||b.position.absolute).top+(b.clickOffset||b.offset.click).top,o=a.ui.isOver(n,m,k,i,c.proportions.height,c.proportions.width);return o;case"touch":return(g>=k&&g<=l||h>=k&&h<=l||g<k&&h>l)&&(e>=i&&e<=j||f>=i&&f<=j||e<i&&f>j);default:return!1}},a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(b,c){var d=a.ui.ddmanager.droppables[b.options.scope]||[],e=c?c.type:null,f=(b.currentItem||b.element).find(":data(droppable)").andSelf();g:for(var h=0;h<d.length;h++){if(d[h].options.disabled||b&&!d[h].accept.call(d[h].element[0],b.currentItem||b.element))continue;for(var i=0;i<f.length;i++)if(f[i]==d[h].element[0]){d[h].proportions.height=0;continue g}d[h].visible=d[h].element.css("display")!="none";if(!d[h].visible)continue;e=="mousedown"&&d[h]._activate.call(d[h],c),d[h].offset=d[h].element.offset(),d[h].proportions={width:d[h].element[0].offsetWidth,height:d[h].element[0].offsetHeight}}},drop:function(b,c){var d=!1;return a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&a.ui.intersect(b,this,this.options.tolerance)&&(d=this._drop.call(this,c)||d),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],b.currentItem||b.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,c))}),d},dragStart:function(b,c){b.element.parents(":not(body,html)").bind("scroll.droppable",function(){b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)})},drag:function(b,c){b.options.refreshPositions&&a.ui.ddmanager.prepareOffsets(b,c),a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var d=a.ui.intersect(b,this,this.options.tolerance),e=!d&&this.isover==1?"isout":d&&this.isover==0?"isover":null;if(!e)return;var f;if(this.options.greedy){var g=this.options.scope,h=this.element.parents(":data(droppable)").filter(function(){return a.data(this,"droppable").options.scope===g});h.length&&(f=a.data(h[0],"droppable"),f.greedyChild=e=="isover"?1:0)}f&&e=="isover"&&(f.isover=0,f.isout=1,f._out.call(f,c)),this[e]=1,this[e=="isout"?"isover":"isout"]=0,this[e=="isover"?"_over":"_out"].call(this,c),f&&e=="isout"&&(f.isout=0,f.isover=1,f._over.call(f,c))})},dragStop:function(b,c){b.element.parents(":not(body,html)").unbind("scroll.droppable"),b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)}}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.resizable.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.resizable",a.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var b=this,c=this.options;this.element.addClass("ui-resizable"),a.extend(this,{_aspectRatio:!!c.aspectRatio,aspectRatio:c.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:c.helper||c.ghost||c.animate?c.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(a('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=c.handles||(a(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var d=this.handles.split(",");this.handles={};for(var e=0;e<d.length;e++){var f=a.trim(d[e]),g="ui-resizable-"+f,h=a('<div class="ui-resizable-handle '+g+'"></div>');h.css({zIndex:c.zIndex}),"se"==f&&h.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[f]=".ui-resizable-"+f,this.element.append(h)}}this._renderAxis=function(b){b=b||this.element;for(var c in this.handles){this.handles[c].constructor==String&&(this.handles[c]=a(this.handles[c],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var d=a(this.handles[c],this.element),e=0;e=/sw|ne|nw|se|n|s/.test(c)?d.outerHeight():d.outerWidth();var f=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join("");b.css(f,e),this._proportionallyResize()}if(!a(this.handles[c]).length)continue}},this._renderAxis(this.element),this._handles=a(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!b.resizing){if(this.className)var a=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=a&&a[1]?a[1]:"se"}}),c.autoHide&&(this._handles.hide(),a(this.element).addClass("ui-resizable-autohide").hover(function(){if(c.disabled)return;a(this).removeClass("ui-resizable-autohide"),b._handles.show()},function(){if(c.disabled)return;b.resizing||(a(this).addClass("ui-resizable-autohide"),b._handles.hide())})),this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(b){a(b).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var c=this.element;c.after(this.originalElement.css({position:c.css("position"),width:c.outerWidth(),height:c.outerHeight(),top:c.css("top"),left:c.css("left")})).remove()}return this.originalElement.css("resize",this.originalResizeStyle),b(this.originalElement),this},_mouseCapture:function(b){var c=!1;for(var d in this.handles)a(this.handles[d])[0]==b.target&&(c=!0);return!this.options.disabled&&c},_mouseStart:function(b){var d=this.options,e=this.element.position(),f=this.element;this.resizing=!0,this.documentScroll={top:a(document).scrollTop(),left:a(document).scrollLeft()},(f.is(".ui-draggable")||/absolute/.test(f.css("position")))&&f.css({position:"absolute",top:e.top,left:e.left}),this._renderProxy();var g=c(this.helper.css("left")),h=c(this.helper.css("top"));d.containment&&(g+=a(d.containment).scrollLeft()||0,h+=a(d.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:g,top:h},this.size=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalSize=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalPosition={left:g,top:h},this.sizeDiff={width:f.outerWidth()-f.width(),height:f.outerHeight()-f.height()},this.originalMousePosition={left:b.pageX,top:b.pageY},this.aspectRatio=typeof d.aspectRatio=="number"?d.aspectRatio:this.originalSize.width/this.originalSize.height||1;var i=a(".ui-resizable-"+this.axis).css("cursor");return a("body").css("cursor",i=="auto"?this.axis+"-resize":i),f.addClass("ui-resizable-resizing"),this._propagate("start",b),!0},_mouseDrag:function(b){var c=this.helper,d=this.options,e={},f=this,g=this.originalMousePosition,h=this.axis,i=b.pageX-g.left||0,j=b.pageY-g.top||0,k=this._change[h];if(!k)return!1;var l=k.apply(this,[b,i,j]),m=a.browser.msie&&a.browser.version<7,n=this.sizeDiff;this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)l=this._updateRatio(l,b);return l=this._respectSize(l,b),this._propagate("resize",b),c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",b,this.ui()),!1},_mouseStop:function(b){this.resizing=!1;var c=this.options,d=this;if(this._helper){var e=this._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName),g=f&&a.ui.hasScroll(e[0],"left")?0:d.sizeDiff.height,h=f?0:d.sizeDiff.width,i={width:d.helper.width()-h,height:d.helper.height()-g},j=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,k=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;c.animate||this.element.css(a.extend(i,{top:k,left:j})),d.helper.height(d.size.height),d.helper.width(d.size.width),this._helper&&!c.animate&&this._proportionallyResize()}return a("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",b),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(a){var b=this.options,c,e,f,g,h;h={minWidth:d(b.minWidth)?b.minWidth:0,maxWidth:d(b.maxWidth)?b.maxWidth:Infinity,minHeight:d(b.minHeight)?b.minHeight:0,maxHeight:d(b.maxHeight)?b.maxHeight:Infinity};if(this._aspectRatio||a)c=h.minHeight*this.aspectRatio,f=h.minWidth/this.aspectRatio,e=h.maxHeight*this.aspectRatio,g=h.maxWidth/this.aspectRatio,c>h.minWidth&&(h.minWidth=c),f>h.minHeight&&(h.minHeight=f),e<h.maxWidth&&(h.maxWidth=e),g<h.maxHeight&&(h.maxHeight=g);this._vBoundaries=h},_updateCache:function(a){var b=this.options;this.offset=this.helper.offset(),d(a.left)&&(this.position.left=a.left),d(a.top)&&(this.position.top=a.top),d(a.height)&&(this.size.height=a.height),d(a.width)&&(this.size.width=a.width)},_updateRatio:function(a,b){var c=this.options,e=this.position,f=this.size,g=this.axis;return d(a.height)?a.width=a.height*this.aspectRatio:d(a.width)&&(a.height=a.width/this.aspectRatio),g=="sw"&&(a.left=e.left+(f.width-a.width),a.top=null),g=="nw"&&(a.top=e.top+(f.height-a.height),a.left=e.left+(f.width-a.width)),a},_respectSize:function(a,b){var c=this.helper,e=this._vBoundaries,f=this._aspectRatio||b.shiftKey,g=this.axis,h=d(a.width)&&e.maxWidth&&e.maxWidth<a.width,i=d(a.height)&&e.maxHeight&&e.maxHeight<a.height,j=d(a.width)&&e.minWidth&&e.minWidth>a.width,k=d(a.height)&&e.minHeight&&e.minHeight>a.height;j&&(a.width=e.minWidth),k&&(a.height=e.minHeight),h&&(a.width=e.maxWidth),i&&(a.height=e.maxHeight);var l=this.originalPosition.left+this.originalSize.width,m=this.position.top+this.size.height,n=/sw|nw|w/.test(g),o=/nw|ne|n/.test(g);j&&n&&(a.left=l-e.minWidth),h&&n&&(a.left=l-e.maxWidth),k&&o&&(a.top=m-e.minHeight),i&&o&&(a.top=m-e.maxHeight);var p=!a.width&&!a.height;return p&&!a.left&&a.top?a.top=null:p&&!a.top&&a.left&&(a.left=null),a},_proportionallyResize:function(){var b=this.options;if(!this._proportionallyResizeElements.length)return;var c=this.helper||this.element;for(var d=0;d<this._proportionallyResizeElements.length;d++){var e=this._proportionallyResizeElements[d];if(!this.borderDif){var f=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],g=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];this.borderDif=a.map(f,function(a,b){var c=parseInt(a,10)||0,d=parseInt(g[b],10)||0;return c+d})}if(!a.browser.msie||!a(c).is(":hidden")&&!a(c).parents(":hidden").length)e.css({height:c.height()-this.borderDif[0]-this.borderDif[2]||0,width:c.width()-this.borderDif[1]-this.borderDif[3]||0});else continue}},_renderProxy:function(){var b=this.element,c=this.options;this.elementOffset=b.offset();if(this._helper){this.helper=this.helper||a('<div style="overflow:hidden;"></div>');var d=a.browser.msie&&a.browser.version<7,e=d?1:0,f=d?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+f,height:this.element.outerHeight()+f,position:"absolute",left:this.elementOffset.left-e+"px",top:this.elementOffset.top-e+"px",zIndex:++c.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(a,b,c){return{width:this.originalSize.width+b}},w:function(a,b,c){var d=this.options,e=this.originalSize,f=this.originalPosition;return{left:f.left+b,width:e.width-b}},n:function(a,b,c){var d=this.options,e=this.originalSize,f=this.originalPosition;return{top:f.top+c,height:e.height-c}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},sw:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,c,d]))},ne:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},nw:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,c,d]))}},_propagate:function(b,c){a.ui.plugin.call(this,b,[c,this.ui()]),b!="resize"&&this._trigger(b,c,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),a.extend(a.ui.resizable,{version:"1.8.24"}),a.ui.plugin.add("resizable","alsoResize",{start:function(b,c){var d=a(this).data("resizable"),e=d.options,f=function(b){a(b).each(function(){var b=a(this);b.data("resizable-alsoresize",{width:parseInt(b.width(),10),height:parseInt(b.height(),10),left:parseInt(b.css("left"),10),top:parseInt(b.css("top"),10)})})};typeof e.alsoResize=="object"&&!e.alsoResize.parentNode?e.alsoResize.length?(e.alsoResize=e.alsoResize[0],f(e.alsoResize)):a.each(e.alsoResize,function(a){f(a)}):f(e.alsoResize)},resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.originalSize,g=d.originalPosition,h={height:d.size.height-f.height||0,width:d.size.width-f.width||0,top:d.position.top-g.top||0,left:d.position.left-g.left||0},i=function(b,d){a(b).each(function(){var b=a(this),e=a(this).data("resizable-alsoresize"),f={},g=d&&d.length?d:b.parents(c.originalElement[0]).length?["width","height"]:["width","height","top","left"];a.each(g,function(a,b){var c=(e[b]||0)+(h[b]||0);c&&c>=0&&(f[b]=c||null)}),b.css(f)})};typeof e.alsoResize=="object"&&!e.alsoResize.nodeType?a.each(e.alsoResize,function(a,b){i(a,b)}):i(e.alsoResize)},stop:function(b,c){a(this).removeData("resizable-alsoresize")}}),a.ui.plugin.add("resizable","animate",{stop:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d._proportionallyResizeElements,g=f.length&&/textarea/i.test(f[0].nodeName),h=g&&a.ui.hasScroll(f[0],"left")?0:d.sizeDiff.height,i=g?0:d.sizeDiff.width,j={width:d.size.width-i,height:d.size.height-h},k=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,l=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;d.element.animate(a.extend(j,l&&k?{top:l,left:k}:{}),{duration:e.animateDuration,easing:e.animateEasing,step:function(){var c={width:parseInt(d.element.css("width"),10),height:parseInt(d.element.css("height"),10),top:parseInt(d.element.css("top"),10),left:parseInt(d.element.css("left"),10)};f&&f.length&&a(f[0]).css({width:c.width,height:c.height}),d._updateCache(c),d._propagate("resize",b)}})}}),a.ui.plugin.add("resizable","containment",{start:function(b,d){var e=a(this).data("resizable"),f=e.options,g=e.element,h=f.containment,i=h instanceof a?h.get(0):/parent/.test(h)?g.parent().get(0):h;if(!i)return;e.containerElement=a(i);if(/document/.test(h)||h==document)e.containerOffset={left:0,top:0},e.containerPosition={left:0,top:0},e.parentData={element:a(document),left:0,top:0,width:a(document).width(),height:a(document).height()||document.body.parentNode.scrollHeight};else{var j=a(i),k=[];a(["Top","Right","Left","Bottom"]).each(function(a,b){k[a]=c(j.css("padding"+b))}),e.containerOffset=j.offset(),e.containerPosition=j.position(),e.containerSize={height:j.innerHeight()-k[3],width:j.innerWidth()-k[1]};var l=e.containerOffset,m=e.containerSize.height,n=e.containerSize.width,o=a.ui.hasScroll(i,"left")?i.scrollWidth:n,p=a.ui.hasScroll(i)?i.scrollHeight:m;e.parentData={element:i,left:l.left,top:l.top,width:o,height:p}}},resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.containerSize,g=d.containerOffset,h=d.size,i=d.position,j=d._aspectRatio||b.shiftKey,k={top:0,left:0},l=d.containerElement;l[0]!=document&&/static/.test(l.css("position"))&&(k=g),i.left<(d._helper?g.left:0)&&(d.size.width=d.size.width+(d._helper?d.position.left-g.left:d.position.left-k.left),j&&(d.size.height=d.size.width/d.aspectRatio),d.position.left=e.helper?g.left:0),i.top<(d._helper?g.top:0)&&(d.size.height=d.size.height+(d._helper?d.position.top-g.top:d.position.top),j&&(d.size.width=d.size.height*d.aspectRatio),d.position.top=d._helper?g.top:0),d.offset.left=d.parentData.left+d.position.left,d.offset.top=d.parentData.top+d.position.top;var m=Math.abs((d._helper?d.offset.left-k.left:d.offset.left-k.left)+d.sizeDiff.width),n=Math.abs((d._helper?d.offset.top-k.top:d.offset.top-g.top)+d.sizeDiff.height),o=d.containerElement.get(0)==d.element.parent().get(0),p=/relative|absolute/.test(d.containerElement.css("position"));o&&p&&(m-=d.parentData.left),m+d.size.width>=d.parentData.width&&(d.size.width=d.parentData.width-m,j&&(d.size.height=d.size.width/d.aspectRatio)),n+d.size.height>=d.parentData.height&&(d.size.height=d.parentData.height-n,j&&(d.size.width=d.size.height*d.aspectRatio))},stop:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.position,g=d.containerOffset,h=d.containerPosition,i=d.containerElement,j=a(d.helper),k=j.offset(),l=j.outerWidth()-d.sizeDiff.width,m=j.outerHeight()-d.sizeDiff.height;d._helper&&!e.animate&&/relative/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m}),d._helper&&!e.animate&&/static/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m})}}),a.ui.plugin.add("resizable","ghost",{start:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.size;d.ghost=d.originalElement.clone(),d.ghost.css({opacity:.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof e.ghost=="string"?e.ghost:""),d.ghost.appendTo(d.helper)},resize:function(b,c){var d=a(this).data("resizable"),e=d.options;d.ghost&&d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})},stop:function(b,c){var d=a(this).data("resizable"),e=d.options;d.ghost&&d.helper&&d.helper.get(0).removeChild(d.ghost.get(0))}}),a.ui.plugin.add("resizable","grid",{resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.size,g=d.originalSize,h=d.originalPosition,i=d.axis,j=e._aspectRatio||b.shiftKey;e.grid=typeof e.grid=="number"?[e.grid,e.grid]:e.grid;var k=Math.round((f.width-g.width)/(e.grid[0]||1))*(e.grid[0]||1),l=Math.round((f.height-g.height)/(e.grid[1]||1))*(e.grid[1]||1);/^(se|s|e)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l):/^(ne)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l):/^(sw)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.left=h.left-k):(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l,d.position.left=h.left-k)}});var c=function(a){return parseInt(a,10)||0},d=function(a){return!isNaN(parseInt(a,10))}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.selectable.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.selectable",a.ui.mouse,{options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var b=this;this.element.addClass("ui-selectable"),this.dragged=!1;var c;this.refresh=function(){c=a(b.options.filter,b.element[0]),c.addClass("ui-selectee"),c.each(function(){var b=a(this),c=b.offset();a.data(this,"selectable-item",{element:this,$element:b,left:c.left,top:c.top,right:c.left+b.outerWidth(),bottom:c.top+b.outerHeight(),startselected:!1,selected:b.hasClass("ui-selected"),selecting:b.hasClass("ui-selecting"),unselecting:b.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=c.addClass("ui-selectee"),this._mouseInit(),this.helper=a("<div class='ui-selectable-helper'></div>")},destroy:function(){return this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable"),this._mouseDestroy(),this},_mouseStart:function(b){var c=this;this.opos=[b.pageX,b.pageY];if(this.options.disabled)return;var d=this.options;this.selectees=a(d.filter,this.element[0]),this._trigger("start",b),a(d.appendTo).append(this.helper),this.helper.css({left:b.clientX,top:b.clientY,width:0,height:0}),d.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var d=a.data(this,"selectable-item");d.startselected=!0,!b.metaKey&&!b.ctrlKey&&(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",b,{unselecting:d.element}))}),a(b.target).parents().andSelf().each(function(){var d=a.data(this,"selectable-item");if(d){var e=!b.metaKey&&!b.ctrlKey||!d.$element.hasClass("ui-selected");return d.$element.removeClass(e?"ui-unselecting":"ui-selected").addClass(e?"ui-selecting":"ui-unselecting"),d.unselecting=!e,d.selecting=e,d.selected=e,e?c._trigger("selecting",b,{selecting:d.element}):c._trigger("unselecting",b,{unselecting:d.element}),!1}})},_mouseDrag:function(b){var c=this;this.dragged=!0;if(this.options.disabled)return;var d=this.options,e=this.opos[0],f=this.opos[1],g=b.pageX,h=b.pageY;if(e>g){var i=g;g=e,e=i}if(f>h){var i=h;h=f,f=i}return this.helper.css({left:e,top:f,width:g-e,height:h-f}),this.selectees.each(function(){var i=a.data(this,"selectable-item");if(!i||i.element==c.element[0])return;var j=!1;d.tolerance=="touch"?j=!(i.left>g||i.right<e||i.top>h||i.bottom<f):d.tolerance=="fit"&&(j=i.left>e&&i.right<g&&i.top>f&&i.bottom<h),j?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,c._trigger("selecting",b,{selecting:i.element}))):(i.selecting&&((b.metaKey||b.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),c._trigger("unselecting",b,{unselecting:i.element}))),i.selected&&!b.metaKey&&!b.ctrlKey&&!i.startselected&&(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,c._trigger("unselecting",b,{unselecting:i.element})))}),!1},_mouseStop:function(b){var c=this;this.dragged=!1;var d=this.options;return a(".ui-unselecting",this.element[0]).each(function(){var d=a.data(this,"selectable-item");d.$element.removeClass("ui-unselecting"),d.unselecting=!1,d.startselected=!1,c._trigger("unselected",b,{unselected:d.element})}),a(".ui-selecting",this.element[0]).each(function(){var d=a.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass("ui-selected"),d.selecting=!1,d.selected=!0,d.startselected=!0,c._trigger("selected",b,{selected:d.element})}),this._trigger("stop",b),this.helper.remove(),!1}}),a.extend(a.ui.selectable,{version:"1.8.24"})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.sortable.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.sortable",a.ui.mouse,{widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},destroy:function(){a.Widget.prototype.destroy.call(this),this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var b=this.items.length-1;b>=0;b--)this.items[b].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){b==="disabled"?(this.options[b]=c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(b);var e=null,f=this,g=a(b.target).parents().each(function(){if(a.data(this,d.widgetName+"-item")==f)return e=a(this),!1});a.data(b.target,d.widgetName+"-item")==f&&(e=a(b.target));if(!e)return!1;if(this.options.handle&&!c){var h=!1;a(this.options.handle,e).find("*").andSelf().each(function(){this==b.target&&(h=!0)});if(!h)return!1}return this.currentItem=e,this._removeCurrentsFromItems(),!0},_mouseStart:function(b,c,d){var e=this.options,f=this;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,e.cursorAt&&this._adjustOffsetFromHelper(e.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),e.containment&&this._setContainment(),e.cursor&&(a("body").css("cursor")&&(this._storedCursor=a("body").css("cursor")),a("body").css("cursor",e.cursor)),e.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",e.opacity)),e.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",e.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(var g=this.containers.length-1;g>=0;g--)this.containers[g]._trigger("activate",b,f._uiHash(this));return a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b),!0},_mouseDrag:function(b){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var c=this.options,d=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY<c.scrollSensitivity?this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop+c.scrollSpeed:b.pageY-this.overflowOffset.top<c.scrollSensitivity&&(this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop-c.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-b.pageX<c.scrollSensitivity?this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft+c.scrollSpeed:b.pageX-this.overflowOffset.left<c.scrollSensitivity&&(this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft-c.scrollSpeed)):(b.pageY-a(document).scrollTop()<c.scrollSensitivity?d=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<c.scrollSensitivity&&(d=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed)),b.pageX-a(document).scrollLeft()<c.scrollSensitivity?d=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(d=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))),d!==!1&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(var e=this.items.length-1;e>=0;e--){var f=this.items[e],g=f.item[0],h=this._intersectsWithPointer(f);if(!h)continue;if(f.instance!==this.currentContainer)continue;if(g!=this.currentItem[0]&&this.placeholder[h==1?"next":"prev"]()[0]!=g&&!a.ui.contains(this.placeholder[0],g)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],g):!0)){this.direction=h==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(f))this._rearrange(b,f);else break;this._trigger("change",b,this._uiHash());break}}return this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(b,c){if(!b)return;a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b);if(this.options.revert){var d=this,e=d.placeholder.offset();d.reverting=!0,a(this.helper).animate({left:e.left-this.offset.parent.left-d.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:e.top-this.offset.parent.top-d.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1},cancel:function(){var b=this;if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("deactivate",null,b._uiHash(this)),this.containers[c].containerCache.over&&(this.containers[c]._trigger("out",null,b._uiHash(this)),this.containers[c].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"="),d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")}),d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l=d+j>h&&d+j<i&&b+k>f&&b+k<g;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?l:f<b+this.helperProportions.width/2&&c-this.helperProportions.width/2<g&&h<d+this.helperProportions.height/2&&e-this.helperProportions.height/2<i},_intersectsWithPointer:function(b){var c=this.options.axis==="x"||a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top,b.height),d=this.options.axis==="y"||a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left,b.width),e=c&&d,f=this._getDragVerticalDirection(),g=this._getDragHorizontalDirection();return e?this.floating?g&&g=="right"||f=="down"?2:1:f&&(f=="down"?2:1):!1},_intersectsWithSides:function(b){var c=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top+b.height/2,b.height),d=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left+b.width/2,b.width),e=this._getDragVerticalDirection(),f=this._getDragHorizontalDirection();return this.floating&&f?f=="right"&&d||f=="left"&&!d:e&&(e=="down"&&c||e=="up"&&!c)},_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;return a!=0&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){return this._refreshItems(a),this.refreshPositions(),this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c=this,d=[],e=[],f=this._connectWith();if(f&&b)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&e.push([a.isFunction(j.options.items)?j.options.items.call(j.element):a(j.options.items,j.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),j])}}e.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var g=e.length-1;g>=0;g--)e[g][0].each(function(){d.push(this)});return a(d)},_removeCurrentsFromItems:function(){var a=this.currentItem.find(":data("+this.widgetName+"-item)");for(var b=0;b<this.items.length;b++)for(var c=0;c<a.length;c++)a[c]==this.items[b].item[0]&&this.items.splice(b,1)},_refreshItems:function(b){this.items=[],this.containers=[this];var c=this.items,d=this,e=[[a.isFunction(this.options.items)?this.options.items.call(this.element[0],b,{item:this.currentItem}):a(this.options.items,this.element),this]],f=this._connectWith();if(f&&this.ready)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&(e.push([a.isFunction(j.options.items)?j.options.items.call(j.element[0],b,{item:this.currentItem}):a(j.options.items,j.element),j]),this.containers.push(j))}}for(var g=e.length-1;g>=0;g--){var k=e[g][1],l=e[g][0];for(var i=0,m=l.length;i<m;i++){var n=a(l[i]);n.data(this.widgetName+"-item",k),c.push({item:n,instance:k,width:0,height:0,left:0,top:0})}}},refreshPositions:function(b){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var c=this.items.length-1;c>=0;c--){var d=this.items[c];if(d.instance!=this.currentContainer&&this.currentContainer&&d.item[0]!=this.currentItem[0])continue;var e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item;b||(d.width=e.outerWidth(),d.height=e.outerHeight());var f=e.offset();d.left=f.left,d.top=f.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var c=this.containers.length-1;c>=0;c--){var f=this.containers[c].element.offset();this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight()}return this},_createPlaceholder:function(b){var c=b||this,d=c.options;if(!d.placeholder||d.placeholder.constructor==String){var e=d.placeholder;d.placeholder={element:function(){var b=a(document.createElement(c.currentItem[0].nodeName)).addClass(e||c.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return e||(b.style.visibility="hidden"),b},update:function(a,b){if(e&&!d.forcePlaceholderSize)return;b.height()||b.height(c.currentItem.innerHeight()-parseInt(c.currentItem.css("paddingTop")||0,10)-parseInt(c.currentItem.css("paddingBottom")||0,10)),b.width()||b.width(c.currentItem.innerWidth()-parseInt(c.currentItem.css("paddingLeft")||0,10)-parseInt(c.currentItem.css("paddingRight")||0,10))}}}c.placeholder=a(d.placeholder.element.call(c.element,c.currentItem)),c.currentItem.after(c.placeholder),d.placeholder.update(c,c.placeholder)},_contactContainers:function(b){var c=null,d=null;for(var e=this.containers.length-1;e>=0;e--){if(a.ui.contains(this.currentItem[0],this.containers[e].element[0]))continue;if(this._intersectsWith(this.containers[e].containerCache)){if(c&&a.ui.contains(this.containers[e].element[0],c.element[0]))continue;c=this.containers[e],d=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0)}if(!c)return;if(this.containers.length===1)this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1;else if(this.currentContainer!=this.containers[d]){var f=1e4,g=null,h=this.positionAbs[this.containers[d].floating?"left":"top"];for(var i=this.items.length-1;i>=0;i--){if(!a.ui.contains(this.containers[d].element[0],this.items[i].item[0]))continue;var j=this.containers[d].floating?this.items[i].item.offset().left:this.items[i].item.offset().top;Math.abs(j-h)<f&&(f=Math.abs(j-h),g=this.items[i],this.direction=j-h>0?"down":"up")}if(!g&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[d],g?this._rearrange(b,g,null,!0):this._rearrange(b,null,this.containers[d].element,!0),this._trigger("change",b,this._uiHash()),this.containers[d]._trigger("change",b,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1}},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b,this.currentItem])):c.helper=="clone"?this.currentItem.clone():this.currentItem;return d.parents("body").length||a(c.appendTo!="parent"?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]),d[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(d[0].style.width==""||c.forceHelperSize)&&d.width(this.currentItem.width()),(d[0].style.height==""||c.forceHelperSize)&&d.height(this.currentItem.height()),d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)){var c=a(b.containment)[0],d=a(b.containment).offset(),e=a(c).css("overflow")!="hidden";this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(e?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(e?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var f=b.pageX,g=b.pageY;if(this.originalPosition){this.containment&&(b.pageX-this.offset.click.left<this.containment[0]&&(f=this.containment[0]+this.offset.click.left),b.pageY-this.offset.click.top<this.containment[1]&&(g=this.containment[1]+this.offset.click.top),b.pageX-this.offset.click.left>this.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top));if(c.grid){var h=this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1];g=this.containment?h-this.offset.click.top<this.containment[1]||h-this.offset.click.top>this.containment[3]?h-this.offset.click.top<this.containment[1]?h+c.grid[1]:h-c.grid[1]:h:h;var i=this.originalPageX+Math.round((f-this.originalPageX)/c.grid[0])*c.grid[0];f=this.containment?i-this.offset.click.left<this.containment[0]||i-this.offset.click.left>this.containment[2]?i-this.offset.click.left<this.containment[0]?i+c.grid[0]:i-c.grid[0]:i:i}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:d.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_rearrange:function(a,b,c,d){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?b.item[0]:b.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var e=this,f=this.counter;window.setTimeout(function(){f==e.counter&&e.refreshPositions(!d)},0)},_clear:function(b,c){this.reverting=!1;var d=[],e=this;!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var f in this._storedCSS)if(this._storedCSS[f]=="auto"||this._storedCSS[f]=="static")this._storedCSS[f]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!c&&d.push(function(a){this._trigger("receive",a,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!c&&d.push(function(a){this._trigger("update",a,this._uiHash())}),this!==this.currentContainer&&(c||(d.push(function(a){this._trigger("remove",a,this._uiHash())}),d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.currentContainer)),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.currentContainer))));for(var f=this.containers.length-1;f>=0;f--)c||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over=0);this._storedCursor&&a("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!c){this._trigger("beforeStop",b,this._uiHash());for(var f=0;f<d.length;f++)d[f].call(this,b);this._trigger("stop",b,this._uiHash())}return this.fromOutside=!1,!1}c||this._trigger("beforeStop",b,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!c){for(var f=0;f<d.length;f++)d[f].call(this,b);this._trigger("stop",b,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){var c=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}}),a.extend(a.ui.sortable,{version:"1.8.24"})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.accordion.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.accordion",{options:{active:0,animated:"slide",autoHeight:!0,clearStyle:!1,collapsible:!1,event:"click",fillSpace:!1,header:"> li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var b=this,c=b.options;b.running=0,b.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix"),b.headers=b.element.find(c.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){if(c.disabled)return;a(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){if(c.disabled)return;a(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){if(c.disabled)return;a(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){if(c.disabled)return;a(this).removeClass("ui-state-focus")}),b.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");if(c.navigation){var d=b.element.find("a").filter(c.navigationFilter).eq(0);if(d.length){var e=d.closest(".ui-accordion-header");e.length?b.active=e:b.active=d.closest(".ui-accordion-content").prev()}}b.active=b._findActive(b.active||c.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"),b.active.next().addClass("ui-accordion-content-active"),b._createIcons(),b.resize(),b.element.attr("role","tablist"),b.headers.attr("role","tab").bind("keydown.accordion",function(a){return b._keydown(a)}).next().attr("role","tabpanel"),b.headers.not(b.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide(),b.active.length?b.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):b.headers.eq(0).attr("tabIndex",0),a.browser.safari||b.headers.find("a").attr("tabIndex",-1),c.event&&b.headers.bind(c.event.split(" ").join(".accordion ")+".accordion",function(a){b._clickHandler.call(b,a,this),a.preventDefault()})},_createIcons:function(){var b=this.options;b.icons&&(a("<span></span>").addClass("ui-icon "+b.icons.header).prependTo(this.headers),this.active.children(".ui-icon").toggleClass(b.icons.header).toggleClass(b.icons.headerSelected),this.element.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.children(".ui-icon").remove(),this.element.removeClass("ui-accordion-icons")},destroy:function(){var b=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"),this.headers.find("a").removeAttr("tabIndex"),this._destroyIcons();var c=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");return(b.autoHeight||b.fillHeight)&&c.css("height",""),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b=="active"&&this.activate(c),b=="icons"&&(this._destroyIcons(),c&&this._createIcons()),b=="disabled"&&this.headers.add(this.headers.next())[c?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(b){if(this.options.disabled||b.altKey||b.ctrlKey)return;var c=a.ui.keyCode,d=this.headers.length,e=this.headers.index(b.target),f=!1;switch(b.keyCode){case c.RIGHT:case c.DOWN:f=this.headers[(e+1)%d];break;case c.LEFT:case c.UP:f=this.headers[(e-1+d)%d];break;case c.SPACE:case c.ENTER:this._clickHandler({target:b.target},b.target),b.preventDefault()}return f?(a(b.target).attr("tabIndex",-1),a(f).attr("tabIndex",0),f.focus(),!1):!0},resize:function(){var b=this.options,c;if(b.fillSpace){if(a.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}c=this.element.parent().height(),a.browser.msie&&this.element.parent().css("overflow",d),this.headers.each(function(){c-=a(this).outerHeight(!0)}),this.headers.next().each(function(){a(this).height(Math.max(0,c-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")}else b.autoHeight&&(c=0,this.headers.next().each(function(){c=Math.max(c,a(this).height("").height())}).height(c));return this},activate:function(a){this.options.active=a;var b=this._findActive(a)[0];return this._clickHandler({target:b},b),this},_findActive:function(b){return b?typeof b=="number"?this.headers.filter(":eq("+b+")"):this.headers.not(this.headers.not(b)):b===!1?a([]):this.headers.filter(":eq(0)")},_clickHandler:function(b,c){var d=this.options;if(d.disabled)return;if(!b.target){if(!d.collapsible)return;this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header),this.active.next().addClass("ui-accordion-content-active");var e=this.active.next(),f={options:d,newHeader:a([]),oldHeader:d.active,newContent:a([]),oldContent:e},g=this.active=a([]);this._toggle(g,e,f);return}var h=a(b.currentTarget||c),i=h[0]===this.active[0];d.active=d.collapsible&&i?!1:this.headers.index(h);if(this.running||!d.collapsible&&i)return;var j=this.active,g=h.next(),e=this.active.next(),f={options:d,newHeader:i&&d.collapsible?a([]):h,oldHeader:this.active,newContent:i&&d.collapsible?a([]):g,oldContent:e},k=this.headers.index(this.active[0])>this.headers.index(h[0]);this.active=i?a([]):h,this._toggle(g,e,f,i,k),j.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header),i||(h.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected),h.next().addClass("ui-accordion-content-active"));return},_toggle:function(b,c,d,e,f){var g=this,h=g.options;g.toShow=b,g.toHide=c,g.data=d;var i=function(){if(!g)return;return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data),g.running=c.size()===0?b.size():c.size();if(h.animated){var j={};h.collapsible&&e?j={toShow:a([]),toHide:c,complete:i,down:f,autoHeight:h.autoHeight||h.fillSpace}:j={toShow:b,toHide:c,complete:i,down:f,autoHeight:h.autoHeight||h.fillSpace},h.proxied||(h.proxied=h.animated),h.proxiedDuration||(h.proxiedDuration=h.duration),h.animated=a.isFunction(h.proxied)?h.proxied(j):h.proxied,h.duration=a.isFunction(h.proxiedDuration)?h.proxiedDuration(j):h.proxiedDuration;var k=a.ui.accordion.animations,l=h.duration,m=h.animated;m&&!k[m]&&!a.easing[m]&&(m="slide"),k[m]||(k[m]=function(a){this.slide(a,{easing:m,duration:l||700})}),k[m](j)}else h.collapsible&&e?b.toggle():(c.hide(),b.show()),i(!0);c.prev().attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).blur(),b.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(this.running)return;this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""}),this.toHide.removeClass("ui-accordion-content-active"),this.toHide.length&&(this.toHide.parent()[0].className=this.toHide.parent()[0].className),this._trigger("change",null,this.data)}}),a.extend(a.ui.accordion,{version:"1.8.24",animations:{slide:function(b,c){b=a.extend({easing:"swing",duration:300},b,c);if(!b.toHide.size()){b.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},b);return}if(!b.toShow.size()){b.toHide.animate({height:"hide",paddingTop:"hide",paddingBottom:"hide"},b);return}var d=b.toShow.css("overflow"),e=0,f={},g={},h=["height","paddingTop","paddingBottom"],i,j=b.toShow;i=j[0].style.width,j.width(j.parent().width()-parseFloat(j.css("paddingLeft"))-parseFloat(j.css("paddingRight"))-(parseFloat(j.css("borderLeftWidth"))||0)-(parseFloat(j.css("borderRightWidth"))||0)),a.each(h,function(c,d){g[d]="hide";var e=(""+a.css(b.toShow[0],d)).match(/^([\d+-.]+)(.*)$/);f[d]={value:e[1],unit:e[2]||"px"}}),b.toShow.css({height:0,overflow:"hidden"}).show(),b.toHide.filter(":hidden").each(b.complete).end().filter(":visible").animate(g,{step:function(a,c){c.prop=="height"&&(e=c.end-c.start===0?0:(c.now-c.start)/(c.end-c.start)),b.toShow[0].style[c.prop]=e*f[c.prop].value+f[c.prop].unit},duration:b.duration,easing:b.easing,complete:function(){b.autoHeight||b.toShow.css("height",""),b.toShow.css({width:i,overflow:d}),b.complete()}})},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1e3:200})}}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.autocomplete.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){var c=0;a.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var b=this,c=this.element[0].ownerDocument,d;this.isMultiLine=this.element.is("textarea"),this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(b.options.disabled||b.element.propAttr("readOnly"))return;d=!1;var e=a.ui.keyCode;switch(c.keyCode){case e.PAGE_UP:b._move("previousPage",c);break;case e.PAGE_DOWN:b._move("nextPage",c);break;case e.UP:b._keyEvent("previous",c);break;case e.DOWN:b._keyEvent("next",c);break;case e.ENTER:case e.NUMPAD_ENTER:b.menu.active&&(d=!0,c.preventDefault());case e.TAB:if(!b.menu.active)return;b.menu.select(c);break;case e.ESCAPE:b.element.val(b.term),b.close(c);break;default:clearTimeout(b.searching),b.searching=setTimeout(function(){b.term!=b.element.val()&&(b.selectedItem=null,b.search(null,c))},b.options.delay)}}).bind("keypress.autocomplete",function(a){d&&(d=!1,a.preventDefault())}).bind("focus.autocomplete",function(){if(b.options.disabled)return;b.selectedItem=null,b.previous=b.element.val()}).bind("blur.autocomplete",function(a){if(b.options.disabled)return;clearTimeout(b.searching),b.closing=setTimeout(function(){b.close(a),b._change(a)},150)}),this._initSource(),this.menu=a("<ul></ul>").addClass("ui-autocomplete").appendTo(a(this.options.appendTo||"body",c)[0]).mousedown(function(c){var d=b.menu.element[0];a(c.target).closest(".ui-menu-item").length||setTimeout(function(){a(document).one("mousedown",function(c){c.target!==b.element[0]&&c.target!==d&&!a.ui.contains(d,c.target)&&b.close()})},1),setTimeout(function(){clearTimeout(b.closing)},13)}).menu({focus:function(a,c){var d=c.item.data("item.autocomplete");!1!==b._trigger("focus",a,{item:d})&&/^key/.test(a.originalEvent.type)&&b.element.val(d.value)},selected:function(a,d){var e=d.item.data("item.autocomplete"),f=b.previous;b.element[0]!==c.activeElement&&(b.element.focus(),b.previous=f,setTimeout(function(){b.previous=f,b.selectedItem=e},1)),!1!==b._trigger("select",a,{item:e})&&b.element.val(e.value),b.term=b.element.val(),b.close(a),b.selectedItem=e},blur:function(a,c){b.menu.element.is(":visible")&&b.element.val()!==b.term&&b.element.val(b.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu"),a.fn.bgiframe&&this.menu.element.bgiframe(),b.beforeunloadHandler=function(){b.element.removeAttr("autocomplete")},a(window).bind("beforeunload",b.beforeunloadHandler)},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"),this.menu.element.remove(),a(window).unbind("beforeunload",this.beforeunloadHandler),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b==="source"&&this._initSource(),b==="appendTo"&&this.menu.element.appendTo(a(c||"body",this.element[0].ownerDocument)[0]),b==="disabled"&&c&&this.xhr&&this.xhr.abort()},_initSource:function(){var b=this,c,d;a.isArray(this.options.source)?(c=this.options.source,this.source=function(b,d){d(a.ui.autocomplete.filter(c,b.term))}):typeof this.options.source=="string"?(d=this.options.source,this.source=function(c,e){b.xhr&&b.xhr.abort(),b.xhr=a.ajax({url:d,data:c,dataType:"json",success:function(a,b){e(a)},error:function(){e([])}})}):this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val(),this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)===!1)return;return this._search(a)},_search:function(a){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.source({term:a},this._response())},_response:function(){var a=this,b=++c;return function(d){b===c&&a.__response(d),a.pending--,a.pending||a.element.removeClass("ui-autocomplete-loading")}},__response:function(a){!this.options.disabled&&a&&a.length?(a=this._normalize(a),this._suggest(a),this._trigger("open")):this.close()},close:function(a){clearTimeout(this.closing),this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.deactivate(),this._trigger("close",a))},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(b){return b.length&&b[0].label&&b[0].value?b:a.map(b,function(b){return typeof b=="string"?{label:b,value:b}:a.extend({label:b.label||b.value,value:b.value||b.label},b)})},_suggest:function(b){var c=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(c,b),this.menu.deactivate(),this.menu.refresh(),c.show(),this._resizeMenu(),c.position(a.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next(new a.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(b,c){var d=this;a.each(c,function(a,c){d._renderItem(b,c)})},_renderItem:function(b,c){return a("<li></li>").data("item.autocomplete",c).append(a("<a></a>").text(c.label)).appendTo(b)},_move:function(a,b){if(!this.menu.element.is(":visible")){this.search(null,b);return}if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term),this.menu.deactivate();return}this.menu[a](b)},widget:function(){return this.menu.element},_keyEvent:function(a,b){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(a,b),b.preventDefault()}}),a.extend(a.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(b,c){var d=new RegExp(a.ui.autocomplete.escapeRegex(c),"i");return a.grep(b,function(a){return d.test(a.label||a.value||a)})}})})(jQuery),function(a){a.widget("ui.menu",{_create:function(){var b=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){if(!a(c.target).closest(".ui-menu-item a").length)return;c.preventDefault(),b.select(c)}),this.refresh()},refresh:function(){var b=this,c=this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem");c.children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(c){b.activate(c,a(this).parent())}).mouseleave(function(){b.deactivate()})},activate:function(a,b){this.deactivate();if(this.hasScroll()){var c=b.offset().top-this.element.offset().top,d=this.element.scrollTop(),e=this.element.height();c<0?this.element.scrollTop(d+c):c>=e&&this.element.scrollTop(d+c-e+b.height())}this.active=b.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end(),this._trigger("focus",a,{item:b})},deactivate:function(){if(!this.active)return;this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(a,b,c){if(!this.active){this.activate(c,this.element.children(b));return}var d=this.active[a+"All"](".ui-menu-item").eq(0);d.length?this.activate(c,d):this.activate(c,this.element.children(b))},nextPage:function(b){if(this.hasScroll()){if(!this.active||this.last()){this.activate(b,this.element.children(".ui-menu-item:first"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c-d+a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:last")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(b){if(this.hasScroll()){if(!this.active||this.first()){this.activate(b,this.element.children(".ui-menu-item:last"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c+d-a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:first")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[a.fn.prop?"prop":"attr"]("scrollHeight")},select:function(a){this._trigger("selected",a,{item:this.active})}})}(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.button.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){var c,d,e,f,g="ui-button ui-widget ui-state-default ui-corner-all",h="ui-state-hover ui-state-active ",i="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",j=function(){var b=a(this).find(":ui-button");setTimeout(function(){b.button("refresh")},1)},k=function(b){var c=b.name,d=b.form,e=a([]);return c&&(d?e=a(d).find("[name='"+c+"']"):e=a("[name='"+c+"']",b.ownerDocument).filter(function(){return!this.form})),e};a.widget("ui.button",{options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",j),typeof this.options.disabled!="boolean"?this.options.disabled=!!this.element.propAttr("disabled"):this.element.propAttr("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var b=this,h=this.options,i=this.type==="checkbox"||this.type==="radio",l="ui-state-hover"+(i?"":" ui-state-active"),m="ui-state-focus";h.label===null&&(h.label=this.buttonElement.html()),this.buttonElement.addClass(g).attr("role","button").bind("mouseenter.button",function(){if(h.disabled)return;a(this).addClass("ui-state-hover"),this===c&&a(this).addClass("ui-state-active")}).bind("mouseleave.button",function(){if(h.disabled)return;a(this).removeClass(l)}).bind("click.button",function(a){h.disabled&&(a.preventDefault(),a.stopImmediatePropagation())}),this.element.bind("focus.button",function(){b.buttonElement.addClass(m)}).bind("blur.button",function(){b.buttonElement.removeClass(m)}),i&&(this.element.bind("change.button",function(){if(f)return;b.refresh()}),this.buttonElement.bind("mousedown.button",function(a){if(h.disabled)return;f=!1,d=a.pageX,e=a.pageY}).bind("mouseup.button",function(a){if(h.disabled)return;if(d!==a.pageX||e!==a.pageY)f=!0})),this.type==="checkbox"?this.buttonElement.bind("click.button",function(){if(h.disabled||f)return!1;a(this).toggleClass("ui-state-active"),b.buttonElement.attr("aria-pressed",b.element[0].checked)}):this.type==="radio"?this.buttonElement.bind("click.button",function(){if(h.disabled||f)return!1;a(this).addClass("ui-state-active"),b.buttonElement.attr("aria-pressed","true");var c=b.element[0];k(c).not(c).map(function(){return a(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown.button",function(){if(h.disabled)return!1;a(this).addClass("ui-state-active"),c=this,a(document).one("mouseup",function(){c=null})}).bind("mouseup.button",function(){if(h.disabled)return!1;a(this).removeClass("ui-state-active")}).bind("keydown.button",function(b){if(h.disabled)return!1;(b.keyCode==a.ui.keyCode.SPACE||b.keyCode==a.ui.keyCode.ENTER)&&a(this).addClass("ui-state-active")}).bind("keyup.button",function(){a(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(b){b.keyCode===a.ui.keyCode.SPACE&&a(this).click()})),this._setOption("disabled",h.disabled),this._resetButton()},_determineButtonType:function(){this.element.is(":checkbox")?this.type="checkbox":this.element.is(":radio")?this.type="radio":this.element.is("input")?this.type="input":this.type="button";if(this.type==="checkbox"||this.type==="radio"){var a=this.element.parents().filter(":last"),b="label[for='"+this.element.attr("id")+"']";this.buttonElement=a.find(b),this.buttonElement.length||(a=a.length?a.siblings():this.element.siblings(),this.buttonElement=a.filter(b),this.buttonElement.length||(this.buttonElement=a.find(b))),this.element.addClass("ui-helper-hidden-accessible");var c=this.element.is(":checked");c&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.attr("aria-pressed",c)}else this.buttonElement=this.element},widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(g+" "+h+" "+i).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title"),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments);if(b==="disabled"){c?this.element.propAttr("disabled",!0):this.element.propAttr("disabled",!1);return}this._resetButton()},refresh:function(){var b=this.element.is(":disabled");b!==this.options.disabled&&this._setOption("disabled",b),this.type==="radio"?k(this.element[0]).each(function(){a(this).is(":checked")?a(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):a(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):this.type==="checkbox"&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if(this.type==="input"){this.options.label&&this.element.val(this.options.label);return}var b=this.buttonElement.removeClass(i),c=a("<span></span>",this.element[0].ownerDocument).addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),d=this.options.icons,e=d.primary&&d.secondary,f=[];d.primary||d.secondary?(this.options.text&&f.push("ui-button-text-icon"+(e?"s":d.primary?"-primary":"-secondary")),d.primary&&b.prepend("<span class='ui-button-icon-primary ui-icon "+d.primary+"'></span>"),d.secondary&&b.append("<span class='ui-button-icon-secondary ui-icon "+d.secondary+"'></span>"),this.options.text||(f.push(e?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||b.attr("title",c))):f.push("ui-button-text-only"),b.addClass(f.join(" "))}}),a.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(b,c){b==="disabled"&&this.buttons.button("option",b,c),a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var b=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(b?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(b?"ui-corner-left":"ui-corner-right").end().end()},destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"),a.Widget.prototype.destroy.call(this)}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.dialog.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){var c="ui-dialog ui-widget ui-widget-content ui-corner-all ",d={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},e={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};a.widget("ui.dialog",{options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",collision:"fit",using:function(b){var c=a(this).css(b).offset().top;c<0&&a(this).css("top",b.top-c)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.options.title=this.options.title||this.originalTitle;var b=this,d=b.options,e=d.title||" ",f=a.ui.dialog.getTitleId(b.element),g=(b.uiDialog=a("<div></div>")).appendTo(document.body).hide().addClass(c+d.dialogClass).css({zIndex:d.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(c){d.closeOnEscape&&!c.isDefaultPrevented()&&c.keyCode&&c.keyCode===a.ui.keyCode.ESCAPE&&(b.close(c),c.preventDefault())}).attr({role:"dialog","aria-labelledby":f}).mousedown(function(a){b.moveToTop(!1,a)}),h=b.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g),i=(b.uiDialogTitlebar=a("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),j=a('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){j.addClass("ui-state-hover")},function(){j.removeClass("ui-state-hover")}).focus(function(){j.addClass("ui-state-focus")}).blur(function(){j.removeClass("ui-state-focus")}).click(function(a){return b.close(a),!1}).appendTo(i),k=(b.uiDialogTitlebarCloseText=a("<span></span>")).addClass("ui-icon ui-icon-closethick").text(d.closeText).appendTo(j),l=a("<span></span>").addClass("ui-dialog-title").attr("id",f).html(e).prependTo(i);a.isFunction(d.beforeclose)&&!a.isFunction(d.beforeClose)&&(d.beforeClose=d.beforeclose),i.find("*").add(i).disableSelection(),d.draggable&&a.fn.draggable&&b._makeDraggable(),d.resizable&&a.fn.resizable&&b._makeResizable(),b._createButtons(d.buttons),b._isOpen=!1,a.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;return a.overlay&&a.overlay.destroy(),a.uiDialog.hide(),a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),a.uiDialog.remove(),a.originalTitle&&a.element.attr("title",a.originalTitle),a},widget:function(){return this.uiDialog},close:function(b){var c=this,d,e;if(!1===c._trigger("beforeClose",b))return;return c.overlay&&c.overlay.destroy(),c.uiDialog.unbind("keypress.ui-dialog"),c._isOpen=!1,c.options.hide?c.uiDialog.hide(c.options.hide,function(){c._trigger("close",b)}):(c.uiDialog.hide(),c._trigger("close",b)),a.ui.dialog.overlay.resize(),c.options.modal&&(d=0,a(".ui-dialog").each(function(){this!==c.uiDialog[0]&&(e=a(this).css("z-index"),isNaN(e)||(d=Math.max(d,e)))}),a.ui.dialog.maxZ=d),c},isOpen:function(){return this._isOpen},moveToTop:function(b,c){var d=this,e=d.options,f;return e.modal&&!b||!e.stack&&!e.modal?d._trigger("focus",c):(e.zIndex>a.ui.dialog.maxZ&&(a.ui.dialog.maxZ=e.zIndex),d.overlay&&(a.ui.dialog.maxZ+=1,d.overlay.$el.css("z-index",a.ui.dialog.overlay.maxZ=a.ui.dialog.maxZ)),f={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()},a.ui.dialog.maxZ+=1,d.uiDialog.css("z-index",a.ui.dialog.maxZ),d.element.attr(f),d._trigger("focus",c),d)},open:function(){if(this._isOpen)return;var b=this,c=b.options,d=b.uiDialog;return b.overlay=c.modal?new a.ui.dialog.overlay(b):null,b._size(),b._position(c.position),d.show(c.show),b.moveToTop(!0),c.modal&&d.bind("keydown.ui-dialog",function(b){if(b.keyCode!==a.ui.keyCode.TAB)return;var c=a(":tabbable",this),d=c.filter(":first"),e=c.filter(":last");if(b.target===e[0]&&!b.shiftKey)return d.focus(1),!1;if(b.target===d[0]&&b.shiftKey)return e.focus(1),!1}),a(b.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus(),b._isOpen=!0,b._trigger("open"),b},_createButtons:function(b){var c=this,d=!1,e=a("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),f=a("<div></div>").addClass("ui-dialog-buttonset").appendTo(e);c.uiDialog.find(".ui-dialog-buttonpane").remove(),typeof b=="object"&&b!==null&&a.each(b,function(){return!(d=!0)}),d&&(a.each(b,function(b,d){d=a.isFunction(d)?{click:d,text:b}:d;var e=a('<button type="button"></button>').click(function(){d.click.apply(c.element[0],arguments)}).appendTo(f);a.each(d,function(a,b){if(a==="click")return;a in e?e[a](b):e.attr(a,b)}),a.fn.button&&e.button()}),e.appendTo(c.uiDialog))},_makeDraggable:function(){function f(a){return{position:a.position,offset:a.offset}}var b=this,c=b.options,d=a(document),e;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(d,g){e=c.height==="auto"?"auto":a(this).height(),a(this).height(a(this).height()).addClass("ui-dialog-dragging"),b._trigger("dragStart",d,f(g))},drag:function(a,c){b._trigger("drag",a,f(c))},stop:function(g,h){c.position=[h.position.left-d.scrollLeft(),h.position.top-d.scrollTop()],a(this).removeClass("ui-dialog-dragging").height(e),b._trigger("dragStop",g,f(h)),a.ui.dialog.overlay.resize()}})},_makeResizable:function(c){function h(a){return{originalPosition:a.originalPosition,originalSize:a.originalSize,position:a.position,size:a.size}}c=c===b?this.options.resizable:c;var d=this,e=d.options,f=d.uiDialog.css("position"),g=typeof c=="string"?c:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:g,start:function(b,c){a(this).addClass("ui-dialog-resizing"),d._trigger("resizeStart",b,h(c))},resize:function(a,b){d._trigger("resize",a,h(b))},stop:function(b,c){a(this).removeClass("ui-dialog-resizing"),e.height=a(this).height(),e.width=a(this).width(),d._trigger("resizeStop",b,h(c)),a.ui.dialog.overlay.resize()}}).css("position",f).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(b){var c=[],d=[0,0],e;if(b){if(typeof b=="string"||typeof b=="object"&&"0"in b)c=b.split?b.split(" "):[b[0],b[1]],c.length===1&&(c[1]=c[0]),a.each(["left","top"],function(a,b){+c[a]===c[a]&&(d[a]=c[a],c[a]=b)}),b={my:c.join(" "),at:c.join(" "),offset:d.join(" ")};b=a.extend({},a.ui.dialog.prototype.options.position,b)}else b=a.ui.dialog.prototype.options.position;e=this.uiDialog.is(":visible"),e||this.uiDialog.show(),this.uiDialog.css({top:0,left:0}).position(a.extend({of:window},b)),e||this.uiDialog.hide()},_setOptions:function(b){var c=this,f={},g=!1;a.each(b,function(a,b){c._setOption(a,b),a in d&&(g=!0),a in e&&(f[a]=b)}),g&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",f)},_setOption:function(b,d){var e=this,f=e.uiDialog;switch(b){case"beforeclose":b="beforeClose";break;case"buttons":e._createButtons(d);break;case"closeText":e.uiDialogTitlebarCloseText.text(""+d);break;case"dialogClass":f.removeClass(e.options.dialogClass).addClass(c+d);break;case"disabled":d?f.addClass("ui-dialog-disabled"):f.removeClass("ui-dialog-disabled");break;case"draggable":var g=f.is(":data(draggable)");g&&!d&&f.draggable("destroy"),!g&&d&&e._makeDraggable();break;case"position":e._position(d);break;case"resizable":var h=f.is(":data(resizable)");h&&!d&&f.resizable("destroy"),h&&typeof d=="string"&&f.resizable("option","handles",d),!h&&d!==!1&&e._makeResizable(d);break;case"title":a(".ui-dialog-title",e.uiDialogTitlebar).html(""+(d||" "))}a.Widget.prototype._setOption.apply(e,arguments)},_size:function(){var b=this.options,c,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),b.minWidth>b.width&&(b.width=b.minWidth),c=this.uiDialog.css({height:"auto",width:b.width}).height(),d=Math.max(0,b.minHeight-c);if(b.height==="auto")if(a.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();var f=this.element.css("height","auto").height();e||this.uiDialog.hide(),this.element.height(Math.max(f,d))}else this.element.height(Math.max(b.height-c,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),a.extend(a.ui.dialog,{version:"1.8.24",uuid:0,maxZ:0,getTitleId:function(a){var b=a.attr("id");return b||(this.uuid+=1,b=this.uuid),"ui-dialog-title-"+b},overlay:function(b){this.$el=a.ui.dialog.overlay.create(b)}}),a.extend(a.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:a.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),create:function(b){this.instances.length===0&&(setTimeout(function(){a.ui.dialog.overlay.instances.length&&a(document).bind(a.ui.dialog.overlay.events,function(b){if(a(b.target).zIndex()<a.ui.dialog.overlay.maxZ)return!1})},1),a(document).bind("keydown.dialog-overlay",function(c){b.options.closeOnEscape&&!c.isDefaultPrevented()&&c.keyCode&&c.keyCode===a.ui.keyCode.ESCAPE&&(b.close(c),c.preventDefault())}),a(window).bind("resize.dialog-overlay",a.ui.dialog.overlay.resize));var c=(this.oldInstances.pop()||a("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});return a.fn.bgiframe&&c.bgiframe(),this.instances.push(c),c},destroy:function(b){var c=a.inArray(b,this.instances);c!=-1&&this.oldInstances.push(this.instances.splice(c,1)[0]),this.instances.length===0&&a([document,window]).unbind(".dialog-overlay"),b.remove();var d=0;a.each(this.instances,function(){d=Math.max(d,this.css("z-index"))}),this.maxZ=d},height:function(){var b,c;return a.browser.msie&&a.browser.version<7?(b=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),b<c?a(window).height()+"px":b+"px"):a(document).height()+"px"},width:function(){var b,c;return a.browser.msie?(b=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),c=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),b<c?a(window).width()+"px":b+"px"):a(document).width()+"px"},resize:function(){var b=a([]);a.each(a.ui.dialog.overlay.instances,function(){b=b.add(this)}),b.css({width:0,height:0}).css({width:a.ui.dialog.overlay.width(),height:a.ui.dialog.overlay.height()})}}),a.extend(a.ui.dialog.overlay.prototype,{destroy:function(){a.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.slider.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){var c=5;a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var b=this,d=this.options,e=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",g=d.values&&d.values.length||1,h=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(d.disabled?" ui-slider-disabled ui-disabled":"")),this.range=a([]),d.range&&(d.range===!0&&(d.values||(d.values=[this._valueMin(),this._valueMin()]),d.values.length&&d.values.length!==2&&(d.values=[d.values[0],d.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(d.range==="min"||d.range==="max"?" ui-slider-range-"+d.range:"")));for(var i=e.length;i<g;i+=1)h.push(f);this.handles=e.add(a(h.join("")).appendTo(b.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(a){a.preventDefault()}).hover(function(){d.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){d.disabled?a(this).blur():(a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),a(this).addClass("ui-state-focus"))}).blur(function(){a(this).removeClass("ui-state-focus")}),this.handles.each(function(b){a(this).data("index.ui-slider-handle",b)}),this.handles.keydown(function(d){var e=a(this).data("index.ui-slider-handle"),f,g,h,i;if(b.options.disabled)return;switch(d.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:d.preventDefault();if(!b._keySliding){b._keySliding=!0,a(this).addClass("ui-state-active"),f=b._start(d,e);if(f===!1)return}}i=b.options.step,b.options.values&&b.options.values.length?g=h=b.values(e):g=h=b.value();switch(d.keyCode){case a.ui.keyCode.HOME:h=b._valueMin();break;case a.ui.keyCode.END:h=b._valueMax();break;case a.ui.keyCode.PAGE_UP:h=b._trimAlignValue(g+(b._valueMax()-b._valueMin())/c);break;case a.ui.keyCode.PAGE_DOWN:h=b._trimAlignValue(g-(b._valueMax()-b._valueMin())/c);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(g===b._valueMax())return;h=b._trimAlignValue(g+i);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(g===b._valueMin())return;h=b._trimAlignValue(g-i)}b._slide(d,e,h)}).keyup(function(c){var d=a(this).data("index.ui-slider-handle");b._keySliding&&(b._keySliding=!1,b._stop(c,d),b._change(c,d),a(this).removeClass("ui-state-active"))}),this._refreshValue(),this._animateOff=!1},destroy:function(){return this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider"),this._mouseDestroy(),this},_mouseCapture:function(b){var c=this.options,d,e,f,g,h,i,j,k,l;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),d={x:b.pageX,y:b.pageY},e=this._normValueFromMouse(d),f=this._valueMax()-this._valueMin()+1,h=this,this.handles.each(function(b){var c=Math.abs(e-h.values(b));f>c&&(f=c,g=a(this),i=b)}),c.range===!0&&this.values(1)===c.min&&(i+=1,g=a(this.handles[i])),j=this._start(b,i),j===!1?!1:(this._mouseSliding=!0,h._handleIndex=i,g.addClass("ui-state-active").focus(),k=g.offset(),l=!a(b.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:b.pageX-k.left-g.width()/2,top:b.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,i,e),this._animateOff=!0,!0))},_mouseStart:function(a){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);return this._slide(a,this._handleIndex,c),!1},_mouseStop:function(a){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;return this.orientation==="horizontal"?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),d<0&&(d=0),this.orientation==="vertical"&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e,this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};return this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c<d)&&(c=d),c!==this.values(b)&&(e=this.values(),e[b]=c,f=this._trigger("slide",a,{handle:this.handles[b],value:c,values:e}),d=this.values(b?0:1),f!==!1&&this.values(b,c,!0))):c!==this.value()&&(f=this._trigger("slide",a,{handle:this.handles[b],value:c}),f!==!1&&this.value(c))},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("change",a,c)}},value:function(a){if(arguments.length){this.options.value=this._trimAlignValue(a),this._refreshValue(),this._change(null,0);return}return this._value()},values:function(b,c){var d,e,f;if(arguments.length>1){this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b);return}if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();d=this.options.values,e=arguments[0];for(f=0;f<d.length;f+=1)d[f]=this._trimAlignValue(e[f]),this._change(null,f);this._refreshValue()},_setOption:function(b,c){var d,e=0;a.isArray(this.options.values)&&(e=this.options.values.length),a.Widget.prototype._setOption.apply(this,arguments);switch(b){case"disabled":c?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",!1),this.element.removeClass("ui-disabled"));break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(d=0;d<e;d+=1)this._change(null,d);this._animateOff=!1}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a),a},_values:function(a){var b,c,d;if(arguments.length)return b=this.options.values[a],b=this._trimAlignValue(b),b;c=this.options.values.slice();for(d=0;d<c.length;d+=1)c[d]=this._trimAlignValue(c[d]);return c},_trimAlignValue:function(a){if(a<=this._valueMin())return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b,d=a-c;return Math.abs(c)*2>=b&&(d+=c>0?b:-b),parseFloat(d.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,c=this.options,d=this,e=this._animateOff?!1:c.animate,f,g={},h,i,j,k;this.options.values&&this.options.values.length?this.handles.each(function(b,i){f=(d.values(b)-d._valueMin())/(d._valueMax()-d._valueMin())*100,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",a(this).stop(1,1)[e?"animate":"css"](g,c.animate),d.options.range===!0&&(d.orientation==="horizontal"?(b===0&&d.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({width:f-h+"%"},{queue:!1,duration:c.animate})):(b===0&&d.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({height:f-h+"%"},{queue:!1,duration:c.animate}))),h=f}):(i=this.value(),j=this._valueMin(),k=this._valueMax(),f=k!==j?(i-j)/(k-j)*100:0,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",this.handle.stop(1,1)[e?"animate":"css"](g,c.animate),b==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},c.animate),b==="max"&&this.orientation==="horizontal"&&this.range[e?"animate":"css"]({width:100-f+"%"},{queue:!1,duration:c.animate}),b==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},c.animate),b==="max"&&this.orientation==="vertical"&&this.range[e?"animate":"css"]({height:100-f+"%"},{queue:!1,duration:c.animate}))}}),a.extend(a.ui.slider,{version:"1.8.24"})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.tabs.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){function e(){return++c}function f(){return++d}var c=0,d=0;a.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:!1,cookie:null,collapsible:!1,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading…</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(!0)},_setOption:function(a,b){if(a=="selected"){if(this.options.collapsible&&b==this.options.selected)return;this.select(b)}else this.options[a]=b,this._tabify()},_tabId:function(a){return a.title&&a.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+e()},_sanitizeSelector:function(a){return a.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+f());return a.cookie.apply(null,[b].concat(a.makeArray(arguments)))},_ui:function(a,b){return{tab:a,panel:b,index:this.anchors.index(a)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=a(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function m(b,c){b.css("display",""),!a.support.opacity&&c.opacity&&b[0].style.removeAttribute("filter")}var d=this,e=this.options,f=/^#.+/;this.list=this.element.find("ol,ul").eq(0),this.lis=a(" > li:has(a[href])",this.list),this.anchors=this.lis.map(function(){return a("a",this)[0]}),this.panels=a([]),this.anchors.each(function(b,c){var g=a(c).attr("href"),h=g.split("#")[0],i;h&&(h===location.toString().split("#")[0]||(i=a("base")[0])&&h===i.href)&&(g=c.hash,c.href=g);if(f.test(g))d.panels=d.panels.add(d.element.find(d._sanitizeSelector(g)));else if(g&&g!=="#"){a.data(c,"href.tabs",g),a.data(c,"load.tabs",g.replace(/#.*$/,""));var j=d._tabId(c);c.href="#"+j;var k=d.element.find("#"+j);k.length||(k=a(e.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(d.panels[b-1]||d.list),k.data("destroy.tabs",!0)),d.panels=d.panels.add(k)}else e.disabled.push(b)}),c?(this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"),this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.lis.addClass("ui-state-default ui-corner-top"),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom"),e.selected===b?(location.hash&&this.anchors.each(function(a,b){if(b.hash==location.hash)return e.selected=a,!1}),typeof e.selected!="number"&&e.cookie&&(e.selected=parseInt(d._cookie(),10)),typeof e.selected!="number"&&this.lis.filter(".ui-tabs-selected").length&&(e.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))),e.selected=e.selected||(this.lis.length?0:-1)):e.selected===null&&(e.selected=-1),e.selected=e.selected>=0&&this.anchors[e.selected]||e.selected<0?e.selected:0,e.disabled=a.unique(e.disabled.concat(a.map(this.lis.filter(".ui-state-disabled"),function(a,b){return d.lis.index(a)}))).sort(),a.inArray(e.selected,e.disabled)!=-1&&e.disabled.splice(a.inArray(e.selected,e.disabled),1),this.panels.addClass("ui-tabs-hide"),this.lis.removeClass("ui-tabs-selected ui-state-active"),e.selected>=0&&this.anchors.length&&(d.element.find(d._sanitizeSelector(d.anchors[e.selected].hash)).removeClass("ui-tabs-hide"),this.lis.eq(e.selected).addClass("ui-tabs-selected ui-state-active"),d.element.queue("tabs",function(){d._trigger("show",null,d._ui(d.anchors[e.selected],d.element.find(d._sanitizeSelector(d.anchors[e.selected].hash))[0]))}),this.load(e.selected)),a(window).bind("unload",function(){d.lis.add(d.anchors).unbind(".tabs"),d.lis=d.anchors=d.panels=null})):e.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")),this.element[e.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible"),e.cookie&&this._cookie(e.selected,e.cookie);for(var g=0,h;h=this.lis[g];g++)a(h)[a.inArray(g,e.disabled)!=-1&&!a(h).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");e.cache===!1&&this.anchors.removeData("cache.tabs"),this.lis.add(this.anchors).unbind(".tabs");if(e.event!=="mouseover"){var i=function(a,b){b.is(":not(.ui-state-disabled)")&&b.addClass("ui-state-"+a)},j=function(a,b){b.removeClass("ui-state-"+a)};this.lis.bind("mouseover.tabs",function(){i("hover",a(this))}),this.lis.bind("mouseout.tabs",function(){j("hover",a(this))}),this.anchors.bind("focus.tabs",function(){i("focus",a(this).closest("li"))}),this.anchors.bind("blur.tabs",function(){j("focus",a(this).closest("li"))})}var k,l;e.fx&&(a.isArray(e.fx)?(k=e.fx[0],l=e.fx[1]):k=l=e.fx);var n=l?function(b,c){a(b).closest("li").addClass("ui-tabs-selected ui-state-active"),c.hide().removeClass("ui-tabs-hide").animate(l,l.duration||"normal",function(){m(c,l),d._trigger("show",null,d._ui(b,c[0]))})}:function(b,c){a(b).closest("li").addClass("ui-tabs-selected ui-state-active"),c.removeClass("ui-tabs-hide"),d._trigger("show",null,d._ui(b,c[0]))},o=k?function(a,b){b.animate(k,k.duration||"normal",function(){d.lis.removeClass("ui-tabs-selected ui-state-active"),b.addClass("ui-tabs-hide"),m(b,k),d.element.dequeue("tabs")})}:function(a,b,c){d.lis.removeClass("ui-tabs-selected ui-state-active"),b.addClass("ui-tabs-hide"),d.element.dequeue("tabs")};this.anchors.bind(e.event+".tabs",function(){var b=this,c=a(b).closest("li"),f=d.panels.filter(":not(.ui-tabs-hide)"),g=d.element.find(d._sanitizeSelector(b.hash));if(c.hasClass("ui-tabs-selected")&&!e.collapsible||c.hasClass("ui-state-disabled")||c.hasClass("ui-state-processing")||d.panels.filter(":animated").length||d._trigger("select",null,d._ui(this,g[0]))===!1)return this.blur(),!1;e.selected=d.anchors.index(this),d.abort();if(e.collapsible){if(c.hasClass("ui-tabs-selected"))return e.selected=-1,e.cookie&&d._cookie(e.selected,e.cookie),d.element.queue("tabs",function(){o(b,f)}).dequeue("tabs"),this.blur(),!1;if(!f.length)return e.cookie&&d._cookie(e.selected,e.cookie),d.element.queue("tabs",function(){n(b,g)}),d.load(d.anchors.index(this)),this.blur(),!1}e.cookie&&d._cookie(e.selected,e.cookie);if(g.length)f.length&&d.element.queue("tabs",function(){o(b,f)}),d.element.queue("tabs",function(){n(b,g)}),d.load(d.anchors.index(this));else throw"jQuery UI Tabs: Mismatching fragment identifier.";a.browser.msie&&this.blur()}),this.anchors.bind("click.tabs",function(){return!1})},_getIndex:function(a){return typeof a=="string"&&(a=this.anchors.index(this.anchors.filter("[href$='"+a+"']"))),a},destroy:function(){var b=this.options;return this.abort(),this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs"),this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.anchors.each(function(){var b=a.data(this,"href.tabs");b&&(this.href=b);var c=a(this).unbind(".tabs");a.each(["href","load","cache"],function(a,b){c.removeData(b+".tabs")})}),this.lis.unbind(".tabs").add(this.panels).each(function(){a.data(this,"destroy.tabs")?a(this).remove():a(this).removeClass(["ui-state-default","ui-corner-top","ui-tabs-selected","ui-state-active","ui-state-hover","ui-state-focus","ui-state-disabled","ui-tabs-panel","ui-widget-content","ui-corner-bottom","ui-tabs-hide"].join(" "))}),b.cookie&&this._cookie(null,b.cookie),this},add:function(c,d,e){e===b&&(e=this.anchors.length);var f=this,g=this.options,h=a(g.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,d)),i=c.indexOf("#")?this._tabId(a("a",h)[0]):c.replace("#","");h.addClass("ui-state-default ui-corner-top").data("destroy.tabs",!0);var j=f.element.find("#"+i);return j.length||(j=a(g.panelTemplate).attr("id",i).data("destroy.tabs",!0)),j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"),e>=this.lis.length?(h.appendTo(this.list),j.appendTo(this.list[0].parentNode)):(h.insertBefore(this.lis[e]),j.insertBefore(this.panels[e])),g.disabled=a.map(g.disabled,function(a,b){return a>=e?++a:a}),this._tabify(),this.anchors.length==1&&(g.selected=0,h.addClass("ui-tabs-selected ui-state-active"),j.removeClass("ui-tabs-hide"),this.element.queue("tabs",function(){f._trigger("show",null,f._ui(f.anchors[0],f.panels[0]))}),this.load(0)),this._trigger("add",null,this._ui(this.anchors[e],this.panels[e])),this},remove:function(b){b=this._getIndex(b);var c=this.options,d=this.lis.eq(b).remove(),e=this.panels.eq(b).remove();return d.hasClass("ui-tabs-selected")&&this.anchors.length>1&&this.select(b+(b+1<this.anchors.length?1:-1)),c.disabled=a.map(a.grep(c.disabled,function(a,c){return a!=b}),function(a,c){return a>=b?--a:a}),this._tabify(),this._trigger("remove",null,this._ui(d.find("a")[0],e[0])),this},enable:function(b){b=this._getIndex(b);var c=this.options;if(a.inArray(b,c.disabled)==-1)return;return this.lis.eq(b).removeClass("ui-state-disabled"),c.disabled=a.grep(c.disabled,function(a,c){return a!=b}),this._trigger("enable",null,this._ui(this.anchors[b],this.panels[b])),this},disable:function(a){a=this._getIndex(a);var b=this,c=this.options;return a!=c.selected&&(this.lis.eq(a).addClass("ui-state-disabled"),c.disabled.push(a),c.disabled.sort(),this._trigger("disable",null,this._ui(this.anchors[a],this.panels[a]))),this},select:function(a){a=this._getIndex(a);if(a==-1)if(this.options.collapsible&&this.options.selected!=-1)a=this.options.selected;else return this;return this.anchors.eq(a).trigger(this.options.event+".tabs"),this},load:function(b){b=this._getIndex(b);var c=this,d=this.options,e=this.anchors.eq(b)[0],f=a.data(e,"load.tabs");this.abort();if(!f||this.element.queue("tabs").length!==0&&a.data(e,"cache.tabs")){this.element.dequeue("tabs");return}this.lis.eq(b).addClass("ui-state-processing");if(d.spinner){var g=a("span",e);g.data("label.tabs",g.html()).html(d.spinner)}return this.xhr=a.ajax(a.extend({},d.ajaxOptions,{url:f,success:function(f,g){c.element.find(c._sanitizeSelector(e.hash)).html(f),c._cleanup(),d.cache&&a.data(e,"cache.tabs",!0),c._trigger("load",null,c._ui(c.anchors[b],c.panels[b]));try{d.ajaxOptions.success(f,g)}catch(h){}},error:function(a,f,g){c._cleanup(),c._trigger("load",null,c._ui(c.anchors[b],c.panels[b]));try{d.ajaxOptions.error(a,f,b,e)}catch(g){}}})),c.element.dequeue("tabs"),this},abort:function(){return this.element.queue([]),this.panels.stop(!1,!0),this.element.queue("tabs",this.element.queue("tabs").splice(-2,2)),this.xhr&&(this.xhr.abort(),delete this.xhr),this._cleanup(),this},url:function(a,b){return this.anchors.eq(a).removeData("cache.tabs").data("load.tabs",b),this},length:function(){return this.anchors.length}}),a.extend(a.ui.tabs,{version:"1.8.24"}),a.extend(a.ui.tabs.prototype,{rotation:null,rotate:function(a,b){var c=this,d=this.options,e=c._rotate||(c._rotate=function(b){clearTimeout(c.rotation),c.rotation=setTimeout(function(){var a=d.selected;c.select(++a<c.anchors.length?a:0)},a),b&&b.stopPropagation()}),f=c._unrotate||(c._unrotate=b?function(a){e()}:function(a){a.clientX&&c.rotate(null)});return a?(this.element.bind("tabsshow",e),this.anchors.bind(d.event+".tabs",f),e()):(clearTimeout(c.rotation),this.element.unbind("tabsshow",e),this.anchors.unbind(d.event+".tabs",f),delete this._rotate,delete this._unrotate),this}})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.datepicker.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function($,undefined){function Datepicker(){this.debug=!1,this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},$.extend(this._defaults,this.regional[""]),this.dpDiv=bindHover($('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}function bindHover(a){var b="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return a.bind("mouseout",function(a){var c=$(a.target).closest(b);if(!c.length)return;c.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(c){var d=$(c.target).closest(b);if($.datepicker._isDisabledDatepicker(instActive.inline?a.parent()[0]:instActive.input[0])||!d.length)return;d.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),d.addClass("ui-state-hover"),d.hasClass("ui-datepicker-prev")&&d.addClass("ui-datepicker-prev-hover"),d.hasClass("ui-datepicker-next")&&d.addClass("ui-datepicker-next-hover")})}function extendRemove(a,b){$.extend(a,b);for(var c in b)if(b[c]==null||b[c]==undefined)a[c]=b[c];return a}function isArray(a){return a&&($.browser.safari&&typeof a=="object"&&a.length||a.constructor&&a.constructor.toString().match(/\Array\(\)/))}$.extend($.ui,{datepicker:{version:"1.8.24"}});var PROP_NAME="datepicker",dpuuid=(new Date).getTime(),instActive;$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){return extendRemove(this._defaults,a||{}),this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase(),inline=nodeName=="div"||nodeName=="span";target.id||(this.uuid+=1,target.id="dp"+this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{}),nodeName=="input"?this._connectDatepicker(target,inst):inline&&this._inlineDatepicker(target,inst)},_newInst:function(a,b){var c=a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:c,input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:b?bindHover($('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')):this.dpDiv}},_connectDatepicker:function(a,b){var c=$(a);b.append=$([]),b.trigger=$([]);if(c.hasClass(this.markerClassName))return;this._attachments(c,b),c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),this._autoSize(b),$.data(a,PROP_NAME,b),b.settings.disabled&&this._disableDatepicker(a)},_attachments:function(a,b){var c=this._get(b,"appendText"),d=this._get(b,"isRTL");b.append&&b.append.remove(),c&&(b.append=$('<span class="'+this._appendClass+'">'+c+"</span>"),a[d?"before":"after"](b.append)),a.unbind("focus",this._showDatepicker),b.trigger&&b.trigger.remove();var e=this._get(b,"showOn");(e=="focus"||e=="both")&&a.focus(this._showDatepicker);if(e=="button"||e=="both"){var f=this._get(b,"buttonText"),g=this._get(b,"buttonImage");b.trigger=$(this._get(b,"buttonImageOnly")?$("<img/>").addClass(this._triggerClass).attr({src:g,alt:f,title:f}):$('<button type="button"></button>').addClass(this._triggerClass).html(g==""?f:$("<img/>").attr({src:g,alt:f,title:f}))),a[d?"before":"after"](b.trigger),b.trigger.click(function(){return $.datepicker._datepickerShowing&&$.datepicker._lastInput==a[0]?$.datepicker._hideDatepicker():$.datepicker._datepickerShowing&&$.datepicker._lastInput!=a[0]?($.datepicker._hideDatepicker(),$.datepicker._showDatepicker(a[0])):$.datepicker._showDatepicker(a[0]),!1})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var d=function(a){var b=0,c=0;for(var d=0;d<a.length;d++)a[d].length>b&&(b=a[d].length,c=d);return c};b.setMonth(d(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort"))),b.setDate(d(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=$(a);if(c.hasClass(this.markerClassName))return;c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),$.data(a,PROP_NAME,b),this._setDate(b,this._getDefaultDate(b),!0),this._updateDatepicker(b),this._updateAlternate(b),b.settings.disabled&&this._disableDatepicker(a),b.dpDiv.css("display","block")},_dialogDatepicker:function(a,b,c,d,e){var f=this._dialogInst;if(!f){this.uuid+=1;var g="dp"+this.uuid;this._dialogInput=$('<input type="text" id="'+g+'" style="position: absolute; top: -100px; width: 0px;"/>'),this._dialogInput.keydown(this._doKeyDown),$("body").append(this._dialogInput),f=this._dialogInst=this._newInst(this._dialogInput,!1),f.settings={},$.data(this._dialogInput[0],PROP_NAME,f)}extendRemove(f.settings,d||{}),b=b&&b.constructor==Date?this._formatDate(f,b):b,this._dialogInput.val(b),this._pos=e?e.length?e:[e.pageX,e.pageY]:null;if(!this._pos){var h=document.documentElement.clientWidth,i=document.documentElement.clientHeight,j=document.documentElement.scrollLeft||document.body.scrollLeft,k=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[h/2-100+j,i/2-150+k]}return this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),f.settings.onSelect=c,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),$.blockUI&&$.blockUI(this.dpDiv),$.data(this._dialogInput[0],PROP_NAME,f),this},_destroyDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();$.removeData(a,PROP_NAME),d=="input"?(c.append.remove(),c.trigger.remove(),b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):(d=="div"||d=="span")&&b.removeClass(this.markerClassName).empty()},_enableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!1,c.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().removeClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b})},_disableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!0,c.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().addClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b}),this._disabledInputs[this._disabledInputs.length]=a},_isDisabledDatepicker:function(a){if(!a)return!1;for(var b=0;b<this._disabledInputs.length;b++)if(this._disabledInputs[b]==a)return!0;return!1},_getInst:function(a){try{return $.data(a,PROP_NAME)}catch(b){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(a,b,c){var d=this._getInst(a);if(arguments.length==2&&typeof b=="string")return b=="defaults"?$.extend({},$.datepicker._defaults):d?b=="all"?$.extend({},d.settings):this._get(d,b):null;var e=b||{};typeof b=="string"&&(e={},e[b]=c);if(d){this._curInst==d&&this._hideDatepicker();var f=this._getDateDatepicker(a,!0),g=this._getMinMaxDate(d,"min"),h=this._getMinMaxDate(d,"max");extendRemove(d.settings,e),g!==null&&e.dateFormat!==undefined&&e.minDate===undefined&&(d.settings.minDate=this._formatDate(d,g)),h!==null&&e.dateFormat!==undefined&&e.maxDate===undefined&&(d.settings.maxDate=this._formatDate(d,h)),this._attachments($(a),d),this._autoSize(d),this._setDate(d,f),this._updateAlternate(d),this._updateDatepicker(d)}},_changeDatepicker:function(a,b,c){this._optionDatepicker(a,b,c)},_refreshDatepicker:function(a){var b=this._getInst(a);b&&this._updateDatepicker(b)},_setDateDatepicker:function(a,b){var c=this._getInst(a);c&&(this._setDate(c,b),this._updateDatepicker(c),this._updateAlternate(c))},_getDateDatepicker:function(a,b){var c=this._getInst(a);return c&&!c.inline&&this._setDateFromField(c,b),c?this._getDate(c):null},_doKeyDown:function(a){var b=$.datepicker._getInst(a.target),c=!0,d=b.dpDiv.is(".ui-datepicker-rtl");b._keyEvent=!0;if($.datepicker._datepickerShowing)switch(a.keyCode){case 9:$.datepicker._hideDatepicker(),c=!1;break;case 13:var e=$("td."+$.datepicker._dayOverClass+":not(."+$.datepicker._currentClass+")",b.dpDiv);e[0]&&$.datepicker._selectDay(a.target,b.selectedMonth,b.selectedYear,e[0]);var f=$.datepicker._get(b,"onSelect");if(f){var g=$.datepicker._formatDate(b);f.apply(b.input?b.input[0]:null,[g,b])}else $.datepicker._hideDatepicker();return!1;case 27:$.datepicker._hideDatepicker();break;case 33:$.datepicker._adjustDate(a.target,a.ctrlKey?-$.datepicker._get(b,"stepBigMonths"):-$.datepicker._get(b,"stepMonths"),"M");break;case 34:$.datepicker._adjustDate(a.target,a.ctrlKey?+$.datepicker._get(b,"stepBigMonths"):+$.datepicker._get(b,"stepMonths"),"M");break;case 35:(a.ctrlKey||a.metaKey)&&$.datepicker._clearDate(a.target),c=a.ctrlKey||a.metaKey;break;case 36:(a.ctrlKey||a.metaKey)&&$.datepicker._gotoToday(a.target),c=a.ctrlKey||a.metaKey;break;case 37:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,d?1:-1,"D"),c=a.ctrlKey||a.metaKey,a.originalEvent.altKey&&$.datepicker._adjustDate(a.target,a.ctrlKey?-$.datepicker._get(b,"stepBigMonths"):-$.datepicker._get(b,"stepMonths"),"M");break;case 38:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,-7,"D"),c=a.ctrlKey||a.metaKey;break;case 39:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,d?-1:1,"D"),c=a.ctrlKey||a.metaKey,a.originalEvent.altKey&&$.datepicker._adjustDate(a.target,a.ctrlKey?+$.datepicker._get(b,"stepBigMonths"):+$.datepicker._get(b,"stepMonths"),"M");break;case 40:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,7,"D"),c=a.ctrlKey||a.metaKey;break;default:c=!1}else a.keyCode==36&&a.ctrlKey?$.datepicker._showDatepicker(this):c=!1;c&&(a.preventDefault(),a.stopPropagation())},_doKeyPress:function(a){var b=$.datepicker._getInst(a.target);if($.datepicker._get(b,"constrainInput")){var c=$.datepicker._possibleChars($.datepicker._get(b,"dateFormat")),d=String.fromCharCode(a.charCode==undefined?a.keyCode:a.charCode);return a.ctrlKey||a.metaKey||d<" "||!c||c.indexOf(d)>-1}},_doKeyUp:function(a){var b=$.datepicker._getInst(a.target);if(b.input.val()!=b.lastVal)try{var c=$.datepicker.parseDate($.datepicker._get(b,"dateFormat"),b.input?b.input.val():null,$.datepicker._getFormatConfig(b));c&&($.datepicker._setDateFromField(b),$.datepicker._updateAlternate(b),$.datepicker._updateDatepicker(b))}catch(d){$.datepicker.log(d)}return!0},_showDatepicker:function(a){a=a.target||a,a.nodeName.toLowerCase()!="input"&&(a=$("input",a.parentNode)[0]);if($.datepicker._isDisabledDatepicker(a)||$.datepicker._lastInput==a)return;var b=$.datepicker._getInst(a);$.datepicker._curInst&&$.datepicker._curInst!=b&&($.datepicker._curInst.dpDiv.stop(!0,!0),b&&$.datepicker._datepickerShowing&&$.datepicker._hideDatepicker($.datepicker._curInst.input[0]));var c=$.datepicker._get(b,"beforeShow"),d=c?c.apply(a,[a,b]):{};if(d===!1)return;extendRemove(b.settings,d),b.lastVal=null,$.datepicker._lastInput=a,$.datepicker._setDateFromField(b),$.datepicker._inDialog&&(a.value=""),$.datepicker._pos||($.datepicker._pos=$.datepicker._findPos(a),$.datepicker._pos[1]+=a.offsetHeight);var e=!1;$(a).parents().each(function(){return e|=$(this).css("position")=="fixed",!e}),e&&$.browser.opera&&($.datepicker._pos[0]-=document.documentElement.scrollLeft,$.datepicker._pos[1]-=document.documentElement.scrollTop);var f={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null,b.dpDiv.empty(),b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),$.datepicker._updateDatepicker(b),f=$.datepicker._checkOffset(b,f,e),b.dpDiv.css({position:$.datepicker._inDialog&&$.blockUI?"static":e?"fixed":"absolute",display:"none",left:f.left+"px",top:f.top+"px"});if(!b.inline){var g=$.datepicker._get(b,"showAnim"),h=$.datepicker._get(b,"duration"),i=function(){var a=b.dpDiv.find("iframe.ui-datepicker-cover");if(!!a.length){var c=$.datepicker._getBorders(b.dpDiv);a.css({left:-c[0],top:-c[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex($(a).zIndex()+1),$.datepicker._datepickerShowing=!0,$.effects&&$.effects[g]?b.dpDiv.show(g,$.datepicker._get(b,"showOptions"),h,i):b.dpDiv[g||"show"](g?h:null,i),(!g||!h)&&i(),b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus(),$.datepicker._curInst=b}},_updateDatepicker:function(a){var b=this;b.maxRows=4;var c=$.datepicker._getBorders(a.dpDiv);instActive=a,a.dpDiv.empty().append(this._generateHTML(a)),this._attachHandlers(a);var d=a.dpDiv.find("iframe.ui-datepicker-cover");!d.length||d.css({left:-c[0],top:-c[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}),a.dpDiv.find("."+this._dayOverClass+" a").mouseover();var e=this._getNumberOfMonths(a),f=e[1],g=17;a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),f>1&&a.dpDiv.addClass("ui-datepicker-multi-"+f).css("width",g*f+"em"),a.dpDiv[(e[0]!=1||e[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi"),a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),a==$.datepicker._curInst&&$.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var h=a.yearshtml;setTimeout(function(){h===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml),h=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(a){return{thin:1,medium:2,thick:3}[a]||a};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var d=a.dpDiv.outerWidth(),e=a.dpDiv.outerHeight(),f=a.input?a.input.outerWidth():0,g=a.input?a.input.outerHeight():0,h=document.documentElement.clientWidth+(c?0:$(document).scrollLeft()),i=document.documentElement.clientHeight+(c?0:$(document).scrollTop());return b.left-=this._get(a,"isRTL")?d-f:0,b.left-=c&&b.left==a.input.offset().left?$(document).scrollLeft():0,b.top-=c&&b.top==a.input.offset().top+g?$(document).scrollTop():0,b.left-=Math.min(b.left,b.left+d>h&&h>d?Math.abs(b.left+d-h):0),b.top-=Math.min(b.top,b.top+e>i&&i>e?Math.abs(e+g):0),b},_findPos:function(a){var b=this._getInst(a),c=this._get(b,"isRTL");while(a&&(a.type=="hidden"||a.nodeType!=1||$.expr.filters.hidden(a)))a=a[c?"previousSibling":"nextSibling"];var d=$(a).offset();return[d.left,d.top]},_hideDatepicker:function(a){var b=this._curInst;if(!b||a&&b!=$.data(a,PROP_NAME))return;if(this._datepickerShowing){var c=this._get(b,"showAnim"),d=this._get(b,"duration"),e=function(){$.datepicker._tidyDialog(b)};$.effects&&$.effects[c]?b.dpDiv.hide(c,$.datepicker._get(b,"showOptions"),d,e):b.dpDiv[c=="slideDown"?"slideUp":c=="fadeIn"?"fadeOut":"hide"](c?d:null,e),c||e(),this._datepickerShowing=!1;var f=this._get(b,"onClose");f&&f.apply(b.input?b.input[0]:null,[b.input?b.input.val():"",b]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),$.blockUI&&($.unblockUI(),$("body").append(this.dpDiv))),this._inDialog=!1}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(!$.datepicker._curInst)return;var b=$(a.target),c=$.datepicker._getInst(b[0]);(b[0].id!=$.datepicker._mainDivId&&b.parents("#"+$.datepicker._mainDivId).length==0&&!b.hasClass($.datepicker.markerClassName)&&!b.closest("."+$.datepicker._triggerClass).length&&$.datepicker._datepickerShowing&&(!$.datepicker._inDialog||!$.blockUI)||b.hasClass($.datepicker.markerClassName)&&$.datepicker._curInst!=c)&&$.datepicker._hideDatepicker()},_adjustDate:function(a,b,c){var d=$(a),e=this._getInst(d[0]);if(this._isDisabledDatepicker(d[0]))return;this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c),this._updateDatepicker(e)},_gotoToday:function(a){var b=$(a),c=this._getInst(b[0]);if(this._get(c,"gotoCurrent")&&c.currentDay)c.selectedDay=c.currentDay,c.drawMonth=c.selectedMonth=c.currentMonth,c.drawYear=c.selectedYear=c.currentYear;else{var d=new Date;c.selectedDay=d.getDate(),c.drawMonth=c.selectedMonth=d.getMonth(),c.drawYear=c.selectedYear=d.getFullYear()}this._notifyChange(c),this._adjustDate(b)},_selectMonthYear:function(a,b,c){var d=$(a),e=this._getInst(d[0]);e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10),this._notifyChange(e),this._adjustDate(d)},_selectDay:function(a,b,c,d){var e=$(a);if($(d).hasClass(this._unselectableClass)||this._isDisabledDatepicker(e[0]))return;var f=this._getInst(e[0]);f.selectedDay=f.currentDay=$("a",d).html(),f.selectedMonth=f.currentMonth=b,f.selectedYear=f.currentYear=c,this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))},_clearDate:function(a){var b=$(a),c=this._getInst(b[0]);this._selectDate(b,"")},_selectDate:function(a,b){var c=$(a),d=this._getInst(c[0]);b=b!=null?b:this._formatDate(d),d.input&&d.input.val(b),this._updateAlternate(d);var e=this._get(d,"onSelect");e?e.apply(d.input?d.input[0]:null,[b,d]):d.input&&d.input.trigger("change"),d.inline?this._updateDatepicker(d):(this._hideDatepicker(),this._lastInput=d.input[0],typeof d.input[0]!="object"&&d.input.focus(),this._lastInput=null)},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),d=this._getDate(a),e=this.formatDate(c,d,this._getFormatConfig(a));$(b).each(function(){$(this).val(e)})}},noWeekends:function(a){var b=a.getDay();return[b>0&&b<6,""]},iso8601Week:function(a){var b=new Date(a.getTime());b.setDate(b.getDate()+4-(b.getDay()||7));var c=b.getTime();return b.setMonth(0),b.setDate(1),Math.floor(Math.round((c-b)/864e5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?b.toString():b+"";if(b=="")return null;var d=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;d=typeof d!="string"?d:(new Date).getFullYear()%100+parseInt(d,10);var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,g=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,h=(c?c.monthNames:null)||this._defaults.monthNames,i=-1,j=-1,k=-1,l=-1,m=!1,n=function(b){var c=s+1<a.length&&a.charAt(s+1)==b;return c&&s++,c},o=function(a){var c=n(a),d=a=="@"?14:a=="!"?20:a=="y"&&c?4:a=="o"?3:2,e=new RegExp("^\\d{1,"+d+"}"),f=b.substring(r).match(e);if(!f)throw"Missing number at position "+r;return r+=f[0].length,parseInt(f[0],10)},p=function(a,c,d){var e=$.map(n(a)?d:c,function(a,b){return[[b,a]]}).sort(function(a,b){return-(a[1].length-b[1].length)}),f=-1;$.each(e,function(a,c){var d=c[1];if(b.substr(r,d.length).toLowerCase()==d.toLowerCase())return f=c[0],r+=d.length,!1});if(f!=-1)return f+1;throw"Unknown name at position "+r},q=function(){if(b.charAt(r)!=a.charAt(s))throw"Unexpected literal at position "+r;r++},r=0;for(var s=0;s<a.length;s++)if(m)a.charAt(s)=="'"&&!n("'")?m=!1:q();else switch(a.charAt(s)){case"d":k=o("d");break;case"D":p("D",e,f);break;case"o":l=o("o");break;case"m":j=o("m");break;case"M":j=p("M",g,h);break;case"y":i=o("y");break;case"@":var t=new Date(o("@"));i=t.getFullYear(),j=t.getMonth()+1,k=t.getDate();break;case"!":var t=new Date((o("!")-this._ticksTo1970)/1e4);i=t.getFullYear(),j=t.getMonth()+1,k=t.getDate();break;case"'":n("'")?q():m=!0;break;default:q()}if(r<b.length)throw"Extra/unparsed characters found in date: "+b.substring(r);i==-1?i=(new Date).getFullYear():i<100&&(i+=(new Date).getFullYear()-(new Date).getFullYear()%100+(i<=d?0:-100));if(l>-1){j=1,k=l;do{var u=this._getDaysInMonth(i,j-1);if(k<=u)break;j++,k-=u}while(!0)}var t=this._daylightSavingAdjust(new Date(i,j-1,k));if(t.getFullYear()!=i||t.getMonth()+1!=j||t.getDate()!=k)throw"Invalid date";return t},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1e7,formatDate:function(a,b,c){if(!b)return"";var d=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,e=(c?c.dayNames:null)||this._defaults.dayNames,f=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,h=function(b){var c=m+1<a.length&&a.charAt(m+1)==b;return c&&m++,c},i=function(a,b,c){var d=""+b;if(h(a))while(d.length<c)d="0"+d;return d},j=function(a,b,c,d){return h(a)?d[b]:c[b]},k="",l=!1;if(b)for(var m=0;m<a.length;m++)if(l)a.charAt(m)=="'"&&!h("'")?l=!1:k+=a.charAt(m);else switch(a.charAt(m)){case"d":k+=i("d",b.getDate(),2);break;case"D":k+=j("D",b.getDay(),d,e);break;case"o":k+=i("o",Math.round(((new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime()-(new Date(b.getFullYear(),0,0)).getTime())/864e5),3);break;case"m":k+=i("m",b.getMonth()+1,2);break;case"M":k+=j("M",b.getMonth(),f,g);break;case"y":k+=h("y")?b.getFullYear():(b.getYear()%100<10?"0":"")+b.getYear()%100;break;case"@":k+=b.getTime();break;case"!":k+=b.getTime()*1e4+this._ticksTo1970;break;case"'":h("'")?k+="'":l=!0;break;default:k+=a.charAt(m)}return k},_possibleChars:function(a){var b="",c=!1,d=function(b){var c=e+1<a.length&&a.charAt(e+1)==b;return c&&e++,c};for(var e=0;e<a.length;e++)if(c)a.charAt(e)=="'"&&!d("'")?c=!1:b+=a.charAt(e);else switch(a.charAt(e)){case"d":case"m":case"y":case"@":b+="0123456789";break;case"D":case"M":return null;case"'":d("'")?b+="'":c=!0;break;default:b+=a.charAt(e)}return b},_get:function(a,b){return a.settings[b]!==undefined?a.settings[b]:this._defaults[b]},_setDateFromField:function(a,b){if(a.input.val()==a.lastVal)return;var c=this._get(a,"dateFormat"),d=a.lastVal=a.input?a.input.val():null,e,f;e=f=this._getDefaultDate(a);var g=this._getFormatConfig(a);try{e=this.parseDate(c,d,g)||f}catch(h){this.log(h),d=b?"":d}a.selectedDay=e.getDate(),a.drawMonth=a.selectedMonth=e.getMonth(),a.drawYear=a.selectedYear=e.getFullYear(),a.currentDay=d?e.getDate():0,a.currentMonth=d?e.getMonth():0,a.currentYear=d?e.getFullYear():0,this._adjustInstDate(a)},_getDefaultDate:function(a){return this._restrictMinMax(a,this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,b,c){var d=function(a){var b=new Date;return b.setDate(b.getDate()+a),b},e=function(b){try{return $.datepicker.parseDate($.datepicker._get(a,"dateFormat"),b,$.datepicker._getFormatConfig(a))}catch(c){}var d=(b.toLowerCase().match(/^c/)?$.datepicker._getDate(a):null)||new Date,e=d.getFullYear(),f=d.getMonth(),g=d.getDate(),h=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,i=h.exec(b);while(i){switch(i[2]||"d"){case"d":case"D":g+=parseInt(i[1],10);break;case"w":case"W":g+=parseInt(i[1],10)*7;break;case"m":case"M":f+=parseInt(i[1],10),g=Math.min(g,$.datepicker._getDaysInMonth(e,f));break;case"y":case"Y":e+=parseInt(i[1],10),g=Math.min(g,$.datepicker._getDaysInMonth(e,f))}i=h.exec(b)}return new Date(e,f,g)},f=b==null||b===""?c:typeof b=="string"?e(b):typeof b=="number"?isNaN(b)?c:d(b):new Date(b.getTime());return f=f&&f.toString()=="Invalid Date"?c:f,f&&(f.setHours(0),f.setMinutes(0),f.setSeconds(0),f.setMilliseconds(0)),this._daylightSavingAdjust(f)},_daylightSavingAdjust:function(a){return a?(a.setHours(a.getHours()>12?a.getHours()+2:0),a):null},_setDate:function(a,b,c){var d=!b,e=a.selectedMonth,f=a.selectedYear,g=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=g.getDate(),a.drawMonth=a.selectedMonth=a.currentMonth=g.getMonth(),a.drawYear=a.selectedYear=a.currentYear=g.getFullYear(),(e!=a.selectedMonth||f!=a.selectedYear)&&!c&&this._notifyChange(a),this._adjustInstDate(a),a.input&&a.input.val(d?"":this._formatDate(a))},_getDate:function(a){var b=!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return b},_attachHandlers:function(a){var b=this._get(a,"stepMonths"),c="#"+a.id.replace(/\\\\/g,"\\");a.dpDiv.find("[data-handler]").map(function(){var a={prev:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(c,-b,"M")},next:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(c,+b,"M")},hide:function(){window["DP_jQuery_"+dpuuid].datepicker._hideDatepicker()},today:function(){window["DP_jQuery_"+dpuuid].datepicker._gotoToday(c)},selectDay:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectDay(c,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(c,this,"M"),!1},selectYear:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(c,this,"Y"),!1}};$(this).bind(this.getAttribute("data-event"),a[this.getAttribute("data-handler")])})},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),d=this._get(a,"showButtonPanel"),e=this._get(a,"hideIfNoPrevNext"),f=this._get(a,"navigationAsDateFormat"),g=this._getNumberOfMonths(a),h=this._get(a,"showCurrentAtPos"),i=this._get(a,"stepMonths"),j=g[0]!=1||g[1]!=1,k=this._daylightSavingAdjust(a.currentDay?new Date(a.currentYear,a.currentMonth,a.currentDay):new Date(9999,9,9)),l=this._getMinMaxDate(a,"min"),m=this._getMinMaxDate(a,"max"),n=a.drawMonth-h,o=a.drawYear;n<0&&(n+=12,o--);if(m){var p=this._daylightSavingAdjust(new Date(m.getFullYear(),m.getMonth()-g[0]*g[1]+1,m.getDate()));p=l&&p<l?l:p;while(this._daylightSavingAdjust(new Date(o,n,1))>p)n--,n<0&&(n=11,o--)}a.drawMonth=n,a.drawYear=o;var q=this._get(a,"prevText");q=f?this.formatDate(q,this._daylightSavingAdjust(new Date(o,n-i,1)),this._getFormatConfig(a)):q;var r=this._canAdjustMonth(a,-1,o,n)?'<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="'+q+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+q+"</span></a>":e?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+q+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+q+"</span></a>",s=this._get(a,"nextText");s=f?this.formatDate(s,this._daylightSavingAdjust(new Date(o,n+i,1)),this._getFormatConfig(a)):s;var t=this._canAdjustMonth(a,1,o,n)?'<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click" title="'+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>":e?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>",u=this._get(a,"currentText"),v=this._get(a,"gotoCurrent")&&a.currentDay?k:b;u=f?this.formatDate(u,v,this._getFormatConfig(a)):u;var w=a.inline?"":'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">'+this._get(a,"closeText")+"</button>",x=d?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(c?w:"")+(this._isInRange(a,v)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click">'+u+"</button>":"")+(c?"":w)+"</div>":"",y=parseInt(this._get(a,"firstDay"),10);y=isNaN(y)?0:y;var z=this._get(a,"showWeek"),A=this._get(a,"dayNames"),B=this._get(a,"dayNamesShort"),C=this._get(a,"dayNamesMin"),D=this._get(a,"monthNames"),E=this._get(a,"monthNamesShort"),F=this._get(a,"beforeShowDay"),G=this._get(a,"showOtherMonths"),H=this._get(a,"selectOtherMonths"),I=this._get(a,"calculateWeek")||this.iso8601Week,J=this._getDefaultDate(a),K="";for(var L=0;L<g[0];L++){var M="";this.maxRows=4;for(var N=0;N<g[1];N++){var O=this._daylightSavingAdjust(new Date(o,n,a.selectedDay)),P=" ui-corner-all",Q="";if(j){Q+='<div class="ui-datepicker-group';if(g[1]>1)switch(N){case 0:Q+=" ui-datepicker-group-first",P=" ui-corner-"+(c?"right":"left");break;case g[1]-1:Q+=" ui-datepicker-group-last",P=" ui-corner-"+(c?"left":"right");break;default:Q+=" ui-datepicker-group-middle",P=""}Q+='">'}Q+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+P+'">'+(/all|left/.test(P)&&L==0?c?t:r:"")+(/all|right/.test(P)&&L==0?c?r:t:"")+this._generateMonthYearHeader(a,n,o,l,m,L>0||N>0,D,E)+'</div><table class="ui-datepicker-calendar"><thead>'+"<tr>";var R=z?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":"";for(var S=0;S<7;S++){var T=(S+y)%7;R+="<th"+((S+y+6)%7>=5?' class="ui-datepicker-week-end"':"")+">"+'<span title="'+A[T]+'">'+C[T]+"</span></th>"}Q+=R+"</tr></thead><tbody>";var U=this._getDaysInMonth(o,n);o==a.selectedYear&&n==a.selectedMonth&&(a.selectedDay=Math.min(a.selectedDay,U));var V=(this._getFirstDayOfMonth(o,n)-y+7)%7,W=Math.ceil((V+U)/7),X=j?this.maxRows>W?this.maxRows:W:W;this.maxRows=X;var Y=this._daylightSavingAdjust(new Date(o,n,1-V));for(var Z=0;Z<X;Z++){Q+="<tr>";var _=z?'<td class="ui-datepicker-week-col">'+this._get(a,"calculateWeek")(Y)+"</td>":"";for(var S=0;S<7;S++){var ba=F?F.apply(a.input?a.input[0]:null,[Y]):[!0,""],bb=Y.getMonth()!=n,bc=bb&&!H||!ba[0]||l&&Y<l||m&&Y>m;_+='<td class="'+((S+y+6)%7>=5?" ui-datepicker-week-end":"")+(bb?" ui-datepicker-other-month":"")+(Y.getTime()==O.getTime()&&n==a.selectedMonth&&a._keyEvent||J.getTime()==Y.getTime()&&J.getTime()==O.getTime()?" "+this._dayOverClass:"")+(bc?" "+this._unselectableClass+" ui-state-disabled":"")+(bb&&!G?"":" "+ba[1]+(Y.getTime()==k.getTime()?" "+this._currentClass:"")+(Y.getTime()==b.getTime()?" ui-datepicker-today":""))+'"'+((!bb||G)&&ba[2]?' title="'+ba[2]+'"':"")+(bc?"":' data-handler="selectDay" data-event="click" data-month="'+Y.getMonth()+'" data-year="'+Y.getFullYear()+'"')+">"+(bb&&!G?" ":bc?'<span class="ui-state-default">'+Y.getDate()+"</span>":'<a class="ui-state-default'+(Y.getTime()==b.getTime()?" ui-state-highlight":"")+(Y.getTime()==k.getTime()?" ui-state-active":"")+(bb?" ui-priority-secondary":"")+'" href="#">'+Y.getDate()+"</a>")+"</td>",Y.setDate(Y.getDate()+1),Y=this._daylightSavingAdjust(Y)}Q+=_+"</tr>"}n++,n>11&&(n=0,o++),Q+="</tbody></table>"+(j?"</div>"+(g[0]>0&&N==g[1]-1?'<div class="ui-datepicker-row-break"></div>':""):""),M+=Q}K+=M}return K+=x+($.browser.msie&&parseInt($.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':""),a._keyEvent=!1,K},_generateMonthYearHeader:function(a,b,c,d,e,f,g,h){var i=this._get(a,"changeMonth"),j=this._get(a,"changeYear"),k=this._get(a,"showMonthAfterYear"),l='<div class="ui-datepicker-title">',m="";if(f||!i)m+='<span class="ui-datepicker-month">'+g[b]+"</span>";else{var n=d&&d.getFullYear()==c,o=e&&e.getFullYear()==c;m+='<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';for(var p=0;p<12;p++)(!n||p>=d.getMonth())&&(!o||p<=e.getMonth())&&(m+='<option value="'+p+'"'+(p==b?' selected="selected"':"")+">"+h[p]+"</option>");m+="</select>"}k||(l+=m+(f||!i||!j?" ":""));if(!a.yearshtml){a.yearshtml="";if(f||!j)l+='<span class="ui-datepicker-year">'+c+"</span>";else{var q=this._get(a,"yearRange").split(":"),r=(new Date).getFullYear(),s=function(a){var b=a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?r+parseInt(a,10):parseInt(a,10);return isNaN(b)?r:b},t=s(q[0]),u=Math.max(t,s(q[1]||""));t=d?Math.max(t,d.getFullYear()):t,u=e?Math.min(u,e.getFullYear()):u,a.yearshtml+='<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';for(;t<=u;t++)a.yearshtml+='<option value="'+t+'"'+(t==c?' selected="selected"':"")+">"+t+"</option>";a.yearshtml+="</select>",l+=a.yearshtml,a.yearshtml=null}}return l+=this._get(a,"yearSuffix"),k&&(l+=(f||!i||!j?" ":"")+m),l+="</div>",l},_adjustInstDate:function(a,b,c){var d=a.drawYear+(c=="Y"?b:0),e=a.drawMonth+(c=="M"?b:0),f=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+(c=="D"?b:0),g=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,f)));a.selectedDay=g.getDate(),a.drawMonth=a.selectedMonth=g.getMonth(),a.drawYear=a.selectedYear=g.getFullYear(),(c=="M"||c=="Y")&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),e=c&&b<c?c:b;return e=d&&e>d?d:e,e},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){var b=this._get(a,"numberOfMonths");return b==null?[1,1]:typeof b=="number"?[1,b]:b},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),f=this._daylightSavingAdjust(new Date(c,d+(b<0?b:e[0]*e[1]),1));return b<0&&f.setDate(this._getDaysInMonth(f.getFullYear(),f.getMonth())),this._isInRange(a,f)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<=d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");return b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10),{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);var e=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(d,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),e,this._getFormatConfig(a))}}),$.fn.datepicker=function(a){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find("body").append($.datepicker.dpDiv),$.datepicker.initialized=!0);var b=Array.prototype.slice.call(arguments,1);return typeof a!="string"||a!="isDisabled"&&a!="getDate"&&a!="widget"?a=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b)):this.each(function(){typeof a=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this].concat(b)):$.datepicker._attachDatepicker(this,a)}):$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.8.24",window["DP_jQuery_"+dpuuid]=$})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.ui.progressbar.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=a("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove(),a.Widget.prototype.destroy.apply(this,arguments)},value:function(a){return a===b?this._value():(this._setOption("value",a),this)},_setOption:function(b,c){b==="value"&&(this.options.value=c,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),a.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;return typeof a!="number"&&(a=0),Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change")),this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%"),this.element.attr("aria-valuenow",a)}}),a.extend(a.ui.progressbar,{version:"1.8.24"})})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.core.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
jQuery.effects||function(a,b){function c(b){var c;return b&&b.constructor==Array&&b.length==3?b:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))?[parseFloat(c[1])*2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))?[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:(c=/rgba\(0, 0, 0, 0\)/.exec(b))?e.transparent:e[a.trim(b).toLowerCase()]}function d(b,d){var e;do{e=(a.curCSS||a.css)(b,d);if(e!=""&&e!="transparent"||a.nodeName(b,"body"))break;d="backgroundColor"}while(b=b.parentNode);return c(e)}function h(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]]){var e=a.length;while(e--)c=a[e],typeof a[c]=="string"&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c])}else for(c in a)typeof a[c]=="string"&&(b[c]=a[c]);return b}function i(b){var c,d;for(c in b)d=b[c],(d==null||a.isFunction(d)||c in g||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete b[c];return b}function j(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function k(b,c,d,e){typeof b=="object"&&(e=c,d=null,c=b,b=c.effect),a.isFunction(c)&&(e=c,d=null,c={});if(typeof c=="number"||a.fx.speeds[c])e=d,d=c,c={};return a.isFunction(d)&&(e=d,d=null),c=c||{},d=d||c.duration,d=a.fx.off?0:typeof d=="number"?d:d in a.fx.speeds?a.fx.speeds[d]:a.fx.speeds._default,e=e||c.complete,[b,c,d,e]}function l(b){return!b||typeof b=="number"||a.fx.speeds[b]?!0:typeof b=="string"&&!a.effects[b]?!0:!1}a.effects={},a.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","borderColor","color","outlineColor"],function(b,e){a.fx.step[e]=function(a){a.colorInit||(a.start=d(a.elem,e),a.end=c(a.end),a.colorInit=!0),a.elem.style[e]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var e={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},f=["add","remove","toggle"],g={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};a.effects.animateClass=function(b,c,d,e){return a.isFunction(d)&&(e=d,d=null),this.queue(function(){var g=a(this),k=g.attr("style")||" ",l=i(h.call(this)),m,n=g.attr("class")||"";a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),m=i(h.call(this)),g.attr("class",n),g.animate(j(l,m),{queue:!1,duration:c,easing:d,complete:function(){a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),typeof g.attr("style")=="object"?(g.attr("style").cssText="",g.attr("style").cssText=k):g.attr("style",k),e&&e.apply(this,arguments),a.dequeue(this)}})})},a.fn.extend({_addClass:a.fn.addClass,addClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{add:b},c,d,e]):this._addClass(b)},_removeClass:a.fn.removeClass,removeClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{remove:b},c,d,e]):this._removeClass(b)},_toggleClass:a.fn.toggleClass,toggleClass:function(c,d,e,f,g){return typeof d=="boolean"||d===b?e?a.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):a.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(b,c,d,e,f){return a.effects.animateClass.apply(this,[{add:c,remove:b},d,e,f])}}),a.extend(a.effects,{version:"1.8.24",save:function(a,b){for(var c=0;c<b.length;c++)b[c]!==null&&a.data("ec.storage."+b[c],a[0].style[b[c]])},restore:function(a,b){for(var c=0;c<b.length;c++)b[c]!==null&&a.css(b[c],a.data("ec.storage."+b[c]))},setMode:function(a,b){return b=="toggle"&&(b=a.is(":hidden")?"show":"hide"),b},getBaseline:function(a,b){var c,d;switch(a[0]){case"top":c=0;break;case"middle":c=.5;break;case"bottom":c=1;break;default:c=a[0]/b.height}switch(a[1]){case"left":d=0;break;case"center":d=.5;break;case"right":d=1;break;default:d=a[1]/b.width}return{x:d,y:c}},createWrapper:function(b){if(b.parent().is(".ui-effects-wrapper"))return b.parent();var c={width:b.outerWidth(!0),height:b.outerHeight(!0),"float":b.css("float")},d=a("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),e=document.activeElement;try{e.id}catch(f){e=document.body}return b.wrap(d),(b[0]===e||a.contains(b[0],e))&&a(e).focus(),d=b.parent(),b.css("position")=="static"?(d.css({position:"relative"}),b.css({position:"relative"})):(a.extend(c,{position:b.css("position"),zIndex:b.css("z-index")}),a.each(["top","left","bottom","right"],function(a,d){c[d]=b.css(d),isNaN(parseInt(c[d],10))&&(c[d]="auto")}),b.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),d.css(c).show()},removeWrapper:function(b){var c,d=document.activeElement;return b.parent().is(".ui-effects-wrapper")?(c=b.parent().replaceWith(b),(b[0]===d||a.contains(b[0],d))&&a(d).focus(),c):b},setTransition:function(b,c,d,e){return e=e||{},a.each(c,function(a,c){var f=b.cssUnit(c);f[0]>0&&(e[c]=f[0]*d+f[1])}),e}}),a.fn.extend({effect:function(b,c,d,e){var f=k.apply(this,arguments),g={options:f[1],duration:f[2],callback:f[3]},h=g.options.mode,i=a.effects[b];return a.fx.off||!i?h?this[h](g.duration,g.callback):this.each(function(){g.callback&&g.callback.call(this)}):i.call(this,g)},_show:a.fn.show,show:function(a){if(l(a))return this._show.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="show",this.effect.apply(this,b)},_hide:a.fn.hide,hide:function(a){if(l(a))return this._hide.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="hide",this.effect.apply(this,b)},__toggle:a.fn.toggle,toggle:function(b){if(l(b)||typeof b=="boolean"||a.isFunction(b))return this.__toggle.apply(this,arguments);var c=k.apply(this,arguments);return c[1].mode="toggle",this.effect.apply(this,c)},cssUnit:function(b){var c=this.css(b),d=[];return a.each(["em","px","%","pt"],function(a,b){c.indexOf(b)>0&&(d=[parseFloat(c),b])}),d}});var m={};a.each(["Quad","Cubic","Quart","Quint","Expo"],function(a,b){m[b]=function(b){return Math.pow(b,a+2)}}),a.extend(m,{Sine:function(a){return 1-Math.cos(a*Math.PI/2)},Circ:function(a){return 1-Math.sqrt(1-a*a)},Elastic:function(a){return a===0||a===1?a:-Math.pow(2,8*(a-1))*Math.sin(((a-1)*80-7.5)*Math.PI/15)},Back:function(a){return a*a*(3*a-2)},Bounce:function(a){var b,c=4;while(a<((b=Math.pow(2,--c))-1)/11);return 1/Math.pow(4,3-c)-7.5625*Math.pow((b*3-2)/22-a,2)}}),a.each(m,function(b,c){a.easing["easeIn"+b]=c,a.easing["easeOut"+b]=function(a){return 1-c(1-a)},a.easing["easeInOut"+b]=function(a){return a<.5?c(a*2)/2:c(a*-2+2)/-2+1}})}(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.blind.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.blind=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"vertical";a.effects.save(c,d),c.show();var g=a.effects.createWrapper(c).css({overflow:"hidden"}),h=f=="vertical"?"height":"width",i=f=="vertical"?g.height():g.width();e=="show"&&g.css(h,0);var j={};j[h]=e=="show"?i:0,g.animate(j,b.duration,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.bounce.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.bounce=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"effect"),f=b.options.direction||"up",g=b.options.distance||20,h=b.options.times||5,i=b.duration||250;/show|hide/.test(e)&&d.push("opacity"),a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var j=f=="up"||f=="down"?"top":"left",k=f=="up"||f=="left"?"pos":"neg",g=b.options.distance||(j=="top"?c.outerHeight(!0)/3:c.outerWidth(!0)/3);e=="show"&&c.css("opacity",0).css(j,k=="pos"?-g:g),e=="hide"&&(g=g/(h*2)),e!="hide"&&h--;if(e=="show"){var l={opacity:1};l[j]=(k=="pos"?"+=":"-=")+g,c.animate(l,i/2,b.options.easing),g=g/2,h--}for(var m=0;m<h;m++){var n={},p={};n[j]=(k=="pos"?"-=":"+=")+g,p[j]=(k=="pos"?"+=":"-=")+g,c.animate(n,i/2,b.options.easing).animate(p,i/2,b.options.easing),g=e=="hide"?g*2:g/2}if(e=="hide"){var l={opacity:0};l[j]=(k=="pos"?"-=":"+=")+g,c.animate(l,i/2,b.options.easing,function(){c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments)})}else{var n={},p={};n[j]=(k=="pos"?"-=":"+=")+g,p[j]=(k=="pos"?"+=":"-=")+g,c.animate(n,i/2,b.options.easing).animate(p,i/2,b.options.easing,function(){a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments)})}c.queue("fx",function(){c.dequeue()}),c.dequeue()})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.clip.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.clip=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right","height","width"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"vertical";a.effects.save(c,d),c.show();var g=a.effects.createWrapper(c).css({overflow:"hidden"}),h=c[0].tagName=="IMG"?g:c,i={size:f=="vertical"?"height":"width",position:f=="vertical"?"top":"left"},j=f=="vertical"?h.height():h.width();e=="show"&&(h.css(i.size,0),h.css(i.position,j/2));var k={};k[i.size]=e=="show"?j:0,k[i.position]=e=="show"?0:j/2,h.animate(k,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.drop.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.drop=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right","opacity"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"left";a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var g=f=="up"||f=="down"?"top":"left",h=f=="up"||f=="left"?"pos":"neg",i=b.options.distance||(g=="top"?c.outerHeight(!0)/2:c.outerWidth(!0)/2);e=="show"&&c.css("opacity",0).css(g,h=="pos"?-i:i);var j={opacity:e=="show"?1:0};j[g]=(e=="show"?h=="pos"?"+=":"-=":h=="pos"?"-=":"+=")+i,c.animate(j,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.explode.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.explode=function(b){return this.queue(function(){var c=b.options.pieces?Math.round(Math.sqrt(b.options.pieces)):3,d=b.options.pieces?Math.round(Math.sqrt(b.options.pieces)):3;b.options.mode=b.options.mode=="toggle"?a(this).is(":visible")?"hide":"show":b.options.mode;var e=a(this).show().css("visibility","hidden"),f=e.offset();f.top-=parseInt(e.css("marginTop"),10)||0,f.left-=parseInt(e.css("marginLeft"),10)||0;var g=e.outerWidth(!0),h=e.outerHeight(!0);for(var i=0;i<c;i++)for(var j=0;j<d;j++)e.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-j*(g/d),top:-i*(h/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:g/d,height:h/c,left:f.left+j*(g/d)+(b.options.mode=="show"?(j-Math.floor(d/2))*(g/d):0),top:f.top+i*(h/c)+(b.options.mode=="show"?(i-Math.floor(c/2))*(h/c):0),opacity:b.options.mode=="show"?0:1}).animate({left:f.left+j*(g/d)+(b.options.mode=="show"?0:(j-Math.floor(d/2))*(g/d)),top:f.top+i*(h/c)+(b.options.mode=="show"?0:(i-Math.floor(c/2))*(h/c)),opacity:b.options.mode=="show"?1:0},b.duration||500);setTimeout(function(){b.options.mode=="show"?e.css({visibility:"visible"}):e.css({visibility:"visible"}).hide(),b.callback&&b.callback.apply(e[0]),e.dequeue(),a("div.ui-effects-explode").remove()},b.duration||500)})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.fade.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.fade=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.fold.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.fold=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.size||15,g=!!b.options.horizFirst,h=b.duration?b.duration/2:a.fx.speeds._default/2;a.effects.save(c,d),c.show();var i=a.effects.createWrapper(c).css({overflow:"hidden"}),j=e=="show"!=g,k=j?["width","height"]:["height","width"],l=j?[i.width(),i.height()]:[i.height(),i.width()],m=/([0-9]+)%/.exec(f);m&&(f=parseInt(m[1],10)/100*l[e=="hide"?0:1]),e=="show"&&i.css(g?{height:0,width:f}:{height:f,width:0});var n={},p={};n[k[0]]=e=="show"?l[0]:f,p[k[1]]=e=="show"?l[1]:0,i.animate(n,h,b.options.easing).animate(p,h,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.highlight.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.highlight=function(b){return this.queue(function(){var c=a(this),d=["backgroundImage","backgroundColor","opacity"],e=a.effects.setMode(c,b.options.mode||"show"),f={backgroundColor:c.css("backgroundColor")};e=="hide"&&(f.opacity=0),a.effects.save(c,d),c.show().css({backgroundImage:"none",backgroundColor:b.options.color||"#ffff99"}).animate(f,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),e=="show"&&!a.support.opacity&&this.style.removeAttribute("filter"),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.pulsate.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.pulsate=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"show"),e=(b.options.times||5)*2-1,f=b.duration?b.duration/2:a.fx.speeds._default/2,g=c.is(":visible"),h=0;g||(c.css("opacity",0).show(),h=1),(d=="hide"&&g||d=="show"&&!g)&&e--;for(var i=0;i<e;i++)c.animate({opacity:h},f,b.options.easing),h=(h+1)%2;c.animate({opacity:h},f,b.options.easing,function(){h==0&&c.hide(),b.callback&&b.callback.apply(this,arguments)}),c.queue("fx",function(){c.dequeue()}).dequeue()})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.scale.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.puff=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"hide"),e=parseInt(b.options.percent,10)||150,f=e/100,g={height:c.height(),width:c.width()};a.extend(b.options,{fade:!0,mode:d,percent:d=="hide"?e:100,from:d=="hide"?g:{height:g.height*f,width:g.width*f}}),c.effect("scale",b.options,b.duration,b.callback),c.dequeue()})},a.effects.scale=function(b){return this.queue(function(){var c=a(this),d=a.extend(!0,{},b.options),e=a.effects.setMode(c,b.options.mode||"effect"),f=parseInt(b.options.percent,10)||(parseInt(b.options.percent,10)==0?0:e=="hide"?0:100),g=b.options.direction||"both",h=b.options.origin;e!="effect"&&(d.origin=h||["middle","center"],d.restore=!0);var i={height:c.height(),width:c.width()};c.from=b.options.from||(e=="show"?{height:0,width:0}:i);var j={y:g!="horizontal"?f/100:1,x:g!="vertical"?f/100:1};c.to={height:i.height*j.y,width:i.width*j.x},b.options.fade&&(e=="show"&&(c.from.opacity=0,c.to.opacity=1),e=="hide"&&(c.from.opacity=1,c.to.opacity=0)),d.from=c.from,d.to=c.to,d.mode=e,c.effect("size",d,b.duration,b.callback),c.dequeue()})},a.effects.size=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right","width","height","overflow","opacity"],e=["position","top","bottom","left","right","overflow","opacity"],f=["width","height","overflow"],g=["fontSize"],h=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],i=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],j=a.effects.setMode(c,b.options.mode||"effect"),k=b.options.restore||!1,l=b.options.scale||"both",m=b.options.origin,n={height:c.height(),width:c.width()};c.from=b.options.from||n,c.to=b.options.to||n;if(m){var p=a.effects.getBaseline(m,n);c.from.top=(n.height-c.from.height)*p.y,c.from.left=(n.width-c.from.width)*p.x,c.to.top=(n.height-c.to.height)*p.y,c.to.left=(n.width-c.to.width)*p.x}var q={from:{y:c.from.height/n.height,x:c.from.width/n.width},to:{y:c.to.height/n.height,x:c.to.width/n.width}};if(l=="box"||l=="both")q.from.y!=q.to.y&&(d=d.concat(h),c.from=a.effects.setTransition(c,h,q.from.y,c.from),c.to=a.effects.setTransition(c,h,q.to.y,c.to)),q.from.x!=q.to.x&&(d=d.concat(i),c.from=a.effects.setTransition(c,i,q.from.x,c.from),c.to=a.effects.setTransition(c,i,q.to.x,c.to));(l=="content"||l=="both")&&q.from.y!=q.to.y&&(d=d.concat(g),c.from=a.effects.setTransition(c,g,q.from.y,c.from),c.to=a.effects.setTransition(c,g,q.to.y,c.to)),a.effects.save(c,k?d:e),c.show(),a.effects.createWrapper(c),c.css("overflow","hidden").css(c.from);if(l=="content"||l=="both")h=h.concat(["marginTop","marginBottom"]).concat(g),i=i.concat(["marginLeft","marginRight"]),f=d.concat(h).concat(i),c.find("*[width]").each(function(){var c=a(this);k&&a.effects.save(c,f);var d={height:c.height(),width:c.width()};c.from={height:d.height*q.from.y,width:d.width*q.from.x},c.to={height:d.height*q.to.y,width:d.width*q.to.x},q.from.y!=q.to.y&&(c.from=a.effects.setTransition(c,h,q.from.y,c.from),c.to=a.effects.setTransition(c,h,q.to.y,c.to)),q.from.x!=q.to.x&&(c.from=a.effects.setTransition(c,i,q.from.x,c.from),c.to=a.effects.setTransition(c,i,q.to.x,c.to)),c.css(c.from),c.animate(c.to,b.duration,b.options.easing,function(){k&&a.effects.restore(c,f)})});c.animate(c.to,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){c.to.opacity===0&&c.css("opacity",c.from.opacity),j=="hide"&&c.hide(),a.effects.restore(c,k?d:e),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.shake.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.shake=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"effect"),f=b.options.direction||"left",g=b.options.distance||20,h=b.options.times||3,i=b.duration||b.options.duration||140;a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var j=f=="up"||f=="down"?"top":"left",k=f=="up"||f=="left"?"pos":"neg",l={},m={},n={};l[j]=(k=="pos"?"-=":"+=")+g,m[j]=(k=="pos"?"+=":"-=")+g*2,n[j]=(k=="pos"?"-=":"+=")+g*2,c.animate(l,i,b.options.easing);for(var p=1;p<h;p++)c.animate(m,i,b.options.easing).animate(n,i,b.options.easing);c.animate(m,i,b.options.easing).animate(l,i/2,b.options.easing,function(){a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments)}),c.queue("fx",function(){c.dequeue()}),c.dequeue()})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.slide.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.slide=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"show"),f=b.options.direction||"left";a.effects.save(c,d),c.show(),a.effects.createWrapper(c).css({overflow:"hidden"});var g=f=="up"||f=="down"?"top":"left",h=f=="up"||f=="left"?"pos":"neg",i=b.options.distance||(g=="top"?c.outerHeight(!0):c.outerWidth(!0));e=="show"&&c.css(g,h=="pos"?isNaN(i)?"-"+i:-i:i);var j={};j[g]=(e=="show"?h=="pos"?"+=":"-=":h=="pos"?"-=":"+=")+i,c.animate(j,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.24 - 2012-09-28 | |
* https://github.com/jquery/jquery-ui | |
* Includes: jquery.effects.transfer.js | |
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ | |
(function(a,b){a.effects.transfer=function(b){return this.queue(function(){var c=a(this),d=a(b.options.to),e=d.offset(),f={top:e.top,left:e.left,height:d.innerHeight(),width:d.innerWidth()},g=c.offset(),h=a('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(b.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(f,b.duration,b.options.easing,function(){h.remove(),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);; |
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
// | |
// LESS - Leaner CSS v1.3.0 | |
// http://lesscss.org | |
// | |
// Copyright (c) 2009-2011, Alexis Sellier | |
// Licensed under the Apache 2.0 License. | |
// | |
(function (window, undefined) { | |
// | |
// Stub out `require` in the browser | |
// | |
function require(arg) { | |
return window.less[arg.split('/')[1]]; | |
}; | |
// amd.js | |
// | |
// Define Less as an AMD module. | |
if (typeof define === "function" && define.amd) { | |
define("less", [], function () { return less; } ); | |
} | |
// ecma-5.js | |
// | |
// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License | |
// -- tlrobinson Tom Robinson | |
// dantman Daniel Friesen | |
// | |
// Array | |
// | |
if (!Array.isArray) { | |
Array.isArray = function(obj) { | |
return Object.prototype.toString.call(obj) === "[object Array]" || | |
(obj instanceof Array); | |
}; | |
} | |
if (!Array.prototype.forEach) { | |
Array.prototype.forEach = function(block, thisObject) { | |
var len = this.length >>> 0; | |
for (var i = 0; i < len; i++) { | |
if (i in this) { | |
block.call(thisObject, this[i], i, this); | |
} | |
} | |
}; | |
} | |
if (!Array.prototype.map) { | |
Array.prototype.map = function(fun /*, thisp*/) { | |
var len = this.length >>> 0; | |
var res = new Array(len); | |
var thisp = arguments[1]; | |
for (var i = 0; i < len; i++) { | |
if (i in this) { | |
res[i] = fun.call(thisp, this[i], i, this); | |
} | |
} | |
return res; | |
}; | |
} | |
if (!Array.prototype.filter) { | |
Array.prototype.filter = function (block /*, thisp */) { | |
var values = []; | |
var thisp = arguments[1]; | |
for (var i = 0; i < this.length; i++) { | |
if (block.call(thisp, this[i])) { | |
values.push(this[i]); | |
} | |
} | |
return values; | |
}; | |
} | |
if (!Array.prototype.reduce) { | |
Array.prototype.reduce = function(fun /*, initial*/) { | |
var len = this.length >>> 0; | |
var i = 0; | |
// no value to return if no initial value and an empty array | |
if (len === 0 && arguments.length === 1) throw new TypeError(); | |
if (arguments.length >= 2) { | |
var rv = arguments[1]; | |
} else { | |
do { | |
if (i in this) { | |
rv = this[i++]; | |
break; | |
} | |
// if array contains no values, no initial value to return | |
if (++i >= len) throw new TypeError(); | |
} while (true); | |
} | |
for (; i < len; i++) { | |
if (i in this) { | |
rv = fun.call(null, rv, this[i], i, this); | |
} | |
} | |
return rv; | |
}; | |
} | |
if (!Array.prototype.indexOf) { | |
Array.prototype.indexOf = function (value /*, fromIndex */ ) { | |
var length = this.length; | |
var i = arguments[1] || 0; | |
if (!length) return -1; | |
if (i >= length) return -1; | |
if (i < 0) i += length; | |
for (; i < length; i++) { | |
if (!Object.prototype.hasOwnProperty.call(this, i)) { continue } | |
if (value === this[i]) return i; | |
} | |
return -1; | |
}; | |
} | |
// | |
// Object | |
// | |
if (!Object.keys) { | |
Object.keys = function (object) { | |
var keys = []; | |
for (var name in object) { | |
if (Object.prototype.hasOwnProperty.call(object, name)) { | |
keys.push(name); | |
} | |
} | |
return keys; | |
}; | |
} | |
// | |
// String | |
// | |
if (!String.prototype.trim) { | |
String.prototype.trim = function () { | |
return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, ''); | |
}; | |
} | |
var less, tree; | |
if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") { | |
// Rhino | |
// Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88 | |
if (typeof(window) === 'undefined') { less = {} } | |
else { less = window.less = {} } | |
tree = less.tree = {}; | |
less.mode = 'rhino'; | |
} else if (typeof(window) === 'undefined') { | |
// Node.js | |
less = exports, | |
tree = require('./tree'); | |
less.mode = 'node'; | |
} else { | |
// Browser | |
if (typeof(window.less) === 'undefined') { window.less = {} } | |
less = window.less, | |
tree = window.less.tree = {}; | |
less.mode = 'browser'; | |
} | |
// | |
// less.js - parser | |
// | |
// A relatively straight-forward predictive parser. | |
// There is no tokenization/lexing stage, the input is parsed | |
// in one sweep. | |
// | |
// To make the parser fast enough to run in the browser, several | |
// optimization had to be made: | |
// | |
// - Matching and slicing on a huge input is often cause of slowdowns. | |
// The solution is to chunkify the input into smaller strings. | |
// The chunks are stored in the `chunks` var, | |
// `j` holds the current chunk index, and `current` holds | |
// the index of the current chunk in relation to `input`. | |
// This gives us an almost 4x speed-up. | |
// | |
// - In many cases, we don't need to match individual tokens; | |
// for example, if a value doesn't hold any variables, operations | |
// or dynamic references, the parser can effectively 'skip' it, | |
// treating it as a literal. | |
// An example would be '1px solid #000' - which evaluates to itself, | |
// we don't need to know what the individual components are. | |
// The drawback, of course is that you don't get the benefits of | |
// syntax-checking on the CSS. This gives us a 50% speed-up in the parser, | |
// and a smaller speed-up in the code-gen. | |
// | |
// | |
// Token matching is done with the `$` function, which either takes | |
// a terminal string or regexp, or a non-terminal function to call. | |
// It also takes care of moving all the indices forwards. | |
// | |
// | |
less.Parser = function Parser(env) { | |
var input, // LeSS input string | |
i, // current index in `input` | |
j, // current chunk | |
temp, // temporarily holds a chunk's state, for backtracking | |
memo, // temporarily holds `i`, when backtracking | |
furthest, // furthest index the parser has gone to | |
chunks, // chunkified input | |
current, // index of current chunk, in `input` | |
parser; | |
var that = this; | |
// This function is called after all files | |
// have been imported through `@import`. | |
var finish = function () {}; | |
var imports = this.imports = { | |
paths: env && env.paths || [], // Search paths, when importing | |
queue: [], // Files which haven't been imported yet | |
files: {}, // Holds the imported parse trees | |
contents: {}, // Holds the imported file contents | |
mime: env && env.mime, // MIME type of .less files | |
error: null, // Error in parsing/evaluating an import | |
push: function (path, callback) { | |
var that = this; | |
this.queue.push(path); | |
// | |
// Import a file asynchronously | |
// | |
less.Parser.importer(path, this.paths, function (e, root, contents) { | |
that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue | |
that.files[path] = root; // Store the root | |
that.contents[path] = contents; | |
if (e && !that.error) { that.error = e } | |
callback(e, root); | |
if (that.queue.length === 0) { finish() } // Call `finish` if we're done importing | |
}, env); | |
} | |
}; | |
function save() { temp = chunks[j], memo = i, current = i } | |
function restore() { chunks[j] = temp, i = memo, current = i } | |
function sync() { | |
if (i > current) { | |
chunks[j] = chunks[j].slice(i - current); | |
current = i; | |
} | |
} | |
// | |
// Parse from a token, regexp or string, and move forward if match | |
// | |
function $(tok) { | |
var match, args, length, c, index, endIndex, k, mem; | |
// | |
// Non-terminal | |
// | |
if (tok instanceof Function) { | |
return tok.call(parser.parsers); | |
// | |
// Terminal | |
// | |
// Either match a single character in the input, | |
// or match a regexp in the current chunk (chunk[j]). | |
// | |
} else if (typeof(tok) === 'string') { | |
match = input.charAt(i) === tok ? tok : null; | |
length = 1; | |
sync (); | |
} else { | |
sync (); | |
if (match = tok.exec(chunks[j])) { | |
length = match[0].length; | |
} else { | |
return null; | |
} | |
} | |
// The match is confirmed, add the match length to `i`, | |
// and consume any extra white-space characters (' ' || '\n') | |
// which come after that. The reason for this is that LeSS's | |
// grammar is mostly white-space insensitive. | |
// | |
if (match) { | |
mem = i += length; | |
endIndex = i + chunks[j].length - length; | |
while (i < endIndex) { | |
c = input.charCodeAt(i); | |
if (! (c === 32 || c === 10 || c === 9)) { break } | |
i++; | |
} | |
chunks[j] = chunks[j].slice(length + (i - mem)); | |
current = i; | |
if (chunks[j].length === 0 && j < chunks.length - 1) { j++ } | |
if(typeof(match) === 'string') { | |
return match; | |
} else { | |
return match.length === 1 ? match[0] : match; | |
} | |
} | |
} | |
function expect(arg, msg) { | |
var result = $(arg); | |
if (! result) { | |
error(msg || (typeof(arg) === 'string' ? "expected '" + arg + "' got '" + input.charAt(i) + "'" | |
: "unexpected token")); | |
} else { | |
return result; | |
} | |
} | |
function error(msg, type) { | |
throw { index: i, type: type || 'Syntax', message: msg }; | |
} | |
// Same as $(), but don't change the state of the parser, | |
// just return the match. | |
function peek(tok) { | |
if (typeof(tok) === 'string') { | |
return input.charAt(i) === tok; | |
} else { | |
if (tok.test(chunks[j])) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} | |
function basename(pathname) { | |
if (less.mode === 'node') { | |
return require('path').basename(pathname); | |
} else { | |
return pathname.match(/[^\/]+$/)[0]; | |
} | |
} | |
function getInput(e, env) { | |
if (e.filename && env.filename && (e.filename !== env.filename)) { | |
return parser.imports.contents[basename(e.filename)]; | |
} else { | |
return input; | |
} | |
} | |
function getLocation(index, input) { | |
for (var n = index, column = -1; | |
n >= 0 && input.charAt(n) !== '\n'; | |
n--) { column++ } | |
return { line: typeof(index) === 'number' ? (input.slice(0, index).match(/\n/g) || "").length : null, | |
column: column }; | |
} | |
function LessError(e, env) { | |
var input = getInput(e, env), | |
loc = getLocation(e.index, input), | |
line = loc.line, | |
col = loc.column, | |
lines = input.split('\n'); | |
this.type = e.type || 'Syntax'; | |
this.message = e.message; | |
this.filename = e.filename || env.filename; | |
this.index = e.index; | |
this.line = typeof(line) === 'number' ? line + 1 : null; | |
this.callLine = e.call && (getLocation(e.call, input).line + 1); | |
this.callExtract = lines[getLocation(e.call, input).line]; | |
this.stack = e.stack; | |
this.column = col; | |
this.extract = [ | |
lines[line - 1], | |
lines[line], | |
lines[line + 1] | |
]; | |
} | |
this.env = env = env || {}; | |
// The optimization level dictates the thoroughness of the parser, | |
// the lower the number, the less nodes it will create in the tree. | |
// This could matter for debugging, or if you want to access | |
// the individual nodes in the tree. | |
this.optimization = ('optimization' in this.env) ? this.env.optimization : 1; | |
this.env.filename = this.env.filename || null; | |
// | |
// The Parser | |
// | |
return parser = { | |
imports: imports, | |
// | |
// Parse an input string into an abstract syntax tree, | |
// call `callback` when done. | |
// | |
parse: function (str, callback) { | |
var root, start, end, zone, line, lines, buff = [], c, error = null; | |
i = j = current = furthest = 0; | |
input = str.replace(/\r\n/g, '\n'); | |
// Split the input into chunks. | |
chunks = (function (chunks) { | |
var j = 0, | |
skip = /[^"'`\{\}\/\(\)\\]+/g, | |
comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g, | |
string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`\\\r\n]|\\.)*)`/g, | |
level = 0, | |
match, | |
chunk = chunks[0], | |
inParam; | |
for (var i = 0, c, cc; i < input.length; i++) { | |
skip.lastIndex = i; | |
if (match = skip.exec(input)) { | |
if (match.index === i) { | |
i += match[0].length; | |
chunk.push(match[0]); | |
} | |
} | |
c = input.charAt(i); | |
comment.lastIndex = string.lastIndex = i; | |
if (match = string.exec(input)) { | |
if (match.index === i) { | |
i += match[0].length; | |
chunk.push(match[0]); | |
c = input.charAt(i); | |
} | |
} | |
if (!inParam && c === '/') { | |
cc = input.charAt(i + 1); | |
if (cc === '/' || cc === '*') { | |
if (match = comment.exec(input)) { | |
if (match.index === i) { | |
i += match[0].length; | |
chunk.push(match[0]); | |
c = input.charAt(i); | |
} | |
} | |
} | |
} | |
switch (c) { | |
case '{': if (! inParam) { level ++; chunk.push(c); break } | |
case '}': if (! inParam) { level --; chunk.push(c); chunks[++j] = chunk = []; break } | |
case '(': if (! inParam) { inParam = true; chunk.push(c); break } | |
case ')': if ( inParam) { inParam = false; chunk.push(c); break } | |
default: chunk.push(c); | |
} | |
} | |
if (level > 0) { | |
error = new(LessError)({ | |
index: i, | |
type: 'Parse', | |
message: "missing closing `}`", | |
filename: env.filename | |
}, env); | |
} | |
return chunks.map(function (c) { return c.join('') });; | |
})([[]]); | |
if (error) { | |
return callback(error); | |
} | |
// Start with the primary rule. | |
// The whole syntax tree is held under a Ruleset node, | |
// with the `root` property set to true, so no `{}` are | |
// output. The callback is called when the input is parsed. | |
try { | |
root = new(tree.Ruleset)([], $(this.parsers.primary)); | |
root.root = true; | |
} catch (e) { | |
return callback(new(LessError)(e, env)); | |
} | |
root.toCSS = (function (evaluate) { | |
var line, lines, column; | |
return function (options, variables) { | |
var frames = [], importError; | |
options = options || {}; | |
// | |
// Allows setting variables with a hash, so: | |
// | |
// `{ color: new(tree.Color)('#f01') }` will become: | |
// | |
// new(tree.Rule)('@color', | |
// new(tree.Value)([ | |
// new(tree.Expression)([ | |
// new(tree.Color)('#f01') | |
// ]) | |
// ]) | |
// ) | |
// | |
if (typeof(variables) === 'object' && !Array.isArray(variables)) { | |
variables = Object.keys(variables).map(function (k) { | |
var value = variables[k]; | |
if (! (value instanceof tree.Value)) { | |
if (! (value instanceof tree.Expression)) { | |
value = new(tree.Expression)([value]); | |
} | |
value = new(tree.Value)([value]); | |
} | |
return new(tree.Rule)('@' + k, value, false, 0); | |
}); | |
frames = [new(tree.Ruleset)(null, variables)]; | |
} | |
try { | |
var css = evaluate.call(this, { frames: frames }) | |
.toCSS([], { compress: options.compress || false }); | |
} catch (e) { | |
throw new(LessError)(e, env); | |
} | |
if ((importError = parser.imports.error)) { // Check if there was an error during importing | |
if (importError instanceof LessError) throw importError; | |
else throw new(LessError)(importError, env); | |
} | |
if (options.yuicompress && less.mode === 'node') { | |
return require('./cssmin').compressor.cssmin(css); | |
} else if (options.compress) { | |
return css.replace(/(\s)+/g, "$1"); | |
} else { | |
return css; | |
} | |
}; | |
})(root.eval); | |
// If `i` is smaller than the `input.length - 1`, | |
// it means the parser wasn't able to parse the whole | |
// string, so we've got a parsing error. | |
// | |
// We try to extract a \n delimited string, | |
// showing the line where the parse error occured. | |
// We split it up into two parts (the part which parsed, | |
// and the part which didn't), so we can color them differently. | |
if (i < input.length - 1) { | |
i = furthest; | |
lines = input.split('\n'); | |
line = (input.slice(0, i).match(/\n/g) || "").length + 1; | |
for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ } | |
error = { | |
type: "Parse", | |
message: "Syntax Error on line " + line, | |
index: i, | |
filename: env.filename, | |
line: line, | |
column: column, | |
extract: [ | |
lines[line - 2], | |
lines[line - 1], | |
lines[line] | |
] | |
}; | |
} | |
if (this.imports.queue.length > 0) { | |
finish = function () { callback(error, root) }; | |
} else { | |
callback(error, root); | |
} | |
}, | |
// | |
// Here in, the parsing rules/functions | |
// | |
// The basic structure of the syntax tree generated is as follows: | |
// | |
// Ruleset -> Rule -> Value -> Expression -> Entity | |
// | |
// Here's some LESS code: | |
// | |
// .class { | |
// color: #fff; | |
// border: 1px solid #000; | |
// width: @w + 4px; | |
// > .child {...} | |
// } | |
// | |
// And here's what the parse tree might look like: | |
// | |
// Ruleset (Selector '.class', [ | |
// Rule ("color", Value ([Expression [Color #fff]])) | |
// Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]])) | |
// Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]])) | |
// Ruleset (Selector [Element '>', '.child'], [...]) | |
// ]) | |
// | |
// In general, most rules will try to parse a token with the `$()` function, and if the return | |
// value is truly, will return a new node, of the relevant type. Sometimes, we need to check | |
// first, before parsing, that's when we use `peek()`. | |
// | |
parsers: { | |
// | |
// The `primary` rule is the *entry* and *exit* point of the parser. | |
// The rules here can appear at any level of the parse tree. | |
// | |
// The recursive nature of the grammar is an interplay between the `block` | |
// rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, | |
// as represented by this simplified grammar: | |
// | |
// primary → (ruleset | rule)+ | |
// ruleset → selector+ block | |
// block → '{' primary '}' | |
// | |
// Only at one point is the primary rule not called from the | |
// block rule: at the root level. | |
// | |
primary: function () { | |
var node, root = []; | |
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) || | |
$(this.mixin.call) || $(this.comment) || $(this.directive)) | |
|| $(/^[\s\n]+/)) { | |
node && root.push(node); | |
} | |
return root; | |
}, | |
// We create a Comment node for CSS comments `/* */`, | |
// but keep the LeSS comments `//` silent, by just skipping | |
// over them. | |
comment: function () { | |
var comment; | |
if (input.charAt(i) !== '/') return; | |
if (input.charAt(i + 1) === '/') { | |
return new(tree.Comment)($(/^\/\/.*/), true); | |
} else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) { | |
return new(tree.Comment)(comment); | |
} | |
}, | |
// | |
// Entities are tokens which can be found inside an Expression | |
// | |
entities: { | |
// | |
// A string, which supports escaping " and ' | |
// | |
// "milky way" 'he\'s the one!' | |
// | |
quoted: function () { | |
var str, j = i, e; | |
if (input.charAt(j) === '~') { j++, e = true } // Escaped strings | |
if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return; | |
e && $('~'); | |
if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) { | |
return new(tree.Quoted)(str[0], str[1] || str[2], e); | |
} | |
}, | |
// | |
// A catch-all word, such as: | |
// | |
// black border-collapse | |
// | |
keyword: function () { | |
var k; | |
if (k = $(/^[_A-Za-z-][_A-Za-z0-9-]*/)) { | |
if (tree.colors.hasOwnProperty(k)) { | |
// detect named color | |
return new(tree.Color)(tree.colors[k].slice(1)); | |
} else { | |
return new(tree.Keyword)(k); | |
} | |
} | |
}, | |
// | |
// A function call | |
// | |
// rgb(255, 0, 255) | |
// | |
// We also try to catch IE's `alpha()`, but let the `alpha` parser | |
// deal with the details. | |
// | |
// The arguments are parsed with the `entities.arguments` parser. | |
// | |
call: function () { | |
var name, args, index = i; | |
if (! (name = /^([\w-]+|%|progid:[\w\.]+)\(/.exec(chunks[j]))) return; | |
name = name[1].toLowerCase(); | |
if (name === 'url') { return null } | |
else { i += name.length } | |
if (name === 'alpha') { return $(this.alpha) } | |
$('('); // Parse the '(' and consume whitespace. | |
args = $(this.entities.arguments); | |
if (! $(')')) return; | |
if (name) { return new(tree.Call)(name, args, index, env.filename) } | |
}, | |
arguments: function () { | |
var args = [], arg; | |
while (arg = $(this.entities.assignment) || $(this.expression)) { | |
args.push(arg); | |
if (! $(',')) { break } | |
} | |
return args; | |
}, | |
literal: function () { | |
return $(this.entities.dimension) || | |
$(this.entities.color) || | |
$(this.entities.quoted); | |
}, | |
// Assignments are argument entities for calls. | |
// They are present in ie filter properties as shown below. | |
// | |
// filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* ) | |
// | |
assignment: function () { | |
var key, value; | |
if ((key = $(/^\w+(?=\s?=)/i)) && $('=') && (value = $(this.entity))) { | |
return new(tree.Assignment)(key, value); | |
} | |
}, | |
// | |
// Parse url() tokens | |
// | |
// We use a specific rule for urls, because they don't really behave like | |
// standard function calls. The difference is that the argument doesn't have | |
// to be enclosed within a string, so it can't be parsed as an Expression. | |
// | |
url: function () { | |
var value; | |
if (input.charAt(i) !== 'u' || !$(/^url\(/)) return; | |
value = $(this.entities.quoted) || $(this.entities.variable) || | |
$(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || ""; | |
expect(')'); | |
return new(tree.URL)((value.value || value.data || value instanceof tree.Variable) | |
? value : new(tree.Anonymous)(value), imports.paths); | |
}, | |
dataURI: function () { | |
var obj; | |
if ($(/^data:/)) { | |
obj = {}; | |
obj.mime = $(/^[^\/]+\/[^,;)]+/) || ''; | |
obj.charset = $(/^;\s*charset=[^,;)]+/) || ''; | |
obj.base64 = $(/^;\s*base64/) || ''; | |
obj.data = $(/^,\s*[^)]+/); | |
if (obj.data) { return obj } | |
} | |
}, | |
// | |
// A Variable entity, such as `@fink`, in | |
// | |
// width: @fink + 2px | |
// | |
// We use a different parser for variable definitions, | |
// see `parsers.variable`. | |
// | |
variable: function () { | |
var name, index = i; | |
if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) { | |
return new(tree.Variable)(name, index, env.filename); | |
} | |
}, | |
// | |
// A Hexadecimal color | |
// | |
// #4F3C2F | |
// | |
// `rgb` and `hsl` colors are parsed through the `entities.call` parser. | |
// | |
color: function () { | |
var rgb; | |
if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) { | |
return new(tree.Color)(rgb[1]); | |
} | |
}, | |
// | |
// A Dimension, that is, a number and a unit | |
// | |
// 0.5em 95% | |
// | |
dimension: function () { | |
var value, c = input.charCodeAt(i); | |
if ((c > 57 || c < 45) || c === 47) return; | |
if (value = $(/^(-?\d*\.?\d+)(px|%|em|rem|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/)) { | |
return new(tree.Dimension)(value[1], value[2]); | |
} | |
}, | |
// | |
// JavaScript code to be evaluated | |
// | |
// `window.location.href` | |
// | |
javascript: function () { | |
var str, j = i, e; | |
if (input.charAt(j) === '~') { j++, e = true } // Escaped strings | |
if (input.charAt(j) !== '`') { return } | |
e && $('~'); | |
if (str = $(/^`([^`]*)`/)) { | |
return new(tree.JavaScript)(str[1], i, e); | |
} | |
} | |
}, | |
// | |
// The variable part of a variable definition. Used in the `rule` parser | |
// | |
// @fink: | |
// | |
variable: function () { | |
var name; | |
if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] } | |
}, | |
// | |
// A font size/line-height shorthand | |
// | |
// small/12px | |
// | |
// We need to peek first, or we'll match on keywords and dimensions | |
// | |
shorthand: function () { | |
var a, b; | |
if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return; | |
if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) { | |
return new(tree.Shorthand)(a, b); | |
} | |
}, | |
// | |
// Mixins | |
// | |
mixin: { | |
// | |
// A Mixin call, with an optional argument list | |
// | |
// #mixins > .square(#fff); | |
// .rounded(4px, black); | |
// .button; | |
// | |
// The `while` loop is there because mixins can be | |
// namespaced, but we only support the child and descendant | |
// selector for now. | |
// | |
call: function () { | |
var elements = [], e, c, args, index = i, s = input.charAt(i), important = false; | |
if (s !== '.' && s !== '#') { return } | |
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) { | |
elements.push(new(tree.Element)(c, e, i)); | |
c = $('>'); | |
} | |
$('(') && (args = $(this.entities.arguments)) && $(')'); | |
if ($(this.important)) { | |
important = true; | |
} | |
if (elements.length > 0 && ($(';') || peek('}'))) { | |
return new(tree.mixin.Call)(elements, args || [], index, env.filename, important); | |
} | |
}, | |
// | |
// A Mixin definition, with a list of parameters | |
// | |
// .rounded (@radius: 2px, @color) { | |
// ... | |
// } | |
// | |
// Until we have a finer grained state-machine, we have to | |
// do a look-ahead, to make sure we don't have a mixin call. | |
// See the `rule` function for more information. | |
// | |
// We start by matching `.rounded (`, and then proceed on to | |
// the argument list, which has optional default values. | |
// We store the parameters in `params`, with a `value` key, | |
// if there is a value, such as in the case of `@radius`. | |
// | |
// Once we've got our params list, and a closing `)`, we parse | |
// the `{...}` block. | |
// | |
definition: function () { | |
var name, params = [], match, ruleset, param, value, cond, variadic = false; | |
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') || | |
peek(/^[^{]*(;|})/)) return; | |
save(); | |
if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) { | |
name = match[1]; | |
do { | |
if (input.charAt(i) === '.' && $(/^\.{3}/)) { | |
variadic = true; | |
break; | |
} else if (param = $(this.entities.variable) || $(this.entities.literal) | |
|| $(this.entities.keyword)) { | |
// Variable | |
if (param instanceof tree.Variable) { | |
if ($(':')) { | |
value = expect(this.expression, 'expected expression'); | |
params.push({ name: param.name, value: value }); | |
} else if ($(/^\.{3}/)) { | |
params.push({ name: param.name, variadic: true }); | |
variadic = true; | |
break; | |
} else { | |
params.push({ name: param.name }); | |
} | |
} else { | |
params.push({ value: param }); | |
} | |
} else { | |
break; | |
} | |
} while ($(',')) | |
expect(')'); | |
if ($(/^when/)) { // Guard | |
cond = expect(this.conditions, 'expected condition'); | |
} | |
ruleset = $(this.block); | |
if (ruleset) { | |
return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic); | |
} else { | |
restore(); | |
} | |
} | |
} | |
}, | |
// | |
// Entities are the smallest recognized token, | |
// and can be found inside a rule's value. | |
// | |
entity: function () { | |
return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) || | |
$(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) || | |
$(this.comment); | |
}, | |
// | |
// A Rule terminator. Note that we use `peek()` to check for '}', | |
// because the `block` rule will be expecting it, but we still need to make sure | |
// it's there, if ';' was ommitted. | |
// | |
end: function () { | |
return $(';') || peek('}'); | |
}, | |
// | |
// IE's alpha function | |
// | |
// alpha(opacity=88) | |
// | |
alpha: function () { | |
var value; | |
if (! $(/^\(opacity=/i)) return; | |
if (value = $(/^\d+/) || $(this.entities.variable)) { | |
expect(')'); | |
return new(tree.Alpha)(value); | |
} | |
}, | |
// | |
// A Selector Element | |
// | |
// div | |
// + h1 | |
// #socks | |
// input[type="text"] | |
// | |
// Elements are the building blocks for Selectors, | |
// they are made out of a `Combinator` (see combinator rule), | |
// and an element name, such as a tag a class, or `*`. | |
// | |
element: function () { | |
var e, t, c, v; | |
c = $(this.combinator); | |
e = $(/^(?:\d+\.\d+|\d+)%/) || $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || | |
$('*') || $(this.attribute) || $(/^\([^)@]+\)/); | |
if (! e) { | |
$('(') && (v = $(this.entities.variable)) && $(')') && (e = new(tree.Paren)(v)); | |
} | |
if (e) { return new(tree.Element)(c, e, i) } | |
if (c.value && c.value.charAt(0) === '&') { | |
return new(tree.Element)(c, null, i); | |
} | |
}, | |
// | |
// Combinators combine elements together, in a Selector. | |
// | |
// Because our parser isn't white-space sensitive, special care | |
// has to be taken, when parsing the descendant combinator, ` `, | |
// as it's an empty space. We have to check the previous character | |
// in the input, to see if it's a ` ` character. More info on how | |
// we deal with this in *combinator.js*. | |
// | |
combinator: function () { | |
var match, c = input.charAt(i); | |
if (c === '>' || c === '+' || c === '~') { | |
i++; | |
while (input.charAt(i) === ' ') { i++ } | |
return new(tree.Combinator)(c); | |
} else if (c === '&') { | |
match = '&'; | |
i++; | |
if(input.charAt(i) === ' ') { | |
match = '& '; | |
} | |
while (input.charAt(i) === ' ') { i++ } | |
return new(tree.Combinator)(match); | |
} else if (input.charAt(i - 1) === ' ') { | |
return new(tree.Combinator)(" "); | |
} else { | |
return new(tree.Combinator)(null); | |
} | |
}, | |
// | |
// A CSS Selector | |
// | |
// .class > div + h1 | |
// li a:hover | |
// | |
// Selectors are made out of one or more Elements, see above. | |
// | |
selector: function () { | |
var sel, e, elements = [], c, match; | |
if ($('(')) { | |
sel = $(this.entity); | |
expect(')'); | |
return new(tree.Selector)([new(tree.Element)('', sel, i)]); | |
} | |
while (e = $(this.element)) { | |
c = input.charAt(i); | |
elements.push(e) | |
if (c === '{' || c === '}' || c === ';' || c === ',') { break } | |
} | |
if (elements.length > 0) { return new(tree.Selector)(elements) } | |
}, | |
tag: function () { | |
return $(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || $('*'); | |
}, | |
attribute: function () { | |
var attr = '', key, val, op; | |
if (! $('[')) return; | |
if (key = $(/^[a-zA-Z-]+/) || $(this.entities.quoted)) { | |
if ((op = $(/^[|~*$^]?=/)) && | |
(val = $(this.entities.quoted) || $(/^[\w-]+/))) { | |
attr = [key, op, val.toCSS ? val.toCSS() : val].join(''); | |
} else { attr = key } | |
} | |
if (! $(']')) return; | |
if (attr) { return "[" + attr + "]" } | |
}, | |
// | |
// The `block` rule is used by `ruleset` and `mixin.definition`. | |
// It's a wrapper around the `primary` rule, with added `{}`. | |
// | |
block: function () { | |
var content; | |
if ($('{') && (content = $(this.primary)) && $('}')) { | |
return content; | |
} | |
}, | |
// | |
// div, .class, body > p {...} | |
// | |
ruleset: function () { | |
var selectors = [], s, rules, match; | |
save(); | |
while (s = $(this.selector)) { | |
selectors.push(s); | |
$(this.comment); | |
if (! $(',')) { break } | |
$(this.comment); | |
} | |
if (selectors.length > 0 && (rules = $(this.block))) { | |
return new(tree.Ruleset)(selectors, rules, env.strictImports); | |
} else { | |
// Backtrack | |
furthest = i; | |
restore(); | |
} | |
}, | |
rule: function () { | |
var name, value, c = input.charAt(i), important, match; | |
save(); | |
if (c === '.' || c === '#' || c === '&') { return } | |
if (name = $(this.variable) || $(this.property)) { | |
if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) { | |
i += match[0].length - 1; | |
value = new(tree.Anonymous)(match[1]); | |
} else if (name === "font") { | |
value = $(this.font); | |
} else { | |
value = $(this.value); | |
} | |
important = $(this.important); | |
if (value && $(this.end)) { | |
return new(tree.Rule)(name, value, important, memo); | |
} else { | |
furthest = i; | |
restore(); | |
} | |
} | |
}, | |
// | |
// An @import directive | |
// | |
// @import "lib"; | |
// | |
// Depending on our environemnt, importing is done differently: | |
// In the browser, it's an XHR request, in Node, it would be a | |
// file-system operation. The function used for importing is | |
// stored in `import`, which we pass to the Import constructor. | |
// | |
"import": function () { | |
var path, features, index = i; | |
if ($(/^@import\s+/) && | |
(path = $(this.entities.quoted) || $(this.entities.url))) { | |
features = $(this.mediaFeatures); | |
if ($(';')) { | |
return new(tree.Import)(path, imports, features, index); | |
} | |
} | |
}, | |
mediaFeature: function () { | |
var e, p, nodes = []; | |
do { | |
if (e = $(this.entities.keyword)) { | |
nodes.push(e); | |
} else if ($('(')) { | |
p = $(this.property); | |
e = $(this.entity); | |
if ($(')')) { | |
if (p && e) { | |
nodes.push(new(tree.Paren)(new(tree.Rule)(p, e, null, i, true))); | |
} else if (e) { | |
nodes.push(new(tree.Paren)(e)); | |
} else { | |
return null; | |
} | |
} else { return null } | |
} | |
} while (e); | |
if (nodes.length > 0) { | |
return new(tree.Expression)(nodes); | |
} | |
}, | |
mediaFeatures: function () { | |
var e, features = []; | |
do { | |
if (e = $(this.mediaFeature)) { | |
features.push(e); | |
if (! $(',')) { break } | |
} else if (e = $(this.entities.variable)) { | |
features.push(e); | |
if (! $(',')) { break } | |
} | |
} while (e); | |
return features.length > 0 ? features : null; | |
}, | |
media: function () { | |
var features, rules; | |
if ($(/^@media/)) { | |
features = $(this.mediaFeatures); | |
if (rules = $(this.block)) { | |
return new(tree.Media)(rules, features); | |
} | |
} | |
}, | |
// | |
// A CSS Directive | |
// | |
// @charset "utf-8"; | |
// | |
directive: function () { | |
var name, value, rules, types, e, nodes; | |
if (input.charAt(i) !== '@') return; | |
if (value = $(this['import']) || $(this.media)) { | |
return value; | |
} else if (name = $(/^@page|@keyframes/) || $(/^@(?:-webkit-|-moz-|-o-|-ms-)[a-z0-9-]+/)) { | |
types = ($(/^[^{]+/) || '').trim(); | |
if (rules = $(this.block)) { | |
return new(tree.Directive)(name + " " + types, rules); | |
} | |
} else if (name = $(/^@[-a-z]+/)) { | |
if (name === '@font-face') { | |
if (rules = $(this.block)) { | |
return new(tree.Directive)(name, rules); | |
} | |
} else if ((value = $(this.entity)) && $(';')) { | |
return new(tree.Directive)(name, value); | |
} | |
} | |
}, | |
font: function () { | |
var value = [], expression = [], weight, shorthand, font, e; | |
while (e = $(this.shorthand) || $(this.entity)) { | |
expression.push(e); | |
} | |
value.push(new(tree.Expression)(expression)); | |
if ($(',')) { | |
while (e = $(this.expression)) { | |
value.push(e); | |
if (! $(',')) { break } | |
} | |
} | |
return new(tree.Value)(value); | |
}, | |
// | |
// A Value is a comma-delimited list of Expressions | |
// | |
// font-family: Baskerville, Georgia, serif; | |
// | |
// In a Rule, a Value represents everything after the `:`, | |
// and before the `;`. | |
// | |
value: function () { | |
var e, expressions = [], important; | |
while (e = $(this.expression)) { | |
expressions.push(e); | |
if (! $(',')) { break } | |
} | |
if (expressions.length > 0) { | |
return new(tree.Value)(expressions); | |
} | |
}, | |
important: function () { | |
if (input.charAt(i) === '!') { | |
return $(/^! *important/); | |
} | |
}, | |
sub: function () { | |
var e; | |
if ($('(') && (e = $(this.expression)) && $(')')) { | |
return e; | |
} | |
}, | |
multiplication: function () { | |
var m, a, op, operation; | |
if (m = $(this.operand)) { | |
while (!peek(/^\/\*/) && (op = ($('/') || $('*'))) && (a = $(this.operand))) { | |
operation = new(tree.Operation)(op, [operation || m, a]); | |
} | |
return operation || m; | |
} | |
}, | |
addition: function () { | |
var m, a, op, operation; | |
if (m = $(this.multiplication)) { | |
while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) && | |
(a = $(this.multiplication))) { | |
operation = new(tree.Operation)(op, [operation || m, a]); | |
} | |
return operation || m; | |
} | |
}, | |
conditions: function () { | |
var a, b, index = i, condition; | |
if (a = $(this.condition)) { | |
while ($(',') && (b = $(this.condition))) { | |
condition = new(tree.Condition)('or', condition || a, b, index); | |
} | |
return condition || a; | |
} | |
}, | |
condition: function () { | |
var a, b, c, op, index = i, negate = false; | |
if ($(/^not/)) { negate = true } | |
expect('('); | |
if (a = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) { | |
if (op = $(/^(?:>=|=<|[<=>])/)) { | |
if (b = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) { | |
c = new(tree.Condition)(op, a, b, index, negate); | |
} else { | |
error('expected expression'); | |
} | |
} else { | |
c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index, negate); | |
} | |
expect(')'); | |
return $(/^and/) ? new(tree.Condition)('and', c, $(this.condition)) : c; | |
} | |
}, | |
// | |
// An operand is anything that can be part of an operation, | |
// such as a Color, or a Variable | |
// | |
operand: function () { | |
var negate, p = input.charAt(i + 1); | |
if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') } | |
var o = $(this.sub) || $(this.entities.dimension) || | |
$(this.entities.color) || $(this.entities.variable) || | |
$(this.entities.call); | |
return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o]) | |
: o; | |
}, | |
// | |
// Expressions either represent mathematical operations, | |
// or white-space delimited Entities. | |
// | |
// 1px solid black | |
// @var * 2 | |
// | |
expression: function () { | |
var e, delim, entities = [], d; | |
while (e = $(this.addition) || $(this.entity)) { | |
entities.push(e); | |
} | |
if (entities.length > 0) { | |
return new(tree.Expression)(entities); | |
} | |
}, | |
property: function () { | |
var name; | |
if (name = $(/^(\*?-?[-a-z_0-9]+)\s*:/)) { | |
return name[1]; | |
} | |
} | |
} | |
}; | |
}; | |
if (less.mode === 'browser' || less.mode === 'rhino') { | |
// | |
// Used by `@import` directives | |
// | |
less.Parser.importer = function (path, paths, callback, env) { | |
if (!/^([a-z]+:)?\//.test(path) && paths.length > 0) { | |
path = paths[0] + path; | |
} | |
// We pass `true` as 3rd argument, to force the reload of the import. | |
// This is so we can get the syntax tree as opposed to just the CSS output, | |
// as we need this to evaluate the current stylesheet. | |
loadStyleSheet({ href: path, title: path, type: env.mime }, function (e) { | |
if (e && typeof(env.errback) === "function") { | |
env.errback.call(null, path, paths, callback, env); | |
} else { | |
callback.apply(null, arguments); | |
} | |
}, true); | |
}; | |
} | |
(function (tree) { | |
tree.functions = { | |
rgb: function (r, g, b) { | |
return this.rgba(r, g, b, 1.0); | |
}, | |
rgba: function (r, g, b, a) { | |
var rgb = [r, g, b].map(function (c) { return number(c) }), | |
a = number(a); | |
return new(tree.Color)(rgb, a); | |
}, | |
hsl: function (h, s, l) { | |
return this.hsla(h, s, l, 1.0); | |
}, | |
hsla: function (h, s, l, a) { | |
h = (number(h) % 360) / 360; | |
s = number(s); l = number(l); a = number(a); | |
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; | |
var m1 = l * 2 - m2; | |
return this.rgba(hue(h + 1/3) * 255, | |
hue(h) * 255, | |
hue(h - 1/3) * 255, | |
a); | |
function hue(h) { | |
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h); | |
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; | |
else if (h * 2 < 1) return m2; | |
else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6; | |
else return m1; | |
} | |
}, | |
hue: function (color) { | |
return new(tree.Dimension)(Math.round(color.toHSL().h)); | |
}, | |
saturation: function (color) { | |
return new(tree.Dimension)(Math.round(color.toHSL().s * 100), '%'); | |
}, | |
lightness: function (color) { | |
return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%'); | |
}, | |
alpha: function (color) { | |
return new(tree.Dimension)(color.toHSL().a); | |
}, | |
saturate: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.s += amount.value / 100; | |
hsl.s = clamp(hsl.s); | |
return hsla(hsl); | |
}, | |
desaturate: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.s -= amount.value / 100; | |
hsl.s = clamp(hsl.s); | |
return hsla(hsl); | |
}, | |
lighten: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.l += amount.value / 100; | |
hsl.l = clamp(hsl.l); | |
return hsla(hsl); | |
}, | |
darken: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.l -= amount.value / 100; | |
hsl.l = clamp(hsl.l); | |
return hsla(hsl); | |
}, | |
fadein: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.a += amount.value / 100; | |
hsl.a = clamp(hsl.a); | |
return hsla(hsl); | |
}, | |
fadeout: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.a -= amount.value / 100; | |
hsl.a = clamp(hsl.a); | |
return hsla(hsl); | |
}, | |
fade: function (color, amount) { | |
var hsl = color.toHSL(); | |
hsl.a = amount.value / 100; | |
hsl.a = clamp(hsl.a); | |
return hsla(hsl); | |
}, | |
spin: function (color, amount) { | |
var hsl = color.toHSL(); | |
var hue = (hsl.h + amount.value) % 360; | |
hsl.h = hue < 0 ? 360 + hue : hue; | |
return hsla(hsl); | |
}, | |
// | |
// Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein | |
// http://sass-lang.com | |
// | |
mix: function (color1, color2, weight) { | |
var p = weight.value / 100.0; | |
var w = p * 2 - 1; | |
var a = color1.toHSL().a - color2.toHSL().a; | |
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; | |
var w2 = 1 - w1; | |
var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, | |
color1.rgb[1] * w1 + color2.rgb[1] * w2, | |
color1.rgb[2] * w1 + color2.rgb[2] * w2]; | |
var alpha = color1.alpha * p + color2.alpha * (1 - p); | |
return new(tree.Color)(rgb, alpha); | |
}, | |
greyscale: function (color) { | |
return this.desaturate(color, new(tree.Dimension)(100)); | |
}, | |
e: function (str) { | |
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str); | |
}, | |
escape: function (str) { | |
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29")); | |
}, | |
'%': function (quoted /* arg, arg, ...*/) { | |
var args = Array.prototype.slice.call(arguments, 1), | |
str = quoted.value; | |
for (var i = 0; i < args.length; i++) { | |
str = str.replace(/%[sda]/i, function(token) { | |
var value = token.match(/s/i) ? args[i].value : args[i].toCSS(); | |
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; | |
}); | |
} | |
str = str.replace(/%%/g, '%'); | |
return new(tree.Quoted)('"' + str + '"', str); | |
}, | |
round: function (n) { | |
return this._math('round', n); | |
}, | |
ceil: function (n) { | |
return this._math('ceil', n); | |
}, | |
floor: function (n) { | |
return this._math('floor', n); | |
}, | |
_math: function (fn, n) { | |
if (n instanceof tree.Dimension) { | |
return new(tree.Dimension)(Math[fn](number(n)), n.unit); | |
} else if (typeof(n) === 'number') { | |
return Math[fn](n); | |
} else { | |
throw { type: "Argument", message: "argument must be a number" }; | |
} | |
}, | |
argb: function (color) { | |
return new(tree.Anonymous)(color.toARGB()); | |
}, | |
percentage: function (n) { | |
return new(tree.Dimension)(n.value * 100, '%'); | |
}, | |
color: function (n) { | |
if (n instanceof tree.Quoted) { | |
return new(tree.Color)(n.value.slice(1)); | |
} else { | |
throw { type: "Argument", message: "argument must be a string" }; | |
} | |
}, | |
iscolor: function (n) { | |
return this._isa(n, tree.Color); | |
}, | |
isnumber: function (n) { | |
return this._isa(n, tree.Dimension); | |
}, | |
isstring: function (n) { | |
return this._isa(n, tree.Quoted); | |
}, | |
iskeyword: function (n) { | |
return this._isa(n, tree.Keyword); | |
}, | |
isurl: function (n) { | |
return this._isa(n, tree.URL); | |
}, | |
ispixel: function (n) { | |
return (n instanceof tree.Dimension) && n.unit === 'px' ? tree.True : tree.False; | |
}, | |
ispercentage: function (n) { | |
return (n instanceof tree.Dimension) && n.unit === '%' ? tree.True : tree.False; | |
}, | |
isem: function (n) { | |
return (n instanceof tree.Dimension) && n.unit === 'em' ? tree.True : tree.False; | |
}, | |
_isa: function (n, Type) { | |
return (n instanceof Type) ? tree.True : tree.False; | |
} | |
}; | |
function hsla(hsla) { | |
return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a); | |
} | |
function number(n) { | |
if (n instanceof tree.Dimension) { | |
return parseFloat(n.unit == '%' ? n.value / 100 : n.value); | |
} else if (typeof(n) === 'number') { | |
return n; | |
} else { | |
throw { | |
error: "RuntimeError", | |
message: "color functions take numbers as parameters" | |
}; | |
} | |
} | |
function clamp(val) { | |
return Math.min(1, Math.max(0, val)); | |
} | |
})(require('./tree')); | |
(function (tree) { | |
tree.colors = { | |
'aliceblue':'#f0f8ff', | |
'antiquewhite':'#faebd7', | |
'aqua':'#00ffff', | |
'aquamarine':'#7fffd4', | |
'azure':'#f0ffff', | |
'beige':'#f5f5dc', | |
'bisque':'#ffe4c4', | |
'black':'#000000', | |
'blanchedalmond':'#ffebcd', | |
'blue':'#0000ff', | |
'blueviolet':'#8a2be2', | |
'brown':'#a52a2a', | |
'burlywood':'#deb887', | |
'cadetblue':'#5f9ea0', | |
'chartreuse':'#7fff00', | |
'chocolate':'#d2691e', | |
'coral':'#ff7f50', | |
'cornflowerblue':'#6495ed', | |
'cornsilk':'#fff8dc', | |
'crimson':'#dc143c', | |
'cyan':'#00ffff', | |
'darkblue':'#00008b', | |
'darkcyan':'#008b8b', | |
'darkgoldenrod':'#b8860b', | |
'darkgray':'#a9a9a9', | |
'darkgrey':'#a9a9a9', | |
'darkgreen':'#006400', | |
'darkkhaki':'#bdb76b', | |
'darkmagenta':'#8b008b', | |
'darkolivegreen':'#556b2f', | |
'darkorange':'#ff8c00', | |
'darkorchid':'#9932cc', | |
'darkred':'#8b0000', | |
'darksalmon':'#e9967a', | |
'darkseagreen':'#8fbc8f', | |
'darkslateblue':'#483d8b', | |
'darkslategray':'#2f4f4f', | |
'darkslategrey':'#2f4f4f', | |
'darkturquoise':'#00ced1', | |
'darkviolet':'#9400d3', | |
'deeppink':'#ff1493', | |
'deepskyblue':'#00bfff', | |
'dimgray':'#696969', | |
'dimgrey':'#696969', | |
'dodgerblue':'#1e90ff', | |
'firebrick':'#b22222', | |
'floralwhite':'#fffaf0', | |
'forestgreen':'#228b22', | |
'fuchsia':'#ff00ff', | |
'gainsboro':'#dcdcdc', | |
'ghostwhite':'#f8f8ff', | |
'gold':'#ffd700', | |
'goldenrod':'#daa520', | |
'gray':'#808080', | |
'grey':'#808080', | |
'green':'#008000', | |
'greenyellow':'#adff2f', | |
'honeydew':'#f0fff0', | |
'hotpink':'#ff69b4', | |
'indianred':'#cd5c5c', | |
'indigo':'#4b0082', | |
'ivory':'#fffff0', | |
'khaki':'#f0e68c', | |
'lavender':'#e6e6fa', | |
'lavenderblush':'#fff0f5', | |
'lawngreen':'#7cfc00', | |
'lemonchiffon':'#fffacd', | |
'lightblue':'#add8e6', | |
'lightcoral':'#f08080', | |
'lightcyan':'#e0ffff', | |
'lightgoldenrodyellow':'#fafad2', | |
'lightgray':'#d3d3d3', | |
'lightgrey':'#d3d3d3', | |
'lightgreen':'#90ee90', | |
'lightpink':'#ffb6c1', | |
'lightsalmon':'#ffa07a', | |
'lightseagreen':'#20b2aa', | |
'lightskyblue':'#87cefa', | |
'lightslategray':'#778899', | |
'lightslategrey':'#778899', | |
'lightsteelblue':'#b0c4de', | |
'lightyellow':'#ffffe0', | |
'lime':'#00ff00', | |
'limegreen':'#32cd32', | |
'linen':'#faf0e6', | |
'magenta':'#ff00ff', | |
'maroon':'#800000', | |
'mediumaquamarine':'#66cdaa', | |
'mediumblue':'#0000cd', | |
'mediumorchid':'#ba55d3', | |
'mediumpurple':'#9370d8', | |
'mediumseagreen':'#3cb371', | |
'mediumslateblue':'#7b68ee', | |
'mediumspringgreen':'#00fa9a', | |
'mediumturquoise':'#48d1cc', | |
'mediumvioletred':'#c71585', | |
'midnightblue':'#191970', | |
'mintcream':'#f5fffa', | |
'mistyrose':'#ffe4e1', | |
'moccasin':'#ffe4b5', | |
'navajowhite':'#ffdead', | |
'navy':'#000080', | |
'oldlace':'#fdf5e6', | |
'olive':'#808000', | |
'olivedrab':'#6b8e23', | |
'orange':'#ffa500', | |
'orangered':'#ff4500', | |
'orchid':'#da70d6', | |
'palegoldenrod':'#eee8aa', | |
'palegreen':'#98fb98', | |
'paleturquoise':'#afeeee', | |
'palevioletred':'#d87093', | |
'papayawhip':'#ffefd5', | |
'peachpuff':'#ffdab9', | |
'peru':'#cd853f', | |
'pink':'#ffc0cb', | |
'plum':'#dda0dd', | |
'powderblue':'#b0e0e6', | |
'purple':'#800080', | |
'red':'#ff0000', | |
'rosybrown':'#bc8f8f', | |
'royalblue':'#4169e1', | |
'saddlebrown':'#8b4513', | |
'salmon':'#fa8072', | |
'sandybrown':'#f4a460', | |
'seagreen':'#2e8b57', | |
'seashell':'#fff5ee', | |
'sienna':'#a0522d', | |
'silver':'#c0c0c0', | |
'skyblue':'#87ceeb', | |
'slateblue':'#6a5acd', | |
'slategray':'#708090', | |
'slategrey':'#708090', | |
'snow':'#fffafa', | |
'springgreen':'#00ff7f', | |
'steelblue':'#4682b4', | |
'tan':'#d2b48c', | |
'teal':'#008080', | |
'thistle':'#d8bfd8', | |
'tomato':'#ff6347', | |
'turquoise':'#40e0d0', | |
'violet':'#ee82ee', | |
'wheat':'#f5deb3', | |
'white':'#ffffff', | |
'whitesmoke':'#f5f5f5', | |
'yellow':'#ffff00', | |
'yellowgreen':'#9acd32' | |
}; | |
})(require('./tree')); | |
(function (tree) { | |
tree.Alpha = function (val) { | |
this.value = val; | |
}; | |
tree.Alpha.prototype = { | |
toCSS: function () { | |
return "alpha(opacity=" + | |
(this.value.toCSS ? this.value.toCSS() : this.value) + ")"; | |
}, | |
eval: function (env) { | |
if (this.value.eval) { this.value = this.value.eval(env) } | |
return this; | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Anonymous = function (string) { | |
this.value = string.value || string; | |
}; | |
tree.Anonymous.prototype = { | |
toCSS: function () { | |
return this.value; | |
}, | |
eval: function () { return this } | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Assignment = function (key, val) { | |
this.key = key; | |
this.value = val; | |
}; | |
tree.Assignment.prototype = { | |
toCSS: function () { | |
return this.key + '=' + (this.value.toCSS ? this.value.toCSS() : this.value); | |
}, | |
eval: function (env) { | |
if (this.value.eval) { this.value = this.value.eval(env) } | |
return this; | |
} | |
}; | |
})(require('../tree'));(function (tree) { | |
// | |
// A function call node. | |
// | |
tree.Call = function (name, args, index, filename) { | |
this.name = name; | |
this.args = args; | |
this.index = index; | |
this.filename = filename; | |
}; | |
tree.Call.prototype = { | |
// | |
// When evaluating a function call, | |
// we either find the function in `tree.functions` [1], | |
// in which case we call it, passing the evaluated arguments, | |
// or we simply print it out as it appeared originally [2]. | |
// | |
// The *functions.js* file contains the built-in functions. | |
// | |
// The reason why we evaluate the arguments, is in the case where | |
// we try to pass a variable to a function, like: `saturate(@color)`. | |
// The function should receive the value, not the variable. | |
// | |
eval: function (env) { | |
var args = this.args.map(function (a) { return a.eval(env) }); | |
if (this.name in tree.functions) { // 1. | |
try { | |
return tree.functions[this.name].apply(tree.functions, args); | |
} catch (e) { | |
throw { type: e.type || "Runtime", | |
message: "error evaluating function `" + this.name + "`" + | |
(e.message ? ': ' + e.message : ''), | |
index: this.index, filename: this.filename }; | |
} | |
} else { // 2. | |
return new(tree.Anonymous)(this.name + | |
"(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")"); | |
} | |
}, | |
toCSS: function (env) { | |
return this.eval(env).toCSS(); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
// | |
// RGB Colors - #ff0014, #eee | |
// | |
tree.Color = function (rgb, a) { | |
// | |
// The end goal here, is to parse the arguments | |
// into an integer triplet, such as `128, 255, 0` | |
// | |
// This facilitates operations and conversions. | |
// | |
if (Array.isArray(rgb)) { | |
this.rgb = rgb; | |
} else if (rgb.length == 6) { | |
this.rgb = rgb.match(/.{2}/g).map(function (c) { | |
return parseInt(c, 16); | |
}); | |
} else { | |
this.rgb = rgb.split('').map(function (c) { | |
return parseInt(c + c, 16); | |
}); | |
} | |
this.alpha = typeof(a) === 'number' ? a : 1; | |
}; | |
tree.Color.prototype = { | |
eval: function () { return this }, | |
// | |
// If we have some transparency, the only way to represent it | |
// is via `rgba`. Otherwise, we use the hex representation, | |
// which has better compatibility with older browsers. | |
// Values are capped between `0` and `255`, rounded and zero-padded. | |
// | |
toCSS: function () { | |
if (this.alpha < 1.0) { | |
return "rgba(" + this.rgb.map(function (c) { | |
return Math.round(c); | |
}).concat(this.alpha).join(', ') + ")"; | |
} else { | |
return '#' + this.rgb.map(function (i) { | |
i = Math.round(i); | |
i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16); | |
return i.length === 1 ? '0' + i : i; | |
}).join(''); | |
} | |
}, | |
// | |
// Operations have to be done per-channel, if not, | |
// channels will spill onto each other. Once we have | |
// our result, in the form of an integer triplet, | |
// we create a new Color node to hold the result. | |
// | |
operate: function (op, other) { | |
var result = []; | |
if (! (other instanceof tree.Color)) { | |
other = other.toColor(); | |
} | |
for (var c = 0; c < 3; c++) { | |
result[c] = tree.operate(op, this.rgb[c], other.rgb[c]); | |
} | |
return new(tree.Color)(result, this.alpha + other.alpha); | |
}, | |
toHSL: function () { | |
var r = this.rgb[0] / 255, | |
g = this.rgb[1] / 255, | |
b = this.rgb[2] / 255, | |
a = this.alpha; | |
var max = Math.max(r, g, b), min = Math.min(r, g, b); | |
var h, s, l = (max + min) / 2, d = max - min; | |
if (max === min) { | |
h = s = 0; | |
} else { | |
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); | |
switch (max) { | |
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | |
case g: h = (b - r) / d + 2; break; | |
case b: h = (r - g) / d + 4; break; | |
} | |
h /= 6; | |
} | |
return { h: h * 360, s: s, l: l, a: a }; | |
}, | |
toARGB: function () { | |
var argb = [Math.round(this.alpha * 255)].concat(this.rgb); | |
return '#' + argb.map(function (i) { | |
i = Math.round(i); | |
i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16); | |
return i.length === 1 ? '0' + i : i; | |
}).join(''); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Comment = function (value, silent) { | |
this.value = value; | |
this.silent = !!silent; | |
}; | |
tree.Comment.prototype = { | |
toCSS: function (env) { | |
return env.compress ? '' : this.value; | |
}, | |
eval: function () { return this } | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Condition = function (op, l, r, i, negate) { | |
this.op = op.trim(); | |
this.lvalue = l; | |
this.rvalue = r; | |
this.index = i; | |
this.negate = negate; | |
}; | |
tree.Condition.prototype.eval = function (env) { | |
var a = this.lvalue.eval(env), | |
b = this.rvalue.eval(env); | |
var i = this.index, result; | |
var result = (function (op) { | |
switch (op) { | |
case 'and': | |
return a && b; | |
case 'or': | |
return a || b; | |
default: | |
if (a.compare) { | |
result = a.compare(b); | |
} else if (b.compare) { | |
result = b.compare(a); | |
} else { | |
throw { type: "Type", | |
message: "Unable to perform comparison", | |
index: i }; | |
} | |
switch (result) { | |
case -1: return op === '<' || op === '=<'; | |
case 0: return op === '=' || op === '>=' || op === '=<'; | |
case 1: return op === '>' || op === '>='; | |
} | |
} | |
})(this.op); | |
return this.negate ? !result : result; | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
// | |
// A number with a unit | |
// | |
tree.Dimension = function (value, unit) { | |
this.value = parseFloat(value); | |
this.unit = unit || null; | |
}; | |
tree.Dimension.prototype = { | |
eval: function () { return this }, | |
toColor: function () { | |
return new(tree.Color)([this.value, this.value, this.value]); | |
}, | |
toCSS: function () { | |
var css = this.value + this.unit; | |
return css; | |
}, | |
// In an operation between two Dimensions, | |
// we default to the first Dimension's unit, | |
// so `1px + 2em` will yield `3px`. | |
// In the future, we could implement some unit | |
// conversions such that `100cm + 10mm` would yield | |
// `101cm`. | |
operate: function (op, other) { | |
return new(tree.Dimension) | |
(tree.operate(op, this.value, other.value), | |
this.unit || other.unit); | |
}, | |
// TODO: Perform unit conversion before comparing | |
compare: function (other) { | |
if (other instanceof tree.Dimension) { | |
if (other.value > this.value) { | |
return -1; | |
} else if (other.value < this.value) { | |
return 1; | |
} else { | |
return 0; | |
} | |
} else { | |
return -1; | |
} | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Directive = function (name, value, features) { | |
this.name = name; | |
if (Array.isArray(value)) { | |
this.ruleset = new(tree.Ruleset)([], value); | |
this.ruleset.allowImports = true; | |
} else { | |
this.value = value; | |
} | |
}; | |
tree.Directive.prototype = { | |
toCSS: function (ctx, env) { | |
if (this.ruleset) { | |
this.ruleset.root = true; | |
return this.name + (env.compress ? '{' : ' {\n ') + | |
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') + | |
(env.compress ? '}': '\n}\n'); | |
} else { | |
return this.name + ' ' + this.value.toCSS() + ';\n'; | |
} | |
}, | |
eval: function (env) { | |
env.frames.unshift(this); | |
this.ruleset = this.ruleset && this.ruleset.eval(env); | |
env.frames.shift(); | |
return this; | |
}, | |
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) }, | |
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) }, | |
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) } | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Element = function (combinator, value, index) { | |
this.combinator = combinator instanceof tree.Combinator ? | |
combinator : new(tree.Combinator)(combinator); | |
if (typeof(value) === 'string') { | |
this.value = value.trim(); | |
} else if (value) { | |
this.value = value; | |
} else { | |
this.value = ""; | |
} | |
this.index = index; | |
}; | |
tree.Element.prototype.eval = function (env) { | |
return new(tree.Element)(this.combinator, | |
this.value.eval ? this.value.eval(env) : this.value, | |
this.index); | |
}; | |
tree.Element.prototype.toCSS = function (env) { | |
return this.combinator.toCSS(env || {}) + (this.value.toCSS ? this.value.toCSS(env) : this.value); | |
}; | |
tree.Combinator = function (value) { | |
if (value === ' ') { | |
this.value = ' '; | |
} else if (value === '& ') { | |
this.value = '& '; | |
} else { | |
this.value = value ? value.trim() : ""; | |
} | |
}; | |
tree.Combinator.prototype.toCSS = function (env) { | |
return { | |
'' : '', | |
' ' : ' ', | |
'&' : '', | |
'& ' : ' ', | |
':' : ' :', | |
'+' : env.compress ? '+' : ' + ', | |
'~' : env.compress ? '~' : ' ~ ', | |
'>' : env.compress ? '>' : ' > ' | |
}[this.value]; | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Expression = function (value) { this.value = value }; | |
tree.Expression.prototype = { | |
eval: function (env) { | |
if (this.value.length > 1) { | |
return new(tree.Expression)(this.value.map(function (e) { | |
return e.eval(env); | |
})); | |
} else if (this.value.length === 1) { | |
return this.value[0].eval(env); | |
} else { | |
return this; | |
} | |
}, | |
toCSS: function (env) { | |
return this.value.map(function (e) { | |
return e.toCSS ? e.toCSS(env) : ''; | |
}).join(' '); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
// | |
// CSS @import node | |
// | |
// The general strategy here is that we don't want to wait | |
// for the parsing to be completed, before we start importing | |
// the file. That's because in the context of a browser, | |
// most of the time will be spent waiting for the server to respond. | |
// | |
// On creation, we push the import path to our import queue, though | |
// `import,push`, we also pass it a callback, which it'll call once | |
// the file has been fetched, and parsed. | |
// | |
tree.Import = function (path, imports, features, index) { | |
var that = this; | |
this.index = index; | |
this._path = path; | |
this.features = features && new(tree.Value)(features); | |
// The '.less' extension is optional | |
if (path instanceof tree.Quoted) { | |
this.path = /\.(le?|c)ss(\?.*)?$/.test(path.value) ? path.value : path.value + '.less'; | |
} else { | |
this.path = path.value.value || path.value; | |
} | |
this.css = /css(\?.*)?$/.test(this.path); | |
// Only pre-compile .less files | |
if (! this.css) { | |
imports.push(this.path, function (e, root) { | |
if (e) { e.index = index } | |
that.root = root || new(tree.Ruleset)([], []); | |
}); | |
} | |
}; | |
// | |
// The actual import node doesn't return anything, when converted to CSS. | |
// The reason is that it's used at the evaluation stage, so that the rules | |
// it imports can be treated like any other rules. | |
// | |
// In `eval`, we make sure all Import nodes get evaluated, recursively, so | |
// we end up with a flat structure, which can easily be imported in the parent | |
// ruleset. | |
// | |
tree.Import.prototype = { | |
toCSS: function (env) { | |
var features = this.features ? ' ' + this.features.toCSS(env) : ''; | |
if (this.css) { | |
return "@import " + this._path.toCSS() + features + ';\n'; | |
} else { | |
return ""; | |
} | |
}, | |
eval: function (env) { | |
var ruleset, features = this.features && this.features.eval(env); | |
if (this.css) { | |
return this; | |
} else { | |
ruleset = new(tree.Ruleset)([], this.root.rules.slice(0)); | |
for (var i = 0; i < ruleset.rules.length; i++) { | |
if (ruleset.rules[i] instanceof tree.Import) { | |
Array.prototype | |
.splice | |
.apply(ruleset.rules, | |
[i, 1].concat(ruleset.rules[i].eval(env))); | |
} | |
} | |
return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules; | |
} | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.JavaScript = function (string, index, escaped) { | |
this.escaped = escaped; | |
this.expression = string; | |
this.index = index; | |
}; | |
tree.JavaScript.prototype = { | |
eval: function (env) { | |
var result, | |
that = this, | |
context = {}; | |
var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) { | |
return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env)); | |
}); | |
try { | |
expression = new(Function)('return (' + expression + ')'); | |
} catch (e) { | |
throw { message: "JavaScript evaluation error: `" + expression + "`" , | |
index: this.index }; | |
} | |
for (var k in env.frames[0].variables()) { | |
context[k.slice(1)] = { | |
value: env.frames[0].variables()[k].value, | |
toJS: function () { | |
return this.value.eval(env).toCSS(); | |
} | |
}; | |
} | |
try { | |
result = expression.call(context); | |
} catch (e) { | |
throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" , | |
index: this.index }; | |
} | |
if (typeof(result) === 'string') { | |
return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index); | |
} else if (Array.isArray(result)) { | |
return new(tree.Anonymous)(result.join(', ')); | |
} else { | |
return new(tree.Anonymous)(result); | |
} | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Keyword = function (value) { this.value = value }; | |
tree.Keyword.prototype = { | |
eval: function () { return this }, | |
toCSS: function () { return this.value }, | |
compare: function (other) { | |
if (other instanceof tree.Keyword) { | |
return other.value === this.value ? 0 : 1; | |
} else { | |
return -1; | |
} | |
} | |
}; | |
tree.True = new(tree.Keyword)('true'); | |
tree.False = new(tree.Keyword)('false'); | |
})(require('../tree')); | |
(function (tree) { | |
tree.Media = function (value, features) { | |
var el = new(tree.Element)('&', null, 0), | |
selectors = [new(tree.Selector)([el])]; | |
this.features = new(tree.Value)(features); | |
this.ruleset = new(tree.Ruleset)(selectors, value); | |
this.ruleset.allowImports = true; | |
}; | |
tree.Media.prototype = { | |
toCSS: function (ctx, env) { | |
var features = this.features.toCSS(env); | |
this.ruleset.root = (ctx.length === 0 || ctx[0].multiMedia); | |
return '@media ' + features + (env.compress ? '{' : ' {\n ') + | |
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') + | |
(env.compress ? '}': '\n}\n'); | |
}, | |
eval: function (env) { | |
if (!env.mediaBlocks) { | |
env.mediaBlocks = []; | |
env.mediaPath = []; | |
} | |
var blockIndex = env.mediaBlocks.length; | |
env.mediaPath.push(this); | |
env.mediaBlocks.push(this); | |
var media = new(tree.Media)([], []); | |
media.features = this.features.eval(env); | |
env.frames.unshift(this.ruleset); | |
media.ruleset = this.ruleset.eval(env); | |
env.frames.shift(); | |
env.mediaBlocks[blockIndex] = media; | |
env.mediaPath.pop(); | |
return env.mediaPath.length === 0 ? media.evalTop(env) : | |
media.evalNested(env) | |
}, | |
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) }, | |
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) }, | |
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }, | |
evalTop: function (env) { | |
var result = this; | |
// Render all dependent Media blocks. | |
if (env.mediaBlocks.length > 1) { | |
var el = new(tree.Element)('&', null, 0); | |
var selectors = [new(tree.Selector)([el])]; | |
result = new(tree.Ruleset)(selectors, env.mediaBlocks); | |
result.multiMedia = true; | |
} | |
delete env.mediaBlocks; | |
delete env.mediaPath; | |
return result; | |
}, | |
evalNested: function (env) { | |
var i, value, | |
path = env.mediaPath.concat([this]); | |
// Extract the media-query conditions separated with `,` (OR). | |
for (i = 0; i < path.length; i++) { | |
value = path[i].features instanceof tree.Value ? | |
path[i].features.value : path[i].features; | |
path[i] = Array.isArray(value) ? value : [value]; | |
} | |
// Trace all permutations to generate the resulting media-query. | |
// | |
// (a, b and c) with nested (d, e) -> | |
// a and d | |
// a and e | |
// b and c and d | |
// b and c and e | |
this.features = new(tree.Value)(this.permute(path).map(function (path) { | |
path = path.map(function (fragment) { | |
return fragment.toCSS ? fragment : new(tree.Anonymous)(fragment); | |
}); | |
for(i = path.length - 1; i > 0; i--) { | |
path.splice(i, 0, new(tree.Anonymous)("and")); | |
} | |
return new(tree.Expression)(path); | |
})); | |
// Fake a tree-node that doesn't output anything. | |
return new(tree.Ruleset)([], []); | |
}, | |
permute: function (arr) { | |
if (arr.length === 0) { | |
return []; | |
} else if (arr.length === 1) { | |
return arr[0]; | |
} else { | |
var result = []; | |
var rest = this.permute(arr.slice(1)); | |
for (var i = 0; i < rest.length; i++) { | |
for (var j = 0; j < arr[0].length; j++) { | |
result.push([arr[0][j]].concat(rest[i])); | |
} | |
} | |
return result; | |
} | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.mixin = {}; | |
tree.mixin.Call = function (elements, args, index, filename, important) { | |
this.selector = new(tree.Selector)(elements); | |
this.arguments = args; | |
this.index = index; | |
this.filename = filename; | |
this.important = important; | |
}; | |
tree.mixin.Call.prototype = { | |
eval: function (env) { | |
var mixins, args, rules = [], match = false; | |
for (var i = 0; i < env.frames.length; i++) { | |
if ((mixins = env.frames[i].find(this.selector)).length > 0) { | |
args = this.arguments && this.arguments.map(function (a) { return a.eval(env) }); | |
for (var m = 0; m < mixins.length; m++) { | |
if (mixins[m].match(args, env)) { | |
try { | |
Array.prototype.push.apply( | |
rules, mixins[m].eval(env, this.arguments, this.important).rules); | |
match = true; | |
} catch (e) { | |
throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack }; | |
} | |
} | |
} | |
if (match) { | |
return rules; | |
} else { | |
throw { type: 'Runtime', | |
message: 'No matching definition was found for `' + | |
this.selector.toCSS().trim() + '(' + | |
this.arguments.map(function (a) { | |
return a.toCSS(); | |
}).join(', ') + ")`", | |
index: this.index, filename: this.filename }; | |
} | |
} | |
} | |
throw { type: 'Name', | |
message: this.selector.toCSS().trim() + " is undefined", | |
index: this.index, filename: this.filename }; | |
} | |
}; | |
tree.mixin.Definition = function (name, params, rules, condition, variadic) { | |
this.name = name; | |
this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])]; | |
this.params = params; | |
this.condition = condition; | |
this.variadic = variadic; | |
this.arity = params.length; | |
this.rules = rules; | |
this._lookups = {}; | |
this.required = params.reduce(function (count, p) { | |
if (!p.name || (p.name && !p.value)) { return count + 1 } | |
else { return count } | |
}, 0); | |
this.parent = tree.Ruleset.prototype; | |
this.frames = []; | |
}; | |
tree.mixin.Definition.prototype = { | |
toCSS: function () { return "" }, | |
variable: function (name) { return this.parent.variable.call(this, name) }, | |
variables: function () { return this.parent.variables.call(this) }, | |
find: function () { return this.parent.find.apply(this, arguments) }, | |
rulesets: function () { return this.parent.rulesets.apply(this) }, | |
evalParams: function (env, args) { | |
var frame = new(tree.Ruleset)(null, []), varargs; | |
for (var i = 0, val, name; i < this.params.length; i++) { | |
if (name = this.params[i].name) { | |
if (this.params[i].variadic && args) { | |
varargs = []; | |
for (var j = i; j < args.length; j++) { | |
varargs.push(args[j].eval(env)); | |
} | |
frame.rules.unshift(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env))); | |
} else if (val = (args && args[i]) || this.params[i].value) { | |
frame.rules.unshift(new(tree.Rule)(name, val.eval(env))); | |
} else { | |
throw { type: 'Runtime', message: "wrong number of arguments for " + this.name + | |
' (' + args.length + ' for ' + this.arity + ')' }; | |
} | |
} | |
} | |
return frame; | |
}, | |
eval: function (env, args, important) { | |
var frame = this.evalParams(env, args), context, _arguments = [], rules, start; | |
for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) { | |
_arguments.push(args[i] || this.params[i].value); | |
} | |
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env))); | |
rules = important ? | |
this.rules.map(function (r) { | |
return new(tree.Rule)(r.name, r.value, '!important', r.index); | |
}) : this.rules.slice(0); | |
return new(tree.Ruleset)(null, rules).eval({ | |
frames: [this, frame].concat(this.frames, env.frames) | |
}); | |
}, | |
match: function (args, env) { | |
var argsLength = (args && args.length) || 0, len, frame; | |
if (! this.variadic) { | |
if (argsLength < this.required) { return false } | |
if (argsLength > this.params.length) { return false } | |
if ((this.required > 0) && (argsLength > this.params.length)) { return false } | |
} | |
if (this.condition && !this.condition.eval({ | |
frames: [this.evalParams(env, args)].concat(env.frames) | |
})) { return false } | |
len = Math.min(argsLength, this.arity); | |
for (var i = 0; i < len; i++) { | |
if (!this.params[i].name) { | |
if (args[i].eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) { | |
return false; | |
} | |
} | |
} | |
return true; | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Operation = function (op, operands) { | |
this.op = op.trim(); | |
this.operands = operands; | |
}; | |
tree.Operation.prototype.eval = function (env) { | |
var a = this.operands[0].eval(env), | |
b = this.operands[1].eval(env), | |
temp; | |
if (a instanceof tree.Dimension && b instanceof tree.Color) { | |
if (this.op === '*' || this.op === '+') { | |
temp = b, b = a, a = temp; | |
} else { | |
throw { name: "OperationError", | |
message: "Can't substract or divide a color from a number" }; | |
} | |
} | |
return a.operate(this.op, b); | |
}; | |
tree.operate = function (op, a, b) { | |
switch (op) { | |
case '+': return a + b; | |
case '-': return a - b; | |
case '*': return a * b; | |
case '/': return a / b; | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Paren = function (node) { | |
this.value = node; | |
}; | |
tree.Paren.prototype = { | |
toCSS: function (env) { | |
return '(' + this.value.toCSS(env) + ')'; | |
}, | |
eval: function (env) { | |
return new(tree.Paren)(this.value.eval(env)); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Quoted = function (str, content, escaped, i) { | |
this.escaped = escaped; | |
this.value = content || ''; | |
this.quote = str.charAt(0); | |
this.index = i; | |
}; | |
tree.Quoted.prototype = { | |
toCSS: function () { | |
if (this.escaped) { | |
return this.value; | |
} else { | |
return this.quote + this.value + this.quote; | |
} | |
}, | |
eval: function (env) { | |
var that = this; | |
var value = this.value.replace(/`([^`]+)`/g, function (_, exp) { | |
return new(tree.JavaScript)(exp, that.index, true).eval(env).value; | |
}).replace(/@\{([\w-]+)\}/g, function (_, name) { | |
var v = new(tree.Variable)('@' + name, that.index).eval(env); | |
return ('value' in v) ? v.value : v.toCSS(); | |
}); | |
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Rule = function (name, value, important, index, inline) { | |
this.name = name; | |
this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]); | |
this.important = important ? ' ' + important.trim() : ''; | |
this.index = index; | |
this.inline = inline || false; | |
if (name.charAt(0) === '@') { | |
this.variable = true; | |
} else { this.variable = false } | |
}; | |
tree.Rule.prototype.toCSS = function (env) { | |
if (this.variable) { return "" } | |
else { | |
return this.name + (env.compress ? ':' : ': ') + | |
this.value.toCSS(env) + | |
this.important + (this.inline ? "" : ";"); | |
} | |
}; | |
tree.Rule.prototype.eval = function (context) { | |
return new(tree.Rule)(this.name, | |
this.value.eval(context), | |
this.important, | |
this.index, this.inline); | |
}; | |
tree.Shorthand = function (a, b) { | |
this.a = a; | |
this.b = b; | |
}; | |
tree.Shorthand.prototype = { | |
toCSS: function (env) { | |
return this.a.toCSS(env) + "/" + this.b.toCSS(env); | |
}, | |
eval: function () { return this } | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Ruleset = function (selectors, rules, strictImports) { | |
this.selectors = selectors; | |
this.rules = rules; | |
this._lookups = {}; | |
this.strictImports = strictImports; | |
}; | |
tree.Ruleset.prototype = { | |
eval: function (env) { | |
var selectors = this.selectors && this.selectors.map(function (s) { return s.eval(env) }); | |
var ruleset = new(tree.Ruleset)(selectors, this.rules.slice(0), this.strictImports); | |
ruleset.root = this.root; | |
ruleset.allowImports = this.allowImports; | |
// push the current ruleset to the frames stack | |
env.frames.unshift(ruleset); | |
// Evaluate imports | |
if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) { | |
for (var i = 0; i < ruleset.rules.length; i++) { | |
if (ruleset.rules[i] instanceof tree.Import) { | |
Array.prototype.splice | |
.apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env))); | |
} | |
} | |
} | |
// Store the frames around mixin definitions, | |
// so they can be evaluated like closures when the time comes. | |
for (var i = 0; i < ruleset.rules.length; i++) { | |
if (ruleset.rules[i] instanceof tree.mixin.Definition) { | |
ruleset.rules[i].frames = env.frames.slice(0); | |
} | |
} | |
// Evaluate mixin calls. | |
for (var i = 0; i < ruleset.rules.length; i++) { | |
if (ruleset.rules[i] instanceof tree.mixin.Call) { | |
Array.prototype.splice | |
.apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env))); | |
} | |
} | |
// Evaluate everything else | |
for (var i = 0, rule; i < ruleset.rules.length; i++) { | |
rule = ruleset.rules[i]; | |
if (! (rule instanceof tree.mixin.Definition)) { | |
ruleset.rules[i] = rule.eval ? rule.eval(env) : rule; | |
} | |
} | |
// Pop the stack | |
env.frames.shift(); | |
return ruleset; | |
}, | |
match: function (args) { | |
return !args || args.length === 0; | |
}, | |
variables: function () { | |
if (this._variables) { return this._variables } | |
else { | |
return this._variables = this.rules.reduce(function (hash, r) { | |
if (r instanceof tree.Rule && r.variable === true) { | |
hash[r.name] = r; | |
} | |
return hash; | |
}, {}); | |
} | |
}, | |
variable: function (name) { | |
return this.variables()[name]; | |
}, | |
rulesets: function () { | |
if (this._rulesets) { return this._rulesets } | |
else { | |
return this._rulesets = this.rules.filter(function (r) { | |
return (r instanceof tree.Ruleset) || (r instanceof tree.mixin.Definition); | |
}); | |
} | |
}, | |
find: function (selector, self) { | |
self = self || this; | |
var rules = [], rule, match, | |
key = selector.toCSS(); | |
if (key in this._lookups) { return this._lookups[key] } | |
this.rulesets().forEach(function (rule) { | |
if (rule !== self) { | |
for (var j = 0; j < rule.selectors.length; j++) { | |
if (match = selector.match(rule.selectors[j])) { | |
if (selector.elements.length > rule.selectors[j].elements.length) { | |
Array.prototype.push.apply(rules, rule.find( | |
new(tree.Selector)(selector.elements.slice(1)), self)); | |
} else { | |
rules.push(rule); | |
} | |
break; | |
} | |
} | |
} | |
}); | |
return this._lookups[key] = rules; | |
}, | |
// | |
// Entry point for code generation | |
// | |
// `context` holds an array of arrays. | |
// | |
toCSS: function (context, env) { | |
var css = [], // The CSS output | |
rules = [], // node.Rule instances | |
rulesets = [], // node.Ruleset instances | |
paths = [], // Current selectors | |
selector, // The fully rendered selector | |
rule; | |
if (! this.root) { | |
if (context.length === 0) { | |
paths = this.selectors.map(function (s) { return [s] }); | |
} else { | |
this.joinSelectors(paths, context, this.selectors); | |
} | |
} | |
// Compile rules and rulesets | |
for (var i = 0; i < this.rules.length; i++) { | |
rule = this.rules[i]; | |
if (rule.rules || (rule instanceof tree.Directive) || (rule instanceof tree.Media)) { | |
rulesets.push(rule.toCSS(paths, env)); | |
} else if (rule instanceof tree.Comment) { | |
if (!rule.silent) { | |
if (this.root) { | |
rulesets.push(rule.toCSS(env)); | |
} else { | |
rules.push(rule.toCSS(env)); | |
} | |
} | |
} else { | |
if (rule.toCSS && !rule.variable) { | |
rules.push(rule.toCSS(env)); | |
} else if (rule.value && !rule.variable) { | |
rules.push(rule.value.toString()); | |
} | |
} | |
} | |
rulesets = rulesets.join(''); | |
// If this is the root node, we don't render | |
// a selector, or {}. | |
// Otherwise, only output if this ruleset has rules. | |
if (this.root) { | |
css.push(rules.join(env.compress ? '' : '\n')); | |
} else { | |
if (rules.length > 0) { | |
selector = paths.map(function (p) { | |
return p.map(function (s) { | |
return s.toCSS(env); | |
}).join('').trim(); | |
}).join( env.compress ? ',' : ',\n'); | |
css.push(selector, | |
(env.compress ? '{' : ' {\n ') + | |
rules.join(env.compress ? '' : '\n ') + | |
(env.compress ? '}' : '\n}\n')); | |
} | |
} | |
css.push(rulesets); | |
return css.join('') + (env.compress ? '\n' : ''); | |
}, | |
joinSelectors: function (paths, context, selectors) { | |
for (var s = 0; s < selectors.length; s++) { | |
this.joinSelector(paths, context, selectors[s]); | |
} | |
}, | |
joinSelector: function (paths, context, selector) { | |
var before = [], after = [], beforeElements = [], | |
afterElements = [], hasParentSelector = false, el; | |
for (var i = 0; i < selector.elements.length; i++) { | |
el = selector.elements[i]; | |
if (el.combinator.value.charAt(0) === '&') { | |
hasParentSelector = true; | |
} | |
if (hasParentSelector) afterElements.push(el); | |
else beforeElements.push(el); | |
} | |
if (! hasParentSelector) { | |
afterElements = beforeElements; | |
beforeElements = []; | |
} | |
if (beforeElements.length > 0) { | |
before.push(new(tree.Selector)(beforeElements)); | |
} | |
if (afterElements.length > 0) { | |
after.push(new(tree.Selector)(afterElements)); | |
} | |
for (var c = 0; c < context.length; c++) { | |
paths.push(before.concat(context[c]).concat(after)); | |
} | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Selector = function (elements) { | |
this.elements = elements; | |
if (this.elements[0].combinator.value === "") { | |
this.elements[0].combinator.value = ' '; | |
} | |
}; | |
tree.Selector.prototype.match = function (other) { | |
var len = this.elements.length, | |
olen = other.elements.length, | |
max = Math.min(len, olen); | |
if (len < olen) { | |
return false; | |
} else { | |
for (var i = 0; i < max; i++) { | |
if (this.elements[i].value !== other.elements[i].value) { | |
return false; | |
} | |
} | |
} | |
return true; | |
}; | |
tree.Selector.prototype.eval = function (env) { | |
return new(tree.Selector)(this.elements.map(function (e) { | |
return e.eval(env); | |
})); | |
}; | |
tree.Selector.prototype.toCSS = function (env) { | |
if (this._css) { return this._css } | |
return this._css = this.elements.map(function (e) { | |
if (typeof(e) === 'string') { | |
return ' ' + e.trim(); | |
} else { | |
return e.toCSS(env); | |
} | |
}).join(''); | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.URL = function (val, paths) { | |
if (val.data) { | |
this.attrs = val; | |
} else { | |
// Add the base path if the URL is relative and we are in the browser | |
if (typeof(window) !== 'undefined' && !/^(?:https?:\/\/|file:\/\/|data:|\/)/.test(val.value) && paths.length > 0) { | |
val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value); | |
} | |
this.value = val; | |
this.paths = paths; | |
} | |
}; | |
tree.URL.prototype = { | |
toCSS: function () { | |
return "url(" + (this.attrs ? 'data:' + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data | |
: this.value.toCSS()) + ")"; | |
}, | |
eval: function (ctx) { | |
return this.attrs ? this : new(tree.URL)(this.value.eval(ctx), this.paths); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Value = function (value) { | |
this.value = value; | |
this.is = 'value'; | |
}; | |
tree.Value.prototype = { | |
eval: function (env) { | |
if (this.value.length === 1) { | |
return this.value[0].eval(env); | |
} else { | |
return new(tree.Value)(this.value.map(function (v) { | |
return v.eval(env); | |
})); | |
} | |
}, | |
toCSS: function (env) { | |
return this.value.map(function (e) { | |
return e.toCSS(env); | |
}).join(env.compress ? ',' : ', '); | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.Variable = function (name, index, file) { this.name = name, this.index = index, this.file = file }; | |
tree.Variable.prototype = { | |
eval: function (env) { | |
var variable, v, name = this.name; | |
if (name.indexOf('@@') == 0) { | |
name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value; | |
} | |
if (variable = tree.find(env.frames, function (frame) { | |
if (v = frame.variable(name)) { | |
return v.value.eval(env); | |
} | |
})) { return variable } | |
else { | |
throw { type: 'Name', | |
message: "variable " + name + " is undefined", | |
filename: this.file, | |
index: this.index }; | |
} | |
} | |
}; | |
})(require('../tree')); | |
(function (tree) { | |
tree.find = function (obj, fun) { | |
for (var i = 0, r; i < obj.length; i++) { | |
if (r = fun.call(obj, obj[i])) { return r } | |
} | |
return null; | |
}; | |
tree.jsify = function (obj) { | |
if (Array.isArray(obj.value) && (obj.value.length > 1)) { | |
return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']'; | |
} else { | |
return obj.toCSS(false); | |
} | |
}; | |
})(require('./tree')); | |
// | |
// browser.js - client-side engine | |
// | |
var isFileProtocol = (location.protocol === 'file:' || | |
location.protocol === 'chrome:' || | |
location.protocol === 'chrome-extension:' || | |
location.protocol === 'resource:'); | |
less.env = less.env || (location.hostname == '127.0.0.1' || | |
location.hostname == '0.0.0.0' || | |
location.hostname == 'localhost' || | |
location.port.length > 0 || | |
isFileProtocol ? 'development' | |
: 'production'); | |
// Load styles asynchronously (default: false) | |
// | |
// This is set to `false` by default, so that the body | |
// doesn't start loading before the stylesheets are parsed. | |
// Setting this to `true` can result in flickering. | |
// | |
less.async = false; | |
// Interval between watch polls | |
less.poll = less.poll || (isFileProtocol ? 1000 : 1500); | |
// | |
// Watch mode | |
// | |
less.watch = function () { return this.watchMode = true }; | |
less.unwatch = function () { return this.watchMode = false }; | |
if (less.env === 'development') { | |
less.optimization = 0; | |
if (/!watch/.test(location.hash)) { | |
less.watch(); | |
} | |
less.watchTimer = setInterval(function () { | |
if (less.watchMode) { | |
loadStyleSheets(function (e, root, _, sheet, env) { | |
if (root) { | |
createCSS(root.toCSS(), sheet, env.lastModified); | |
} | |
}); | |
} | |
}, less.poll); | |
} else { | |
less.optimization = 3; | |
} | |
var cache; | |
try { | |
cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage; | |
} catch (_) { | |
cache = null; | |
} | |
// | |
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less" | |
// | |
var links = document.getElementsByTagName('link'); | |
var typePattern = /^text\/(x-)?less$/; | |
less.sheets = []; | |
for (var i = 0; i < links.length; i++) { | |
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) && | |
(links[i].type.match(typePattern)))) { | |
less.sheets.push(links[i]); | |
} | |
} | |
less.refresh = function (reload) { | |
var startTime, endTime; | |
startTime = endTime = new(Date); | |
loadStyleSheets(function (e, root, _, sheet, env) { | |
if (env.local) { | |
log("loading " + sheet.href + " from cache."); | |
} else { | |
log("parsed " + sheet.href + " successfully."); | |
createCSS(root.toCSS(), sheet, env.lastModified); | |
} | |
log("css for " + sheet.href + " generated in " + (new(Date) - endTime) + 'ms'); | |
(env.remaining === 0) && log("css generated in " + (new(Date) - startTime) + 'ms'); | |
endTime = new(Date); | |
}, reload); | |
loadStyles(); | |
}; | |
less.refreshStyles = loadStyles; | |
less.refresh(less.env === 'development'); | |
function loadStyles() { | |
var styles = document.getElementsByTagName('style'); | |
for (var i = 0; i < styles.length; i++) { | |
if (styles[i].type.match(typePattern)) { | |
new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) { | |
var css = tree.toCSS(); | |
var style = styles[i]; | |
style.type = 'text/css'; | |
if (style.styleSheet) { | |
style.styleSheet.cssText = css; | |
} else { | |
style.innerHTML = css; | |
} | |
}); | |
} | |
} | |
} | |
function loadStyleSheets(callback, reload) { | |
for (var i = 0; i < less.sheets.length; i++) { | |
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1)); | |
} | |
} | |
function loadStyleSheet(sheet, callback, reload, remaining) { | |
var url = window.location.href.replace(/[#?].*$/, ''); | |
var href = sheet.href.replace(/\?.*$/, ''); | |
var css = cache && cache.getItem(href); | |
var timestamp = cache && cache.getItem(href + ':timestamp'); | |
var styles = { css: css, timestamp: timestamp }; | |
// Stylesheets in IE don't always return the full path | |
if (! /^(https?|file):/.test(href)) { | |
if (href.charAt(0) == "/") { | |
href = window.location.protocol + "//" + window.location.host + href; | |
} else { | |
href = url.slice(0, url.lastIndexOf('/') + 1) + href; | |
} | |
} | |
var filename = href.match(/([^\/]+)$/)[1]; | |
xhr(sheet.href, sheet.type, function (data, lastModified) { | |
if (!reload && styles && lastModified && | |
(new(Date)(lastModified).valueOf() === | |
new(Date)(styles.timestamp).valueOf())) { | |
// Use local copy | |
createCSS(styles.css, sheet); | |
callback(null, null, data, sheet, { local: true, remaining: remaining }); | |
} else { | |
// Use remote copy (re-parse) | |
try { | |
new(less.Parser)({ | |
optimization: less.optimization, | |
paths: [href.replace(/[\w\.-]+$/, '')], | |
mime: sheet.type, | |
filename: filename | |
}).parse(data, function (e, root) { | |
if (e) { return error(e, href) } | |
try { | |
callback(e, root, data, sheet, { local: false, lastModified: lastModified, remaining: remaining }); | |
removeNode(document.getElementById('less-error-message:' + extractId(href))); | |
} catch (e) { | |
error(e, href); | |
} | |
}); | |
} catch (e) { | |
error(e, href); | |
} | |
} | |
}, function (status, url) { | |
throw new(Error)("Couldn't load " + url + " (" + status + ")"); | |
}); | |
} | |
function extractId(href) { | |
return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain | |
.replace(/^\//, '' ) // Remove root / | |
.replace(/\?.*$/, '' ) // Remove query | |
.replace(/\.[^\.\/]+$/, '' ) // Remove file extension | |
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters | |
.replace(/\./g, ':'); // Replace dots with colons(for valid id) | |
} | |
function createCSS(styles, sheet, lastModified) { | |
var css; | |
// Strip the query-string | |
var href = sheet.href ? sheet.href.replace(/\?.*$/, '') : ''; | |
// If there is no title set, use the filename, minus the extension | |
var id = 'less:' + (sheet.title || extractId(href)); | |
// If the stylesheet doesn't exist, create a new node | |
if ((css = document.getElementById(id)) === null) { | |
css = document.createElement('style'); | |
css.type = 'text/css'; | |
css.media = sheet.media || 'screen'; | |
css.id = id; | |
document.getElementsByTagName('head')[0].appendChild(css); | |
} | |
if (css.styleSheet) { // IE | |
try { | |
css.styleSheet.cssText = styles; | |
} catch (e) { | |
throw new(Error)("Couldn't reassign styleSheet.cssText."); | |
} | |
} else { | |
(function (node) { | |
if (css.childNodes.length > 0) { | |
if (css.firstChild.nodeValue !== node.nodeValue) { | |
css.replaceChild(node, css.firstChild); | |
} | |
} else { | |
css.appendChild(node); | |
} | |
})(document.createTextNode(styles)); | |
} | |
// Don't update the local store if the file wasn't modified | |
if (lastModified && cache) { | |
log('saving ' + href + ' to cache.'); | |
cache.setItem(href, styles); | |
cache.setItem(href + ':timestamp', lastModified); | |
} | |
} | |
function xhr(url, type, callback, errback) { | |
var xhr = getXMLHttpRequest(); | |
var async = isFileProtocol ? false : less.async; | |
if (typeof(xhr.overrideMimeType) === 'function') { | |
xhr.overrideMimeType('text/css'); | |
} | |
xhr.open('GET', url, async); | |
xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5'); | |
xhr.send(null); | |
if (isFileProtocol) { | |
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) { | |
callback(xhr.responseText); | |
} else { | |
errback(xhr.status, url); | |
} | |
} else if (async) { | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState == 4) { | |
handleResponse(xhr, callback, errback); | |
} | |
}; | |
} else { | |
handleResponse(xhr, callback, errback); | |
} | |
function handleResponse(xhr, callback, errback) { | |
if (xhr.status >= 200 && xhr.status < 300) { | |
callback(xhr.responseText, | |
xhr.getResponseHeader("Last-Modified")); | |
} else if (typeof(errback) === 'function') { | |
errback(xhr.status, url); | |
} | |
} | |
} | |
function getXMLHttpRequest() { | |
if (window.XMLHttpRequest) { | |
return new(XMLHttpRequest); | |
} else { | |
try { | |
return new(ActiveXObject)("MSXML2.XMLHTTP.3.0"); | |
} catch (e) { | |
log("browser doesn't support AJAX."); | |
return null; | |
} | |
} | |
} | |
function removeNode(node) { | |
return node && node.parentNode.removeChild(node); | |
} | |
function log(str) { | |
if (less.env == 'development' && typeof(console) !== "undefined") { console.log('less: ' + str) } | |
} | |
function error(e, href) { | |
var id = 'less-error-message:' + extractId(href); | |
var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>'; | |
var elem = document.createElement('div'), timer, content, error = []; | |
var filename = e.filename || href; | |
elem.id = id; | |
elem.className = "less-error-message"; | |
content = '<h3>' + (e.message || 'There is an error in your .less file') + | |
'</h3>' + '<p>in <a href="' + filename + '">' + filename + "</a> "; | |
var errorline = function (e, i, classname) { | |
if (e.extract[i]) { | |
error.push(template.replace(/\{line\}/, parseInt(e.line) + (i - 1)) | |
.replace(/\{class\}/, classname) | |
.replace(/\{content\}/, e.extract[i])); | |
} | |
}; | |
if (e.stack) { | |
content += '<br/>' + e.stack.split('\n').slice(1).join('<br/>'); | |
} else if (e.extract) { | |
errorline(e, 0, ''); | |
errorline(e, 1, 'line'); | |
errorline(e, 2, ''); | |
content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':</p>' + | |
'<ul>' + error.join('') + '</ul>'; | |
} | |
elem.innerHTML = content; | |
// CSS for error messages | |
createCSS([ | |
'.less-error-message ul, .less-error-message li {', | |
'list-style-type: none;', | |
'margin-right: 15px;', | |
'padding: 4px 0;', | |
'margin: 0;', | |
'}', | |
'.less-error-message label {', | |
'font-size: 12px;', | |
'margin-right: 15px;', | |
'padding: 4px 0;', | |
'color: #cc7777;', | |
'}', | |
'.less-error-message pre {', | |
'color: #dd6666;', | |
'padding: 4px 0;', | |
'margin: 0;', | |
'display: inline-block;', | |
'}', | |
'.less-error-message pre.line {', | |
'color: #ff0000;', | |
'}', | |
'.less-error-message h3 {', | |
'font-size: 20px;', | |
'font-weight: bold;', | |
'padding: 15px 0 5px 0;', | |
'margin: 0;', | |
'}', | |
'.less-error-message a {', | |
'color: #10a', | |
'}', | |
'.less-error-message .error {', | |
'color: red;', | |
'font-weight: bold;', | |
'padding-bottom: 2px;', | |
'border-bottom: 1px dashed red;', | |
'}' | |
].join('\n'), { title: 'error-message' }); | |
elem.style.cssText = [ | |
"font-family: Arial, sans-serif", | |
"border: 1px solid #e00", | |
"background-color: #eee", | |
"border-radius: 5px", | |
"-webkit-border-radius: 5px", | |
"-moz-border-radius: 5px", | |
"color: #e00", | |
"padding: 15px", | |
"margin-bottom: 15px" | |
].join(';'); | |
if (less.env == 'development') { | |
timer = setInterval(function () { | |
if (document.body) { | |
if (document.getElementById(id)) { | |
document.body.replaceChild(elem, document.getElementById(id)); | |
} else { | |
document.body.insertBefore(elem, document.body.firstChild); | |
} | |
clearInterval(timer); | |
} | |
}, 10); | |
} | |
} | |
})(window); |
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
var database = {}; | |
var viz = (function () { | |
var api = {}; | |
var width = 800; | |
var height = 800; | |
var ringRadius = width / 4; | |
var blipRadius = 25; | |
var svg; | |
function showMoreInfoFor(blip) { | |
var width = 800; | |
var margins = 80; | |
var height = 600; | |
var history = blip.history(); | |
var historyElement = $('#history').html('<svg></svg>').dialog('destroy').dialog({ | |
width: width + 11, | |
height: height + 50, | |
modal: true, | |
autoOpen: false, | |
resizable: false, | |
title: 'History of ' + blip.name() | |
}); | |
var svg = d3.select('#history svg').attr('width', width).attr('height', height); | |
width = width - 2 * margins; | |
height = height - 2 * margins; | |
function dataRadar(radar) { | |
return new Date(radar + ' 05:00'); | |
} | |
function dataRing(ring) { | |
switch(ring) { | |
case 'adopt': return 5; | |
case 'trial': return 4; | |
case 'assess': return 3; | |
case 'hold': return 2; | |
case 'out': return 1; | |
default: return 0; | |
} | |
} | |
var dates = _.map(history, function (blip) { | |
return new Date(blip.radar + ' 05:00'); | |
}); | |
svg = svg.append("svg:g").attr("transform", "translate(" + margins + "," + margins + ")"); | |
var x = d3.time.scale().range([0, width]); | |
var y = d3.scale.linear().range([height, 0]); | |
x.domain([_.min(dates), _.max(dates)]); | |
y.domain([0, 5]); | |
function createAxis() { | |
var xAxis = d3.svg.axis().scale(x).tickSubdivide(true); | |
var yAxis = d3.svg.axis().scale(y).ticks(4).orient("right") | |
.tickFormat(function (number) { | |
switch(number) { | |
case 0: return ''; | |
case 1: return 'out'; | |
case 2: return 'hold'; | |
case 3: return 'assess'; | |
case 4: return 'trial'; | |
case 5: return 'adopt'; | |
} | |
}); | |
svg.append("svg:g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
svg.append("svg:g") | |
.attr("class", "y axis") | |
.attr("transform", "translate(" + width + ",0)") | |
.call(yAxis); | |
} | |
createAxis(); | |
var line = d3.svg.line() | |
.interpolate("monotone") | |
.x(function(d) { return x(dataRadar(d.radar)); }) | |
.y(function(d) { return y(dataRing(d.ring)); }); | |
svg.append("svg:path") | |
.attr("class", "line") | |
.attr("d", line(history)); | |
historyElement.dialog('open'); | |
} | |
function ring(name, data, svg) { | |
var blips = _.filter(data.blips, function (blip) { | |
return blip.ring() === name; | |
}); | |
return svg.selectAll('circle.' + name).data(blips).enter(); | |
} | |
function radiusOf(ringName) { | |
switch(ringName) { | |
case 'adopt': return ringRadius; | |
case 'trial': return 2 * ringRadius; | |
case 'assess': return 3 * ringRadius; | |
case 'hold': return 4 * ringRadius; | |
} | |
} | |
function position(blip) { // TODO: this sucks, need to find a better approach | |
function yCourtesyOfBhaskara(a, b, c, x) { | |
var b2 = b * b; | |
var delta = b2 - 4 * a * c; | |
return [ | |
((-1 * b) - Math.sqrt(delta)) / (2 * a), | |
((-1 * b) + Math.sqrt(delta)) / (2 * a) | |
]; | |
} | |
var radius = radiusOf(blip.ring()); | |
var minX = width - radius + blipRadius; | |
var maxX = width - blipRadius; | |
var x = minX + _.random(maxX - minX); | |
var b = -1 * 2 * height; | |
var a = 1; | |
var c = (height * height) - (radius * radius) + (x - width) * (x - width); | |
var minY = yCourtesyOfBhaskara(a, b, c, x)[0]; | |
var maxY = minY + ringRadius; | |
if (maxY > height) { | |
maxY = height; | |
} | |
minY = minY + blipRadius; | |
maxY = maxY - blipRadius; | |
var y = minY + _.random(maxY - minY); | |
console.log(blip.ring() + ' | [' + x + ', ' + y + ']'); | |
return 'translate(' + x + ', ' + y + ')'; | |
} | |
function createRingFor(ringName, svg) { | |
svg.append('circle').attr({ 'class': 'ring ' + ringName, r: radiusOf(ringName), cx: width, cy: height }); | |
svg.append('circle').attr({ 'class': 'ring clear', r: radiusOf(ringName) - ringRadius, cx: width, cy: height }); | |
} | |
function createBlipsFor(ringName, data, svg) { | |
var blips = ring(ringName, data, svg).append('g').attr('transform', position); | |
blips.append('circle').attr({ 'class': 'blip ' + ringName, 'r': blipRadius }).on('click', showMoreInfoFor); | |
blips.append('text').attr('class', 'blip-name').text(function (blip) { return blip.name(); }).on('click', showMoreInfoFor); | |
return blips; | |
} | |
api.plot = function (data) { | |
svg = d3.select('svg#radar'); | |
createRingFor('hold', svg); | |
createRingFor('assess', svg); | |
createRingFor('trial', svg); | |
createRingFor('adopt', svg); | |
createBlipsFor('hold', data, svg); | |
createBlipsFor('assess', data, svg); | |
createBlipsFor('trial', data, svg); | |
createBlipsFor('adopt', data, svg); | |
}; | |
return api; | |
}()); | |
var radar = (function () { | |
var api = {}; | |
api.plot = function () { | |
_.each(database.radar.blips, function (blip) { | |
console.log(blip.name() + " | " + blip.ring()); | |
}); | |
viz.plot(database.radar); | |
}; | |
api.historyOf = function (blip) { | |
var radars = ['2012-03-01', '2011-11-01', '2011-07-01', '2011-01-01', '2010-08-01', '2010-02-01', '2009-10-01']; | |
var rings = ['adopt', 'trial', 'assess', 'hold', 'out']; | |
return _.map(radars, function(radar) { | |
return { radar: radar, ring: rings[_.random(4)] }; | |
}); | |
}; | |
return api; | |
}()); | |
radar.blip = function (specs) { | |
var data = {}; | |
var api = {}; | |
_.extend(data, specs); | |
api.name = function () { return data.name; } | |
api.ring = function () { return data.ring; } | |
api.movement = function () { return data.movement; } | |
api.history = function () { return radar.historyOf(api); } | |
return api; | |
}; | |
function generateDummyData(howMany) { | |
database.radar = { blips: [] }; | |
var rings = ["assess", "adopt", "hold", "trial"]; | |
function randomRing() { | |
return rings[_.random(3)]; | |
} | |
function randomString() { | |
return Math.random().toString(36).substring(2); | |
} | |
function randomBlip() { | |
return radar.blip({ | |
name: randomString(), | |
ring: randomRing(), | |
movement: "up" | |
}); | |
} | |
_(howMany).times(function () { database.radar.blips.push(randomBlip()); }); | |
} | |
$(function () { | |
generateDummyData(30); | |
radar.plot(); | |
}); |
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
// Underscore.js 1.4.1 | |
// http://underscorejs.org | |
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. | |
// Underscore may be freely distributed under the MIT license. | |
(function() { | |
// Baseline setup | |
// -------------- | |
// Establish the root object, `window` in the browser, or `global` on the server. | |
var root = this; | |
// Save the previous value of the `_` variable. | |
var previousUnderscore = root._; | |
// Establish the object that gets returned to break out of a loop iteration. | |
var breaker = {}; | |
// Save bytes in the minified (but not gzipped) version: | |
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; | |
// Create quick reference variables for speed access to core prototypes. | |
var push = ArrayProto.push, | |
slice = ArrayProto.slice, | |
concat = ArrayProto.concat, | |
unshift = ArrayProto.unshift, | |
toString = ObjProto.toString, | |
hasOwnProperty = ObjProto.hasOwnProperty; | |
// All **ECMAScript 5** native function implementations that we hope to use | |
// are declared here. | |
var | |
nativeForEach = ArrayProto.forEach, | |
nativeMap = ArrayProto.map, | |
nativeReduce = ArrayProto.reduce, | |
nativeReduceRight = ArrayProto.reduceRight, | |
nativeFilter = ArrayProto.filter, | |
nativeEvery = ArrayProto.every, | |
nativeSome = ArrayProto.some, | |
nativeIndexOf = ArrayProto.indexOf, | |
nativeLastIndexOf = ArrayProto.lastIndexOf, | |
nativeIsArray = Array.isArray, | |
nativeKeys = Object.keys, | |
nativeBind = FuncProto.bind; | |
// Create a safe reference to the Underscore object for use below. | |
var _ = function(obj) { | |
if (obj instanceof _) return obj; | |
if (!(this instanceof _)) return new _(obj); | |
this._wrapped = obj; | |
}; | |
// Export the Underscore object for **Node.js**, with | |
// backwards-compatibility for the old `require()` API. If we're in | |
// the browser, add `_` as a global object via a string identifier, | |
// for Closure Compiler "advanced" mode. | |
if (typeof exports !== 'undefined') { | |
if (typeof module !== 'undefined' && module.exports) { | |
exports = module.exports = _; | |
} | |
exports._ = _; | |
} else { | |
root['_'] = _; | |
} | |
// Current version. | |
_.VERSION = '1.4.1'; | |
// Collection Functions | |
// -------------------- | |
// The cornerstone, an `each` implementation, aka `forEach`. | |
// Handles objects with the built-in `forEach`, arrays, and raw objects. | |
// Delegates to **ECMAScript 5**'s native `forEach` if available. | |
var each = _.each = _.forEach = function(obj, iterator, context) { | |
if (nativeForEach && obj.forEach === nativeForEach) { | |
obj.forEach(iterator, context); | |
} else if (obj.length === +obj.length) { | |
for (var i = 0, l = obj.length; i < l; i++) { | |
if (iterator.call(context, obj[i], i, obj) === breaker) return; | |
} | |
} else { | |
for (var key in obj) { | |
if (_.has(obj, key)) { | |
if (iterator.call(context, obj[key], key, obj) === breaker) return; | |
} | |
} | |
} | |
}; | |
// Return the results of applying the iterator to each element. | |
// Delegates to **ECMAScript 5**'s native `map` if available. | |
_.map = _.collect = function(obj, iterator, context) { | |
var results = []; | |
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); | |
each(obj, function(value, index, list) { | |
results[results.length] = iterator.call(context, value, index, list); | |
}); | |
return results; | |
}; | |
// **Reduce** builds up a single result from a list of values, aka `inject`, | |
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. | |
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { | |
var initial = arguments.length > 2; | |
if (nativeReduce && obj.reduce === nativeReduce) { | |
if (context) iterator = _.bind(iterator, context); | |
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); | |
} | |
each(obj, function(value, index, list) { | |
if (!initial) { | |
memo = value; | |
initial = true; | |
} else { | |
memo = iterator.call(context, memo, value, index, list); | |
} | |
}); | |
if (!initial) throw new TypeError('Reduce of empty array with no initial value'); | |
return memo; | |
}; | |
// The right-associative version of reduce, also known as `foldr`. | |
// Delegates to **ECMAScript 5**'s native `reduceRight` if available. | |
_.reduceRight = _.foldr = function(obj, iterator, memo, context) { | |
var initial = arguments.length > 2; | |
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { | |
if (context) iterator = _.bind(iterator, context); | |
return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); | |
} | |
var length = obj.length; | |
if (length !== +length) { | |
var keys = _.keys(obj); | |
length = keys.length; | |
} | |
each(obj, function(value, index, list) { | |
index = keys ? keys[--length] : --length; | |
if (!initial) { | |
memo = obj[index]; | |
initial = true; | |
} else { | |
memo = iterator.call(context, memo, obj[index], index, list); | |
} | |
}); | |
if (!initial) throw new TypeError('Reduce of empty array with no initial value'); | |
return memo; | |
}; | |
// Return the first value which passes a truth test. Aliased as `detect`. | |
_.find = _.detect = function(obj, iterator, context) { | |
var result; | |
any(obj, function(value, index, list) { | |
if (iterator.call(context, value, index, list)) { | |
result = value; | |
return true; | |
} | |
}); | |
return result; | |
}; | |
// Return all the elements that pass a truth test. | |
// Delegates to **ECMAScript 5**'s native `filter` if available. | |
// Aliased as `select`. | |
_.filter = _.select = function(obj, iterator, context) { | |
var results = []; | |
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); | |
each(obj, function(value, index, list) { | |
if (iterator.call(context, value, index, list)) results[results.length] = value; | |
}); | |
return results; | |
}; | |
// Return all the elements for which a truth test fails. | |
_.reject = function(obj, iterator, context) { | |
var results = []; | |
each(obj, function(value, index, list) { | |
if (!iterator.call(context, value, index, list)) results[results.length] = value; | |
}); | |
return results; | |
}; | |
// Determine whether all of the elements match a truth test. | |
// Delegates to **ECMAScript 5**'s native `every` if available. | |
// Aliased as `all`. | |
_.every = _.all = function(obj, iterator, context) { | |
iterator || (iterator = _.identity); | |
var result = true; | |
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); | |
each(obj, function(value, index, list) { | |
if (!(result = result && iterator.call(context, value, index, list))) return breaker; | |
}); | |
return !!result; | |
}; | |
// Determine if at least one element in the object matches a truth test. | |
// Delegates to **ECMAScript 5**'s native `some` if available. | |
// Aliased as `any`. | |
var any = _.some = _.any = function(obj, iterator, context) { | |
iterator || (iterator = _.identity); | |
var result = false; | |
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); | |
each(obj, function(value, index, list) { | |
if (result || (result = iterator.call(context, value, index, list))) return breaker; | |
}); | |
return !!result; | |
}; | |
// Determine if the array or object contains a given value (using `===`). | |
// Aliased as `include`. | |
_.contains = _.include = function(obj, target) { | |
var found = false; | |
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; | |
found = any(obj, function(value) { | |
return value === target; | |
}); | |
return found; | |
}; | |
// Invoke a method (with arguments) on every item in a collection. | |
_.invoke = function(obj, method) { | |
var args = slice.call(arguments, 2); | |
return _.map(obj, function(value) { | |
return (_.isFunction(method) ? method : value[method]).apply(value, args); | |
}); | |
}; | |
// Convenience version of a common use case of `map`: fetching a property. | |
_.pluck = function(obj, key) { | |
return _.map(obj, function(value){ return value[key]; }); | |
}; | |
// Convenience version of a common use case of `filter`: selecting only objects | |
// with specific `key:value` pairs. | |
_.where = function(obj, attrs) { | |
if (_.isEmpty(attrs)) return []; | |
return _.filter(obj, function(value) { | |
for (var key in attrs) { | |
if (attrs[key] !== value[key]) return false; | |
} | |
return true; | |
}); | |
}; | |
// Return the maximum element or (element-based computation). | |
// Can't optimize arrays of integers longer than 65,535 elements. | |
// See: https://bugs.webkit.org/show_bug.cgi?id=80797 | |
_.max = function(obj, iterator, context) { | |
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { | |
return Math.max.apply(Math, obj); | |
} | |
if (!iterator && _.isEmpty(obj)) return -Infinity; | |
var result = {computed : -Infinity}; | |
each(obj, function(value, index, list) { | |
var computed = iterator ? iterator.call(context, value, index, list) : value; | |
computed >= result.computed && (result = {value : value, computed : computed}); | |
}); | |
return result.value; | |
}; | |
// Return the minimum element (or element-based computation). | |
_.min = function(obj, iterator, context) { | |
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { | |
return Math.min.apply(Math, obj); | |
} | |
if (!iterator && _.isEmpty(obj)) return Infinity; | |
var result = {computed : Infinity}; | |
each(obj, function(value, index, list) { | |
var computed = iterator ? iterator.call(context, value, index, list) : value; | |
computed < result.computed && (result = {value : value, computed : computed}); | |
}); | |
return result.value; | |
}; | |
// Shuffle an array. | |
_.shuffle = function(obj) { | |
var rand; | |
var index = 0; | |
var shuffled = []; | |
each(obj, function(value) { | |
rand = _.random(index++); | |
shuffled[index - 1] = shuffled[rand]; | |
shuffled[rand] = value; | |
}); | |
return shuffled; | |
}; | |
// An internal function to generate lookup iterators. | |
var lookupIterator = function(value) { | |
return _.isFunction(value) ? value : function(obj){ return obj[value]; }; | |
}; | |
// Sort the object's values by a criterion produced by an iterator. | |
_.sortBy = function(obj, value, context) { | |
var iterator = lookupIterator(value); | |
return _.pluck(_.map(obj, function(value, index, list) { | |
return { | |
value : value, | |
index : index, | |
criteria : iterator.call(context, value, index, list) | |
}; | |
}).sort(function(left, right) { | |
var a = left.criteria; | |
var b = right.criteria; | |
if (a !== b) { | |
if (a > b || a === void 0) return 1; | |
if (a < b || b === void 0) return -1; | |
} | |
return left.index < right.index ? -1 : 1; | |
}), 'value'); | |
}; | |
// An internal function used for aggregate "group by" operations. | |
var group = function(obj, value, context, behavior) { | |
var result = {}; | |
var iterator = lookupIterator(value); | |
each(obj, function(value, index) { | |
var key = iterator.call(context, value, index, obj); | |
behavior(result, key, value); | |
}); | |
return result; | |
}; | |
// Groups the object's values by a criterion. Pass either a string attribute | |
// to group by, or a function that returns the criterion. | |
_.groupBy = function(obj, value, context) { | |
return group(obj, value, context, function(result, key, value) { | |
(_.has(result, key) ? result[key] : (result[key] = [])).push(value); | |
}); | |
}; | |
// Counts instances of an object that group by a certain criterion. Pass | |
// either a string attribute to count by, or a function that returns the | |
// criterion. | |
_.countBy = function(obj, value, context) { | |
return group(obj, value, context, function(result, key, value) { | |
if (!_.has(result, key)) result[key] = 0; | |
result[key]++; | |
}); | |
}; | |
// Use a comparator function to figure out the smallest index at which | |
// an object should be inserted so as to maintain order. Uses binary search. | |
_.sortedIndex = function(array, obj, iterator, context) { | |
iterator = iterator == null ? _.identity : lookupIterator(iterator); | |
var value = iterator.call(context, obj); | |
var low = 0, high = array.length; | |
while (low < high) { | |
var mid = (low + high) >>> 1; | |
iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; | |
} | |
return low; | |
}; | |
// Safely convert anything iterable into a real, live array. | |
_.toArray = function(obj) { | |
if (!obj) return []; | |
if (obj.length === +obj.length) return slice.call(obj); | |
return _.values(obj); | |
}; | |
// Return the number of elements in an object. | |
_.size = function(obj) { | |
return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; | |
}; | |
// Array Functions | |
// --------------- | |
// Get the first element of an array. Passing **n** will return the first N | |
// values in the array. Aliased as `head` and `take`. The **guard** check | |
// allows it to work with `_.map`. | |
_.first = _.head = _.take = function(array, n, guard) { | |
return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; | |
}; | |
// Returns everything but the last entry of the array. Especially useful on | |
// the arguments object. Passing **n** will return all the values in | |
// the array, excluding the last N. The **guard** check allows it to work with | |
// `_.map`. | |
_.initial = function(array, n, guard) { | |
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); | |
}; | |
// Get the last element of an array. Passing **n** will return the last N | |
// values in the array. The **guard** check allows it to work with `_.map`. | |
_.last = function(array, n, guard) { | |
if ((n != null) && !guard) { | |
return slice.call(array, Math.max(array.length - n, 0)); | |
} else { | |
return array[array.length - 1]; | |
} | |
}; | |
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`. | |
// Especially useful on the arguments object. Passing an **n** will return | |
// the rest N values in the array. The **guard** | |
// check allows it to work with `_.map`. | |
_.rest = _.tail = _.drop = function(array, n, guard) { | |
return slice.call(array, (n == null) || guard ? 1 : n); | |
}; | |
// Trim out all falsy values from an array. | |
_.compact = function(array) { | |
return _.filter(array, function(value){ return !!value; }); | |
}; | |
// Internal implementation of a recursive `flatten` function. | |
var flatten = function(input, shallow, output) { | |
each(input, function(value) { | |
if (_.isArray(value)) { | |
shallow ? push.apply(output, value) : flatten(value, shallow, output); | |
} else { | |
output.push(value); | |
} | |
}); | |
return output; | |
}; | |
// Return a completely flattened version of an array. | |
_.flatten = function(array, shallow) { | |
return flatten(array, shallow, []); | |
}; | |
// Return a version of the array that does not contain the specified value(s). | |
_.without = function(array) { | |
return _.difference(array, slice.call(arguments, 1)); | |
}; | |
// Produce a duplicate-free version of the array. If the array has already | |
// been sorted, you have the option of using a faster algorithm. | |
// Aliased as `unique`. | |
_.uniq = _.unique = function(array, isSorted, iterator, context) { | |
var initial = iterator ? _.map(array, iterator, context) : array; | |
var results = []; | |
var seen = []; | |
each(initial, function(value, index) { | |
if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { | |
seen.push(value); | |
results.push(array[index]); | |
} | |
}); | |
return results; | |
}; | |
// Produce an array that contains the union: each distinct element from all of | |
// the passed-in arrays. | |
_.union = function() { | |
return _.uniq(concat.apply(ArrayProto, arguments)); | |
}; | |
// Produce an array that contains every item shared between all the | |
// passed-in arrays. | |
_.intersection = function(array) { | |
var rest = slice.call(arguments, 1); | |
return _.filter(_.uniq(array), function(item) { | |
return _.every(rest, function(other) { | |
return _.indexOf(other, item) >= 0; | |
}); | |
}); | |
}; | |
// Take the difference between one array and a number of other arrays. | |
// Only the elements present in just the first array will remain. | |
_.difference = function(array) { | |
var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); | |
return _.filter(array, function(value){ return !_.contains(rest, value); }); | |
}; | |
// Zip together multiple lists into a single array -- elements that share | |
// an index go together. | |
_.zip = function() { | |
var args = slice.call(arguments); | |
var length = _.max(_.pluck(args, 'length')); | |
var results = new Array(length); | |
for (var i = 0; i < length; i++) { | |
results[i] = _.pluck(args, "" + i); | |
} | |
return results; | |
}; | |
// Converts lists into objects. Pass either a single array of `[key, value]` | |
// pairs, or two parallel arrays of the same length -- one of keys, and one of | |
// the corresponding values. | |
_.object = function(list, values) { | |
var result = {}; | |
for (var i = 0, l = list.length; i < l; i++) { | |
if (values) { | |
result[list[i]] = values[i]; | |
} else { | |
result[list[i][0]] = list[i][1]; | |
} | |
} | |
return result; | |
}; | |
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), | |
// we need this function. Return the position of the first occurrence of an | |
// item in an array, or -1 if the item is not included in the array. | |
// Delegates to **ECMAScript 5**'s native `indexOf` if available. | |
// If the array is large and already in sort order, pass `true` | |
// for **isSorted** to use binary search. | |
_.indexOf = function(array, item, isSorted) { | |
var i = 0, l = array.length; | |
if (isSorted) { | |
if (typeof isSorted == 'number') { | |
i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); | |
} else { | |
i = _.sortedIndex(array, item); | |
return array[i] === item ? i : -1; | |
} | |
} | |
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); | |
for (; i < l; i++) if (array[i] === item) return i; | |
return -1; | |
}; | |
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. | |
_.lastIndexOf = function(array, item, from) { | |
var hasIndex = from != null; | |
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { | |
return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); | |
} | |
var i = (hasIndex ? from : array.length); | |
while (i--) if (array[i] === item) return i; | |
return -1; | |
}; | |
// Generate an integer Array containing an arithmetic progression. A port of | |
// the native Python `range()` function. See | |
// [the Python documentation](http://docs.python.org/library/functions.html#range). | |
_.range = function(start, stop, step) { | |
if (arguments.length <= 1) { | |
stop = start || 0; | |
start = 0; | |
} | |
step = arguments[2] || 1; | |
var len = Math.max(Math.ceil((stop - start) / step), 0); | |
var idx = 0; | |
var range = new Array(len); | |
while(idx < len) { | |
range[idx++] = start; | |
start += step; | |
} | |
return range; | |
}; | |
// Function (ahem) Functions | |
// ------------------ | |
// Reusable constructor function for prototype setting. | |
var ctor = function(){}; | |
// Create a function bound to a given object (assigning `this`, and arguments, | |
// optionally). Binding with arguments is also known as `curry`. | |
// Delegates to **ECMAScript 5**'s native `Function.bind` if available. | |
// We check for `func.bind` first, to fail fast when `func` is undefined. | |
_.bind = function bind(func, context) { | |
var bound, args; | |
if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); | |
if (!_.isFunction(func)) throw new TypeError; | |
args = slice.call(arguments, 2); | |
return bound = function() { | |
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); | |
ctor.prototype = func.prototype; | |
var self = new ctor; | |
var result = func.apply(self, args.concat(slice.call(arguments))); | |
if (Object(result) === result) return result; | |
return self; | |
}; | |
}; | |
// Bind all of an object's methods to that object. Useful for ensuring that | |
// all callbacks defined on an object belong to it. | |
_.bindAll = function(obj) { | |
var funcs = slice.call(arguments, 1); | |
if (funcs.length == 0) funcs = _.functions(obj); | |
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); | |
return obj; | |
}; | |
// Memoize an expensive function by storing its results. | |
_.memoize = function(func, hasher) { | |
var memo = {}; | |
hasher || (hasher = _.identity); | |
return function() { | |
var key = hasher.apply(this, arguments); | |
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); | |
}; | |
}; | |
// Delays a function for the given number of milliseconds, and then calls | |
// it with the arguments supplied. | |
_.delay = function(func, wait) { | |
var args = slice.call(arguments, 2); | |
return setTimeout(function(){ return func.apply(null, args); }, wait); | |
}; | |
// Defers a function, scheduling it to run after the current call stack has | |
// cleared. | |
_.defer = function(func) { | |
return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); | |
}; | |
// Returns a function, that, when invoked, will only be triggered at most once | |
// during a given window of time. | |
_.throttle = function(func, wait) { | |
var context, args, timeout, throttling, more, result; | |
var whenDone = _.debounce(function(){ more = throttling = false; }, wait); | |
return function() { | |
context = this; args = arguments; | |
var later = function() { | |
timeout = null; | |
if (more) { | |
result = func.apply(context, args); | |
} | |
whenDone(); | |
}; | |
if (!timeout) timeout = setTimeout(later, wait); | |
if (throttling) { | |
more = true; | |
} else { | |
throttling = true; | |
result = func.apply(context, args); | |
} | |
whenDone(); | |
return result; | |
}; | |
}; | |
// Returns a function, that, as long as it continues to be invoked, will not | |
// be triggered. The function will be called after it stops being called for | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. | |
_.debounce = function(func, wait, immediate) { | |
var timeout, result; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; | |
if (!immediate) result = func.apply(context, args); | |
}; | |
var callNow = immediate && !timeout; | |
clearTimeout(timeout); | |
timeout = setTimeout(later, wait); | |
if (callNow) result = func.apply(context, args); | |
return result; | |
}; | |
}; | |
// Returns a function that will be executed at most one time, no matter how | |
// often you call it. Useful for lazy initialization. | |
_.once = function(func) { | |
var ran = false, memo; | |
return function() { | |
if (ran) return memo; | |
ran = true; | |
memo = func.apply(this, arguments); | |
func = null; | |
return memo; | |
}; | |
}; | |
// Returns the first function passed as an argument to the second, | |
// allowing you to adjust arguments, run code before and after, and | |
// conditionally execute the original function. | |
_.wrap = function(func, wrapper) { | |
return function() { | |
var args = [func]; | |
push.apply(args, arguments); | |
return wrapper.apply(this, args); | |
}; | |
}; | |
// Returns a function that is the composition of a list of functions, each | |
// consuming the return value of the function that follows. | |
_.compose = function() { | |
var funcs = arguments; | |
return function() { | |
var args = arguments; | |
for (var i = funcs.length - 1; i >= 0; i--) { | |
args = [funcs[i].apply(this, args)]; | |
} | |
return args[0]; | |
}; | |
}; | |
// Returns a function that will only be executed after being called N times. | |
_.after = function(times, func) { | |
if (times <= 0) return func(); | |
return function() { | |
if (--times < 1) { | |
return func.apply(this, arguments); | |
} | |
}; | |
}; | |
// Object Functions | |
// ---------------- | |
// Retrieve the names of an object's properties. | |
// Delegates to **ECMAScript 5**'s native `Object.keys` | |
_.keys = nativeKeys || function(obj) { | |
if (obj !== Object(obj)) throw new TypeError('Invalid object'); | |
var keys = []; | |
for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; | |
return keys; | |
}; | |
// Retrieve the values of an object's properties. | |
_.values = function(obj) { | |
var values = []; | |
for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); | |
return values; | |
}; | |
// Convert an object into a list of `[key, value]` pairs. | |
_.pairs = function(obj) { | |
var pairs = []; | |
for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); | |
return pairs; | |
}; | |
// Invert the keys and values of an object. The values must be serializable. | |
_.invert = function(obj) { | |
var result = {}; | |
for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; | |
return result; | |
}; | |
// Return a sorted list of the function names available on the object. | |
// Aliased as `methods` | |
_.functions = _.methods = function(obj) { | |
var names = []; | |
for (var key in obj) { | |
if (_.isFunction(obj[key])) names.push(key); | |
} | |
return names.sort(); | |
}; | |
// Extend a given object with all the properties in passed-in object(s). | |
_.extend = function(obj) { | |
each(slice.call(arguments, 1), function(source) { | |
for (var prop in source) { | |
obj[prop] = source[prop]; | |
} | |
}); | |
return obj; | |
}; | |
// Return a copy of the object only containing the whitelisted properties. | |
_.pick = function(obj) { | |
var copy = {}; | |
var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); | |
each(keys, function(key) { | |
if (key in obj) copy[key] = obj[key]; | |
}); | |
return copy; | |
}; | |
// Return a copy of the object without the blacklisted properties. | |
_.omit = function(obj) { | |
var copy = {}; | |
var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); | |
for (var key in obj) { | |
if (!_.contains(keys, key)) copy[key] = obj[key]; | |
} | |
return copy; | |
}; | |
// Fill in a given object with default properties. | |
_.defaults = function(obj) { | |
each(slice.call(arguments, 1), function(source) { | |
for (var prop in source) { | |
if (obj[prop] == null) obj[prop] = source[prop]; | |
} | |
}); | |
return obj; | |
}; | |
// Create a (shallow-cloned) duplicate of an object. | |
_.clone = function(obj) { | |
if (!_.isObject(obj)) return obj; | |
return _.isArray(obj) ? obj.slice() : _.extend({}, obj); | |
}; | |
// Invokes interceptor with the obj, and then returns obj. | |
// The primary purpose of this method is to "tap into" a method chain, in | |
// order to perform operations on intermediate results within the chain. | |
_.tap = function(obj, interceptor) { | |
interceptor(obj); | |
return obj; | |
}; | |
// Internal recursive comparison function for `isEqual`. | |
var eq = function(a, b, aStack, bStack) { | |
// Identical objects are equal. `0 === -0`, but they aren't identical. | |
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. | |
if (a === b) return a !== 0 || 1 / a == 1 / b; | |
// A strict comparison is necessary because `null == undefined`. | |
if (a == null || b == null) return a === b; | |
// Unwrap any wrapped objects. | |
if (a instanceof _) a = a._wrapped; | |
if (b instanceof _) b = b._wrapped; | |
// Compare `[[Class]]` names. | |
var className = toString.call(a); | |
if (className != toString.call(b)) return false; | |
switch (className) { | |
// Strings, numbers, dates, and booleans are compared by value. | |
case '[object String]': | |
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is | |
// equivalent to `new String("5")`. | |
return a == String(b); | |
case '[object Number]': | |
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for | |
// other numeric values. | |
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); | |
case '[object Date]': | |
case '[object Boolean]': | |
// Coerce dates and booleans to numeric primitive values. Dates are compared by their | |
// millisecond representations. Note that invalid dates with millisecond representations | |
// of `NaN` are not equivalent. | |
return +a == +b; | |
// RegExps are compared by their source patterns and flags. | |
case '[object RegExp]': | |
return a.source == b.source && | |
a.global == b.global && | |
a.multiline == b.multiline && | |
a.ignoreCase == b.ignoreCase; | |
} | |
if (typeof a != 'object' || typeof b != 'object') return false; | |
// Assume equality for cyclic structures. The algorithm for detecting cyclic | |
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. | |
var length = aStack.length; | |
while (length--) { | |
// Linear search. Performance is inversely proportional to the number of | |
// unique nested structures. | |
if (aStack[length] == a) return bStack[length] == b; | |
} | |
// Add the first object to the stack of traversed objects. | |
aStack.push(a); | |
bStack.push(b); | |
var size = 0, result = true; | |
// Recursively compare objects and arrays. | |
if (className == '[object Array]') { | |
// Compare array lengths to determine if a deep comparison is necessary. | |
size = a.length; | |
result = size == b.length; | |
if (result) { | |
// Deep compare the contents, ignoring non-numeric properties. | |
while (size--) { | |
if (!(result = eq(a[size], b[size], aStack, bStack))) break; | |
} | |
} | |
} else { | |
// Objects with different constructors are not equivalent, but `Object`s | |
// from different frames are. | |
var aCtor = a.constructor, bCtor = b.constructor; | |
if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && | |
_.isFunction(bCtor) && (bCtor instanceof bCtor))) { | |
return false; | |
} | |
// Deep compare objects. | |
for (var key in a) { | |
if (_.has(a, key)) { | |
// Count the expected number of properties. | |
size++; | |
// Deep compare each member. | |
if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; | |
} | |
} | |
// Ensure that both objects contain the same number of properties. | |
if (result) { | |
for (key in b) { | |
if (_.has(b, key) && !(size--)) break; | |
} | |
result = !size; | |
} | |
} | |
// Remove the first object from the stack of traversed objects. | |
aStack.pop(); | |
bStack.pop(); | |
return result; | |
}; | |
// Perform a deep comparison to check if two objects are equal. | |
_.isEqual = function(a, b) { | |
return eq(a, b, [], []); | |
}; | |
// Is a given array, string, or object empty? | |
// An "empty" object has no enumerable own-properties. | |
_.isEmpty = function(obj) { | |
if (obj == null) return true; | |
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; | |
for (var key in obj) if (_.has(obj, key)) return false; | |
return true; | |
}; | |
// Is a given value a DOM element? | |
_.isElement = function(obj) { | |
return !!(obj && obj.nodeType === 1); | |
}; | |
// Is a given value an array? | |
// Delegates to ECMA5's native Array.isArray | |
_.isArray = nativeIsArray || function(obj) { | |
return toString.call(obj) == '[object Array]'; | |
}; | |
// Is a given variable an object? | |
_.isObject = function(obj) { | |
return obj === Object(obj); | |
}; | |
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. | |
each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { | |
_['is' + name] = function(obj) { | |
return toString.call(obj) == '[object ' + name + ']'; | |
}; | |
}); | |
// Define a fallback version of the method in browsers (ahem, IE), where | |
// there isn't any inspectable "Arguments" type. | |
if (!_.isArguments(arguments)) { | |
_.isArguments = function(obj) { | |
return !!(obj && _.has(obj, 'callee')); | |
}; | |
} | |
// Optimize `isFunction` if appropriate. | |
if (typeof (/./) !== 'function') { | |
_.isFunction = function(obj) { | |
return typeof obj === 'function'; | |
}; | |
} | |
// Is a given object a finite number? | |
_.isFinite = function(obj) { | |
return _.isNumber(obj) && isFinite(obj); | |
}; | |
// Is the given value `NaN`? (NaN is the only number which does not equal itself). | |
_.isNaN = function(obj) { | |
return _.isNumber(obj) && obj != +obj; | |
}; | |
// Is a given value a boolean? | |
_.isBoolean = function(obj) { | |
return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; | |
}; | |
// Is a given value equal to null? | |
_.isNull = function(obj) { | |
return obj === null; | |
}; | |
// Is a given variable undefined? | |
_.isUndefined = function(obj) { | |
return obj === void 0; | |
}; | |
// Shortcut function for checking if an object has a given property directly | |
// on itself (in other words, not on a prototype). | |
_.has = function(obj, key) { | |
return hasOwnProperty.call(obj, key); | |
}; | |
// Utility Functions | |
// ----------------- | |
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its | |
// previous owner. Returns a reference to the Underscore object. | |
_.noConflict = function() { | |
root._ = previousUnderscore; | |
return this; | |
}; | |
// Keep the identity function around for default iterators. | |
_.identity = function(value) { | |
return value; | |
}; | |
// Run a function **n** times. | |
_.times = function(n, iterator, context) { | |
for (var i = 0; i < n; i++) iterator.call(context, i); | |
}; | |
// Return a random integer between min and max (inclusive). | |
_.random = function(min, max) { | |
if (max == null) { | |
max = min; | |
min = 0; | |
} | |
return min + (0 | Math.random() * (max - min + 1)); | |
}; | |
// List of HTML entities for escaping. | |
var entityMap = { | |
escape: { | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
'"': '"', | |
"'": ''', | |
'/': '/' | |
} | |
}; | |
entityMap.unescape = _.invert(entityMap.escape); | |
// Regexes containing the keys and values listed immediately above. | |
var entityRegexes = { | |
escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), | |
unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') | |
}; | |
// Functions for escaping and unescaping strings to/from HTML interpolation. | |
_.each(['escape', 'unescape'], function(method) { | |
_[method] = function(string) { | |
if (string == null) return ''; | |
return ('' + string).replace(entityRegexes[method], function(match) { | |
return entityMap[method][match]; | |
}); | |
}; | |
}); | |
// If the value of the named property is a function then invoke it; | |
// otherwise, return it. | |
_.result = function(object, property) { | |
if (object == null) return null; | |
var value = object[property]; | |
return _.isFunction(value) ? value.call(object) : value; | |
}; | |
// Add your own custom functions to the Underscore object. | |
_.mixin = function(obj) { | |
each(_.functions(obj), function(name){ | |
var func = _[name] = obj[name]; | |
_.prototype[name] = function() { | |
var args = [this._wrapped]; | |
push.apply(args, arguments); | |
return result.call(this, func.apply(_, args)); | |
}; | |
}); | |
}; | |
// Generate a unique integer id (unique within the entire client session). | |
// Useful for temporary DOM ids. | |
var idCounter = 0; | |
_.uniqueId = function(prefix) { | |
var id = idCounter++; | |
return prefix ? prefix + id : id; | |
}; | |
// By default, Underscore uses ERB-style template delimiters, change the | |
// following template settings to use alternative delimiters. | |
_.templateSettings = { | |
evaluate : /<%([\s\S]+?)%>/g, | |
interpolate : /<%=([\s\S]+?)%>/g, | |
escape : /<%-([\s\S]+?)%>/g | |
}; | |
// When customizing `templateSettings`, if you don't want to define an | |
// interpolation, evaluation or escaping regex, we need one that is | |
// guaranteed not to match. | |
var noMatch = /(.)^/; | |
// Certain characters need to be escaped so that they can be put into a | |
// string literal. | |
var escapes = { | |
"'": "'", | |
'\\': '\\', | |
'\r': 'r', | |
'\n': 'n', | |
'\t': 't', | |
'\u2028': 'u2028', | |
'\u2029': 'u2029' | |
}; | |
var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; | |
// JavaScript micro-templating, similar to John Resig's implementation. | |
// Underscore templating handles arbitrary delimiters, preserves whitespace, | |
// and correctly escapes quotes within interpolated code. | |
_.template = function(text, data, settings) { | |
settings = _.defaults({}, settings, _.templateSettings); | |
// Combine delimiters into one regular expression via alternation. | |
var matcher = new RegExp([ | |
(settings.escape || noMatch).source, | |
(settings.interpolate || noMatch).source, | |
(settings.evaluate || noMatch).source | |
].join('|') + '|$', 'g'); | |
// Compile the template source, escaping string literals appropriately. | |
var index = 0; | |
var source = "__p+='"; | |
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { | |
source += text.slice(index, offset) | |
.replace(escaper, function(match) { return '\\' + escapes[match]; }); | |
source += | |
escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" : | |
interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" : | |
evaluate ? "';\n" + evaluate + "\n__p+='" : ''; | |
index = offset + match.length; | |
}); | |
source += "';\n"; | |
// If a variable is not specified, place data values in local scope. | |
if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; | |
source = "var __t,__p='',__j=Array.prototype.join," + | |
"print=function(){__p+=__j.call(arguments,'');};\n" + | |
source + "return __p;\n"; | |
try { | |
var render = new Function(settings.variable || 'obj', '_', source); | |
} catch (e) { | |
e.source = source; | |
throw e; | |
} | |
if (data) return render(data, _); | |
var template = function(data) { | |
return render.call(this, data, _); | |
}; | |
// Provide the compiled function source as a convenience for precompilation. | |
template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; | |
return template; | |
}; | |
// Add a "chain" function, which will delegate to the wrapper. | |
_.chain = function(obj) { | |
return _(obj).chain(); | |
}; | |
// OOP | |
// --------------- | |
// If Underscore is called as a function, it returns a wrapped object that | |
// can be used OO-style. This wrapper holds altered versions of all the | |
// underscore functions. Wrapped objects may be chained. | |
// Helper function to continue chaining intermediate results. | |
var result = function(obj) { | |
return this._chain ? _(obj).chain() : obj; | |
}; | |
// Add all of the Underscore functions to the wrapper object. | |
_.mixin(_); | |
// Add all mutator Array functions to the wrapper. | |
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { | |
var method = ArrayProto[name]; | |
_.prototype[name] = function() { | |
var obj = this._wrapped; | |
method.apply(obj, arguments); | |
if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; | |
return result.call(this, obj); | |
}; | |
}); | |
// Add all accessor Array functions to the wrapper. | |
each(['concat', 'join', 'slice'], function(name) { | |
var method = ArrayProto[name]; | |
_.prototype[name] = function() { | |
return result.call(this, method.apply(this._wrapped, arguments)); | |
}; | |
}); | |
_.extend(_.prototype, { | |
// Start chaining a wrapped Underscore object. | |
chain: function() { | |
this._chain = true; | |
return this; | |
}, | |
// Extracts the result from a wrapped and chained object. | |
value: function() { | |
return this._wrapped; | |
} | |
}); | |
}).call(this); |
This file has been truncated, but you can view the full file.
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
/*! | |
* jQuery UI CSS Framework 1.8.24 | |
* | |
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://jquery.org/license | |
* | |
* http://docs.jquery.com/UI/Theming/API | |
*/ | |
/* Layout helpers | |
----------------------------------*/ | |
.ui-helper-hidden { display: none; } | |
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } | |
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } | |
.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; } | |
.ui-helper-clearfix:after { clear: both; } | |
.ui-helper-clearfix { zoom: 1; } | |
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } | |
/* Interaction Cues | |
----------------------------------*/ | |
.ui-state-disabled { cursor: default !important; } | |
/* Icons | |
----------------------------------*/ | |
/* states and images */ | |
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } | |
/* Misc visuals | |
----------------------------------*/ | |
/* Overlays */ | |
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } | |
/*! | |
* jQuery UI CSS Framework 1.8.24 | |
* | |
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://jquery.org/license | |
* | |
* http://docs.jquery.com/UI/Theming/API | |
* | |
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px | |
*/ | |
/* Component containers | |
----------------------------------*/ | |
.ui-widget { font-family: Segoe UI, Arial, sans-serif; font-size: 1.1em; } | |
.ui-widget .ui-widget { font-size: 1em; } | |
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Segoe UI, Arial, sans-serif; font-size: 1em; } | |
.ui-widget-content { border: 1px solid #666666; background: #000000 url(../images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x; color: #ffffff; } | |
.ui-widget-content a { color: #ffffff; } | |
.ui-widget-header { border: 1px solid #333333; background: #333333 url(../images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } | |
.ui-widget-header a { color: #ffffff; } | |
/* Interaction states | |
----------------------------------*/ | |
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #666666; background: #555555 url(../images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eeeeee; } | |
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #eeeeee; text-decoration: none; } | |
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #59b4d4; background: #0078a3 url(../images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } | |
.ui-state-hover a, .ui-state-hover a:hover { color: #ffffff; text-decoration: none; } | |
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #ffaf0f; background: #f58400 url(../images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } | |
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } | |
.ui-widget :active { outline: none; } | |
/* Interaction Cues | |
----------------------------------*/ | |
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #eeeeee url(../images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x; color: #2e7db2; } | |
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #2e7db2; } | |
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ffb73d; background: #ffc73d url(../images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x; color: #111111; } | |
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #111111; } | |
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #111111; } | |
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } | |
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } | |
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } | |
/* Icons | |
----------------------------------*/ | |
/* states and images */ | |
.ui-icon { width: 16px; height: 16px; background-image: url(../images/ui-icons_cccccc_256x240.png); } | |
.ui-widget-content .ui-icon {background-image: url(../images/ui-icons_cccccc_256x240.png); } | |
.ui-widget-header .ui-icon {background-image: url(../images/ui-icons_ffffff_256x240.png); } | |
.ui-state-default .ui-icon { background-image: url(../images/ui-icons_cccccc_256x240.png); } | |
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(../images/ui-icons_ffffff_256x240.png); } | |
.ui-state-active .ui-icon {background-image: url(../images/ui-icons_222222_256x240.png); } | |
.ui-state-highlight .ui-icon {background-image: url(../images/ui-icons_4b8e0b_256x240.png); } | |
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(../images/ui-icons_a83300_256x240.png); } | |
/* positioning */ | |
.ui-icon-carat-1-n { background-position: 0 0; } | |
.ui-icon-carat-1-ne { background-position: -16px 0; } | |
.ui-icon-carat-1-e { background-position: -32px 0; } | |
.ui-icon-carat-1-se { background-position: -48px 0; } | |
.ui-icon-carat-1-s { background-position: -64px 0; } | |
.ui-icon-carat-1-sw { background-position: -80px 0; } | |
.ui-icon-carat-1-w { background-position: -96px 0; } | |
.ui-icon-carat-1-nw { background-position: -112px 0; } | |
.ui-icon-carat-2-n-s { background-position: -128px 0; } | |
.ui-icon-carat-2-e-w { background-position: -144px 0; } | |
.ui-icon-triangle-1-n { background-position: 0 -16px; } | |
.ui-icon-triangle-1-ne { background-position: -16px -16px; } | |
.ui-icon-triangle-1-e { background-position: -32px -16px; } | |
.ui-icon-triangle-1-se { background-position: -48px -16px; } | |
.ui-icon-triangle-1-s { background-position: -64px -16px; } | |
.ui-icon-triangle-1-sw { background-position: -80px -16px; } | |
.ui-icon-triangle-1-w { background-position: -96px -16px; } | |
.ui-icon-triangle-1-nw { background-position: -112px -16px; } | |
.ui-icon-triangle-2-n-s { background-position: -128px -16px; } | |
.ui-icon-triangle-2-e-w { background-position: -144px -16px; } | |
.ui-icon-arrow-1-n { background-position: 0 -32px; } | |
.ui-icon-arrow-1-ne { background-position: -16px -32px; } | |
.ui-icon-arrow-1-e { background-position: -32px -32px; } | |
.ui-icon-arrow-1-se { background-position: -48px -32px; } | |
.ui-icon-arrow-1-s { background-position: -64px -32px; } | |
.ui-icon-arrow-1-sw { background-position: -80px -32px; } | |
.ui-icon-arrow-1-w { background-position: -96px -32px; } | |
.ui-icon-arrow-1-nw { background-position: -112px -32px; } | |
.ui-icon-arrow-2-n-s { background-position: -128px -32px; } | |
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } | |
.ui-icon-arrow-2-e-w { background-position: -160px -32px; } | |
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } | |
.ui-icon-arrowstop-1-n { background-position: -192px -32px; } | |
.ui-icon-arrowstop-1-e { background-position: -208px -32px; } | |
.ui-icon-arrowstop-1-s { background-position: -224px -32px; } | |
.ui-icon-arrowstop-1-w { background-position: -240px -32px; } | |
.ui-icon-arrowthick-1-n { background-position: 0 -48px; } | |
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } | |
.ui-icon-arrowthick-1-e { background-position: -32px -48px; } | |
.ui-icon-arrowthick-1-se { background-position: -48px -48px; } | |
.ui-icon-arrowthick-1-s { background-position: -64px -48px; } | |
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } | |
.ui-icon-arrowthick-1-w { background-position: -96px -48px; } | |
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } | |
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } | |
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } | |
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } | |
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } | |
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } | |
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } | |
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } | |
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } | |
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } | |
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } | |
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } | |
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } | |
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } | |
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } | |
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } | |
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } | |
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } | |
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } | |
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } | |
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } | |
.ui-icon-arrow-4 { background-position: 0 -80px; } | |
.ui-icon-arrow-4-diag { background-position: -16px -80px; } | |
.ui-icon-extlink { background-position: -32px -80px; } | |
.ui-icon-newwin { background-position: -48px -80px; } | |
.ui-icon-refresh { background-position: -64px -80px; } | |
.ui-icon-shuffle { background-position: -80px -80px; } | |
.ui-icon-transfer-e-w { background-position: -96px -80px; } | |
.ui-icon-transferthick-e-w { background-position: -112px -80px; } | |
.ui-icon-folder-collapsed { background-position: 0 -96px; } | |
.ui-icon-folder-open { background-position: -16px -96px; } | |
.ui-icon-document { background-position: -32px -96px; } | |
.ui-icon-document-b { background-position: -48px -96px; } | |
.ui-icon-note { background-position: -64px -96px; } | |
.ui-icon-mail-closed { background-position: -80px -96px; } | |
.ui-icon-mail-open { background-position: -96px -96px; } | |
.ui-icon-suitcase { background-position: -112px -96px; } | |
.ui-icon-comment { background-position: -128px -96px; } | |
.ui-icon-person { background-position: -144px -96px; } | |
.ui-icon-print { background-position: -160px -96px; } | |
.ui-icon-trash { background-position: -176px -96px; } | |
.ui-icon-locked { background-position: -192px -96px; } | |
.ui-icon-unlocked { background-position: -208px -96px; } | |
.ui-icon-bookmark { background-position: -224px -96px; } | |
.ui-icon-tag { background-position: -240px -96px; } | |
.ui-icon-home { background-position: 0 -112px; } | |
.ui-icon-flag { background-position: -16px -112px; } | |
.ui-icon-calendar { background-position: -32px -112px; } | |
.ui-icon-cart { background-position: -48px -112px; } | |
.ui-icon-pencil { background-position: -64px -112px; } | |
.ui-icon-clock { background-position: -80px -112px; } | |
.ui-icon-disk { background-position: -96px -112px; } | |
.ui-icon-calculator { background-position: -112px -112px; } | |
.ui-icon-zoomin { background-position: -128px -112px; } | |
.ui-icon-zoomout { background-position: -144px -112px; } | |
.ui-icon-search { background-position: -160px -112px; } | |
.ui-icon-wrench { background-position: -176px -112px; } | |
.ui-icon-gear { background-position: -192px -112px; } | |
.ui-icon-heart { background-position: -208px -112px; } | |
.ui-icon-star { background-position: -224px -112px; } | |
.ui-icon-link { background-position: -240px -112px; } | |
.ui-icon-cancel { background-position: 0 -128px; } | |
.ui-icon-plus { background-position: -16px -128px; } | |
.ui-icon-plusthick { background-position: -32px -128px; } | |
.ui-icon-minus { background-position: -48px -128px; } | |
.ui-icon-minusthick { background-position: -64px -128px; } | |
.ui-icon-close { background-position: -80px -128px; } | |
.ui-icon-closethick { background-position: -96px -128px; } | |
.ui-icon-key { background-position: -112px -128px; } | |
.ui-icon-lightbulb { background-position: -128px -128px; } | |
.ui-icon-scissors { background-position: -144px -128px; } | |
.ui-icon-clipboard { background-position: -160px -128px; } | |
.ui-icon-copy { background-position: -176px -128px; } | |
.ui-icon-contact { background-position: -192px -128px; } | |
.ui-icon-image { background-position: -208px -128px; } | |
.ui-icon-video { background-position: -224px -128px; } | |
.ui-icon-script { background-position: -240px -128px; } | |
.ui-icon-alert { background-position: 0 -144px; } | |
.ui-icon-info { background-position: -16px -144px; } | |
.ui-icon-notice { background-position: -32px -144px; } | |
.ui-icon-help { background-position: -48px -144px; } | |
.ui-icon-check { background-position: -64px -144px; } | |
.ui-icon-bullet { background-position: -80px -144px; } | |
.ui-icon-radio-off { background-position: -96px -144px; } | |
.ui-icon-radio-on { background-position: -112px -144px; } | |
.ui-icon-pin-w { background-position: -128px -144px; } | |
.ui-icon-pin-s { background-position: -144px -144px; } | |
.ui-icon-play { background-position: 0 -160px; } | |
.ui-icon-pause { background-position: -16px -160px; } | |
.ui-icon-seek-next { background-position: -32px -160px; } | |
.ui-icon-seek-prev { background-position: -48px -160px; } | |
.ui-icon-seek-end { background-position: -64px -160px; } | |
.ui-icon-seek-start { background-position: -80px -160px; } | |
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ | |
.ui-icon-seek-first { background-position: -80px -160px; } | |
.ui-icon-stop { background-position: -96px -160px; } | |
.ui-icon-eject { background-position: -112px -160px; } | |
.ui-icon-volume-off { background-position: -128px -160px; } | |
.ui-icon-volume-on { background-position: -144px -160px; } | |
.ui-icon-power { background-position: 0 -176px; } | |
.ui-icon-signal-diag { background-position: -16px -176px; } | |
.ui-icon-signal { background-position: -32px -176px; } | |
.ui-icon-battery-0 { background-position: -48px -176px; } | |
.ui-icon-battery-1 { background-position: -64px -176px; } | |
.ui-icon-battery-2 { background-position: -80px -176px; } | |
.ui-icon-battery-3 { background-position: -96px -176px; } | |
.ui-icon-circle-plus { background-position: 0 -192px; } | |
.ui-icon-circle-minus { background-position: -16px -192px; } | |
.ui-icon-circle-close { background-position: -32px -192px; } | |
.ui-icon-circle-triangle-e { background-position: -48px -192px; } | |
.ui-icon-circle-triangle-s { background-position: -64px -192px; } | |
.ui-icon-circle-triangle-w { background-position: -80px -192px; } | |
.ui-icon-circle-triangle-n { background-position: -96px -192px; } | |
.ui-icon-circle-arrow-e { background-position: -112px -192px; } | |
.ui-icon-circle-arrow-s { background-position: -128px -192px; } | |
.ui-icon-circle-arrow-w { background-position: -144px -192px; } | |
.ui-icon-circle-arrow-n { background-position: -160px -192px; } | |
.ui-icon-circle-zoomin { background-position: -176px -192px; } | |
.ui-icon-circle-zoomout { background-position: -192px -192px; } | |
.ui-icon-circle-check { background-position: -208px -192px; } | |
.ui-icon-circlesmall-plus { background-position: 0 -208px; } | |
.ui-icon-circlesmall-minus { background-position: -16px -208px; } | |
.ui-icon-circlesmall-close { background-position: -32px -208px; } | |
.ui-icon-squaresmall-plus { background-position: -48px -208px; } | |
.ui-icon-squaresmall-minus { background-position: -64px -208px; } | |
.ui-icon-squaresmall-close { background-position: -80px -208px; } | |
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } | |
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } | |
.ui-icon-grip-solid-vertical { background-position: -32px -224px; } | |
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } | |
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } | |
.ui-icon-grip-diagonal-se { background-position: -80px -224px; } | |
/* Misc visuals | |
----------------------------------*/ | |
/* Corner radius */ | |
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-left-radius: 6px; border-top-left-radius: 6px; } | |
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; -khtml-border-top-right-radius: 6px; border-top-right-radius: 6px; } | |
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; -khtml-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } | |
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; -khtml-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } | |
/* Overlays */ | |
.ui-widget-overlay { background: #5c5c5c url(../images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x; opacity: .80;filter:Alpha(Opacity=80); } | |
.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #cccccc url(../images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*! | |
* jQuery UI Resizable 1.8.24 | |
* | |
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://jquery.org/license | |
* | |
* http://docs.jquery.com/UI/Resizable#theming | |
*/ | |
.ui-resizable { position: relative;} | |
.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; } | |
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } | |
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } | |
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } | |
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } | |
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } | |
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } | |
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } | |
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } | |
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*! | |
* jQuery UI Selectable 1.8.24 | |
* | |
* Cop |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment