Commit d31fbf88 authored by S Anand's avatar S Anand

BLD: commit current builds

parent 76583113
This diff is collapsed.
(function(t,n){var r=/^(=|!=|~|!~|>=|<=|>|<)/,i=t.encodeURIComponent,e=["where","sort","value","fields","column"],s=["limit","offset","format","table","download"];function u(t){var n=this;n.url=t;n.clear()}u.prototype.clear=function(){var t=this;t.attrs={};e.forEach(function(n){t.attrs[n]={}});return this};function o(t,n,r,i){if(r===null){if(n in t)delete t[n]}else if(typeof i!="undefined"&&typeof r=="undefined"){t[n]=i}else{t[n]=r}}function f(t,n,r,i){var e;if(n===null)for(e in t)delete t[e];else if($.isPlainObject(n))for(e in n)o(t,e,n[e],i);else if($.isArray(n))for(var s=0,u=n.length;s<u;s++)o(t,n[s],r,i);else o(t,n,r,i)}function a(t,n,i,e){if($.isPlainObject(n)){for(var s in n){e=n[s];if(e!==null)if(typeof e!="string"||!e.match(r))n[s]="="+e}f(t,n)}else{if(typeof e=="undefined"){e=i;e=typeof e=="string"&&e.match(r)?e:e===null?null:"="+e}else{e=i+e}f(t,n,e)}}function l(t,n,r){var i=t.params(),e={type:n,url:t.url,data:i};if(n=="DELETE"&&i)e.url+="?"+i;return $.ajax(e).done(r)}$.extend(u.prototype,{where:function(t,n,r){a(this.attrs.where,t,n,r);return this},value:function(t,n){a(this.attrs.value,t,n);return this},column:function(t,n){a(this.attrs.column,t,n);return this},sort:function(t,n){f(this.attrs.sort,t,n,true);return this},fields:function(t,n){f(this.attrs.fields,t,n,true);return this},limit:function(t){f(this.attrs,"limit",t);return this},offset:function(t){f(this.attrs,"offset",t);return this},format:function(t){f(this.attrs,"format",t);return this},table:function(t){f(this.attrs,"table",t);return this},download:function(t){f(this.attrs,"download",t);return this},get:function(t){return l(this,"GET",t)},put:function(t){return l(this,"PUT",t)},post:function(t){return l(this,"POST",t)},del:function(t){return l(this,"DELETE",t)}});u.prototype.params=function(){var t=[],n=this;e.forEach(function(r){var e=r.match(/sort|fields/),s=$.map(n.attrs[r],function(t,n){var r=e?t?n:"-"+n:n+t;if(r.match(/[",]/))r='"'+r.replace(/"/g,'""')+'"';return r}).join(",");if(s)t.push(r+"="+i(s))});s.forEach(function(r){if(r in n.attrs)t.push(r+"="+i(n.attrs[r]))});return t.join("&")};u.prototype.toString=function(){var t=this.params();return t?this.url+"?"+t:this.url};if("jQuery"in t)t.jQuery.db=function(t){return new u(t)};else t.db=function(t){return new u(t)}})(this);
\ No newline at end of file
......@@ -158,17 +158,21 @@
return self;
};
_url_update = function(args, mode) {
var self = this, search_key = self[_url_parse_qname[0]], search_list = self[_url_parse_qname[1]], qparts = [], key, val, i, l, hash, search_list_key, result;
var self = this, search_key = self[_url_parse_qname[0]], search_list = self[_url_parse_qname[1]], qparts = [], modes = {}, key, val, i, l, hash, search_list_key, result;
if (mode) {
mode = "" + mode;
if (mode.match(/[&=]/)) modes = _url_parse("?" + mode).searchKey; else for (key in args) modes[key] = mode;
}
for (key in args) {
val = args[key];
if (val === null) {
search_list[key] = [];
} else {
if (!_is_array(val)) val = [ val ];
if (!mode) search_list[key] = val; else {
if (!modes[key]) search_list[key] = val; else {
if (!(key in search_list)) search_list[key] = [];
for (hash = {}, i = 0, l = val.length; i < l; i++) hash[val[i].toString()] = 1;
mode = "" + mode;
mode = "" + modes[key];
if (mode.match(/add/i)) search_list[key] = search_list[key].concat(val); else if (mode.match(/del/i)) {
for (result = [], search_list_key = search_list[key], i = 0, l = search_list_key.length; i < l; i++) {
if (!hash[search_list_key[i]]) result.push(search_list_key[i]);
......@@ -370,7 +374,9 @@
};
G.zoom = function(options) {
options = options || {};
var selector = options.selector, speed = options.speed || 50, container = d3.select(selector), children = d3.selectAll(container.node().children), abruptzoom = d3.behavior.zoom().on("zoom", function() {
var selector = options.selector, speed = options.speed || 50, container = d3.select(selector), children = d3.selectAll(container.node().childNodes).filter(function() {
return this.nodeName != "#text";
}), abruptzoom = d3.behavior.zoom().on("zoom", function() {
children.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
smoothzoom.translate(d3.event.translate).scale(d3.event.scale);
}), smoothzoom = d3.behavior.zoom().on("zoom", function() {
......@@ -383,7 +389,12 @@
} else {
container.call(abruptzoom).classed("zoom", false);
}
return {
var self = {
on: function(event, handler) {
smoothzoom.on(event, handler);
abruptzoom.on(event, handler);
return self;
},
to: function(nodes) {
var bounds = {}, i = 0, el, box, trans, scale;
if (!nodes || !nodes.length) {
......@@ -405,8 +416,10 @@
bounds.height = bounds.y2 - bounds.y;
scale = Math.min(width / bounds.width, height / bounds.height) * .7;
smoothzoom.translate([ (-bounds.x - bounds.width / 2) * scale + width / 2, (-bounds.y - bounds.height / 2) * scale + height / 2 ]).scale(scale).event(container);
return self;
}
};
return self;
};
var $ = global.jQuery, jQuery = $, findall = function(node, selector) {
return node.filter(selector).add(node.find(selector));
......@@ -976,27 +989,14 @@
d.y += (d.y0 - d.y) * k;
};
}
function collide(k) {
var q = d3.geom.quadtree(nodes);
return function(node) {
var nr = node.r, nx1 = node.x - nr, nx2 = node.x + nr, ny1 = node.y - nr, ny2 = node.y + nr;
q.visit(function(quad, x1, y1, x2, y2) {
if (quad.point && quad.point !== node) {
var x = node.x - quad.point.x, y = node.y - quad.point.y, l = x * x + y * y, r = nr + quad.point.r;
if (l < r * r) {
l = ((l = Math.sqrt(l)) - r) / l * k;
node.x -= x *= l;
node.y -= y *= l;
quad.point.x += x;
quad.point.y += y;
}
}
return x1 > nx2 || x2 < nx1 || y1 > ny2 || y2 < ny1;
});
};
}
var collide = G.network.collide.circle(function(node) {
return node.r;
});
force.size([ width, height ]).nodes(nodes).on("tick", function tick(e) {
update.each(gravity(e.alpha * .1)).each(collide(.5)).attr("transform", function(d) {
update.each(gravity(e.alpha * .1));
var q = d3.geom.quadtree(nodes), i = 0;
while (++i < l) q.visit(collide(nodes[i]));
update.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")";
});
}).start();
......@@ -1019,7 +1019,7 @@
return self.force(d3.layout.force().charge(0).gravity(.01));
};
G.map = function() {
var shape, width, height, projection, path, unpack, size = function() {
var shape, width, height, projection, path, unpack, draw_label, size = function() {
return 5;
}, self = {};
function center_shape() {
......@@ -1027,19 +1027,32 @@
var b = path.bounds(shape), s = .95 / Math.max((b[1][0] - b[0][0]) / width, (b[1][1] - b[0][1]) / height), t = [ (width - s * (b[1][0] + b[0][0])) / 2, (height - s * (b[1][1] + b[0][1])) / 2 ];
projection.scale(s).translate(t);
}
function add_labels(selection) {
if (!draw_label) return;
var update = selection.selectAll("text.map").data(shape.features);
update.transition();
update.enter().append("text").attr("text-anchor", "middle").attr("dy", "0.35em").attr("class", "map");
update.exit().remove();
update.attr("transform", function(d) {
var centroid = path.centroid(d);
return "translate(" + centroid[0] + "," + centroid[1] + ")";
});
draw_label(update);
return self;
}
self.map = function(selection) {
center_shape();
var update = selection.selectAll("path.map").data(shape.features);
update.transition().attr("transform", null).attr("d", path);
update.enter().append("path").attr("class", "map").attr("transform", null).attr("d", path);
update.exit().remove();
add_labels(selection);
return update;
};
self.dorling = function(selection) {
center_shape();
var circle_path = function(d, i) {
var r = size(d, i);
return r > 0 ? "M0,0m-{r},0a{r},{r} 0 1,0 {d},0a{r},{r} 0 1,0 -{d},0".replace(/\{r\}/g, r).replace(/\{d\}/g, 2 * r) : "M0,0";
var circle_path = function(d) {
return d.r > 0 ? "M0,0m-{r},0a{r},{r} 0 1,0 {d},0a{r},{r} 0 1,0 -{d},0".replace(/\{r\}/g, d.r).replace(/\{d\}/g, 2 * d.r) : "M0,0";
}, nodes = shape.features.map(function(d, i) {
var centroid = path.centroid(d.geometry);
return typeof centroid === "undefined" ? {
......@@ -1052,17 +1065,14 @@
properties: d.properties
};
}), update = selection.selectAll("path.map").data(nodes);
update.attr("d", circle_path).attr("transform", function(d, i) {
return "scale(" + size(d, i) + ")";
});
update.enter().append("path").attr("class", "map").attr("transform", function(d, i) {
return "scale(" + size(d, i) + ")";
}).attr("d", circle_path);
update.attr("d", circle_path);
update.enter().append("path").attr("class", "map").attr("d", circle_path);
update.exit().remove();
if (!unpack) {
unpack = G.unpack().width(width).height(height);
}
unpack(update);
add_labels(selection);
return update;
};
self.shape = function(v) {
......@@ -1095,6 +1105,11 @@
path = v;
return self;
};
self.label = function(v) {
if (!arguments.length) return draw_label;
draw_label = v;
return self;
};
self.projection = function(v) {
if (!arguments.length) return projection;
projection = v;
......@@ -1260,7 +1275,7 @@
return self;
};
_G_network.force = function() {
var data, node_filter = {}, link_filter = {}, nodes, node_ids, links, brush = d3.svg.brush(), force = d3.layout.force(), self = {
var data, node_filter = {}, link_filter = {}, nodes, node_ids, links, collide, brush = d3.svg.brush(), force = d3.layout.force(), self = {
force: force,
brush: brush
};
......@@ -1280,6 +1295,10 @@
}
var draw_label;
force.on("tick", function() {
if (collide) {
var q = d3.geom.quadtree(nodes), i = 0, n = nodes.length;
while (++i < n) q.visit(collide(nodes[i]));
}
self.lines.attr("x1", function(d) {
return d.source.x;
}).attr("y1", function(d) {
......@@ -1368,9 +1387,14 @@
draw_line = v;
return self;
};
self.collide = function(v) {
if (!arguments.length) return collide;
collide = v;
return self;
};
self.draw = function(svg) {
svg = d3.select(svg);
var width = +svg.attr("width"), height = +svg.attr("height"), enter;
var svg_node = svg.node(), viewbox = svg_node.viewBox.baseVal, size = svg_node.getBoundingClientRect(), width = viewbox.width || size.width, height = viewbox.height || size.height, enter;
force.size([ width, height ]);
var $brush = svg.select("g.brush");
if ($brush.empty()) $brush = svg.append("g").attr("class", "brush");
......@@ -1435,6 +1459,27 @@
};
return self;
};
_G_network.collide = {
circle: function(radius_function, padding) {
padding = padding || 0;
return function(node) {
var r = radius_function(node) + padding, nx1 = node.x - r, nx2 = node.x + r, ny1 = node.y - r, ny2 = node.y + r;
return function(quad, x1, y1, x2, y2) {
if (quad.point && quad.point !== node) {
var x = node.x - quad.point.x, y = node.y - quad.point.y, l = Math.sqrt(x * x + y * y), r = radius_function(node) + padding + radius_function(quad.point);
if (l < r) {
l = (l - r) / l * .5;
node.x -= x *= l;
node.y -= y *= l;
quad.point.x += x;
quad.point.y += y;
}
}
return x1 > nx2 || x2 < nx1 || y1 > ny2 || y2 < ny1;
};
};
}
};
G.url = {
parse: _url_parse,
unparse: _url_unparse
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment