├── .gitignore
├── .rvmrc
├── Gemfile
├── Gemfile.lock
├── README.markdown
├── config.ru
├── jquery-graphie.rb
├── public
├── images
│ └── jq_bg.png
└── javascript
│ ├── demo.js
│ ├── jquery.graphie.js
│ └── lib
│ └── raphael.js
└── views
├── index.haml
└── stylesheets
├── application.sass
└── reset.scss
/.gitignore:
--------------------------------------------------------------------------------
1 | .sass-cache
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/.rvmrc:
--------------------------------------------------------------------------------
1 | rvm_gemset_create_on_use_flag=1
2 | rvm use 1.8.7@jquery-graphie
3 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'haml'
4 | gem 'sass'
5 | gem 'hassle'
6 | gem 'sinatra'
7 | gem 'rdiscount'
8 |
9 | group :development do
10 | gem 'heroku'
11 | gem 'sinatra-reloader'
12 | end
13 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: http://rubygems.org/
3 | specs:
4 | backports (2.2.1)
5 | configuration (1.3.1)
6 | haml (3.1.2)
7 | hassle (0.0.1)
8 | haml
9 | rack
10 | heroku (2.3.3)
11 | launchy (>= 0.3.2)
12 | rest-client (~> 1.6.1)
13 | term-ansicolor (~> 1.0.5)
14 | launchy (0.4.0)
15 | configuration (>= 0.0.5)
16 | rake (>= 0.8.1)
17 | mime-types (1.16)
18 | monkey-lib (0.5.4)
19 | backports
20 | rack (1.3.0)
21 | rake (0.9.2)
22 | rdiscount (1.6.8)
23 | rest-client (1.6.3)
24 | mime-types (>= 1.16)
25 | sass (3.1.3)
26 | sinatra (1.2.6)
27 | rack (~> 1.1)
28 | tilt (>= 1.2.2, < 2.0)
29 | sinatra-advanced-routes (0.5.1)
30 | monkey-lib (~> 0.5.0)
31 | sinatra (~> 1.0)
32 | sinatra-sugar (~> 0.5.0)
33 | sinatra-reloader (0.5.0)
34 | sinatra (~> 1.0)
35 | sinatra-advanced-routes (~> 0.5.0)
36 | sinatra-sugar (0.5.1)
37 | monkey-lib (~> 0.5.0)
38 | sinatra (~> 1.0)
39 | term-ansicolor (1.0.5)
40 | tilt (1.3.2)
41 |
42 | PLATFORMS
43 | ruby
44 |
45 | DEPENDENCIES
46 | haml
47 | hassle
48 | heroku
49 | rdiscount
50 | sass
51 | sinatra
52 | sinatra-reloader
53 |
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | # Graphie
2 |
3 | A cute little graphing library with an adorably minimal amount of functionality.
4 |
5 | Visit [http://jquery-graphie.heroku.com]() for examples.
6 |
7 | ## Using graphie
8 |
9 | - Include [Raphael](http://raphaeljs.com/) and [the plugin](https://github.com/camerond/jquery-graphie/blob/master/public/javascript/jquery.graphie.js).
10 | - Call `$.graphie()` on any `
`, `` or `` that contains numeric values.
11 | - Graphie will add a class of 'graphie' on any object that it draws within, allowing you to set dimensions & background color of that object in CSS.
12 |
13 | ## Options (defaults shown)
14 |
15 | $item.graphie({
16 | type: 'line', // can be either 'line' or 'column'
17 | line: {
18 | bgcolor: '#5ad0ea', // Background color of line/columns. Set to false for no background.
19 | smoothing: 'auto', // You can set an arbitrary line smoothing value here (number without 'px'). Change to 0 for straight lines.
20 | column_width: 'auto' // You can set an arbitrary width here (number without 'px').
21 | stroke: '#5ad0ea' // Stroke color
22 | stroke_width: 0 // Stroke width. Looks best with no bgcolor.
23 | },
24 | labels: {
25 | x: 5, // Label distance from sides
26 | y: 5, // Label distance from bottom
27 | color: '#000', // These
28 | family: 'Helvetica', // are
29 | weight: 'bold', // obvious,
30 | size: 12 // right?
31 | }
32 | });
33 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'bundler'
3 |
4 | Bundler.require
5 |
6 | require './jquery-graphie'
7 | run Sinatra::Application
--------------------------------------------------------------------------------
/jquery-graphie.rb:
--------------------------------------------------------------------------------
1 | require 'sinatra'
2 | require 'haml'
3 |
4 | require "sinatra/reloader" if development?
5 |
6 | before do
7 | response.headers['Cache-Control'] = 'public, max-age=604800' if production?
8 | end
9 |
10 | get '/stylesheets/*.css' do |f|
11 | sass ('/stylesheets/' + f).to_sym
12 | end
13 |
14 | get '/' do
15 | haml :index
16 | end
17 |
--------------------------------------------------------------------------------
/public/images/jq_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/camerond/jquery-graphie/8b5b1731690d3b6a5fe17591fdcd95cea34a3006/public/images/jq_bg.png
--------------------------------------------------------------------------------
/public/javascript/demo.js:
--------------------------------------------------------------------------------
1 | $(function() {
2 |
3 | $('#normal').graphie();
4 |
5 | $('#options').graphie({
6 | line: {
7 | bgcolor: "#31363b",
8 | smoothing: 10,
9 | },
10 | labels: {
11 | color: '#ffd800',
12 | x: 20,
13 | y: 20,
14 | size: 20,
15 | weight: 'normal'
16 | }
17 | });
18 |
19 | $('#teeny').graphie();
20 |
21 | $('#columns').graphie({
22 | type: 'column',
23 | line: {
24 | bgcolor: "#fff"
25 | }
26 | });
27 |
28 | $("#line").graphie({
29 | line: {
30 | bgcolor: false,
31 | stroke_width: 1,
32 | stroke: '#000',
33 | smoothing: 0
34 | }
35 | });
36 |
37 | });
--------------------------------------------------------------------------------
/public/javascript/jquery.graphie.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | jQuery Graphie Plugin
4 | version 0.2.3
5 |
6 | Copyright (c) 2011 Cameron Daigle, http://camerondaigle.com
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining
9 | a copy of this software and associated documentation files (the
10 | "Software"), to deal in the Software without restriction, including
11 | without limitation the rights to use, copy, modify, merge, publish,
12 | distribute, sublicense, and/or sell copies of the Software, and to
13 | permit persons to whom the Software is furnished to do so, subject to
14 | the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be
17 | included in all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 |
27 | */
28 |
29 | (function($) {
30 |
31 | var opts;
32 |
33 | $.fn.graphie = function(options) {
34 | var defaults = {
35 | type: 'line',
36 | line: {
37 | bgcolor: '#5ad0ea',
38 | smoothing: 'auto',
39 | stroke: '#5ad0ea',
40 | stroke_width: 0,
41 | column_width: 'auto'
42 | },
43 | labels: {
44 | x: 5,
45 | y: 5,
46 | color: '#000',
47 | family: 'Helvetica, arial, sans-serif',
48 | weight: 'bold',
49 | size: 12
50 | }
51 | };
52 | return this.each(function() {
53 | opts = $.extend(true, defaults, options);
54 | var graph = initGraph($(this));
55 | var data = parseData($(this));
56 | drawLine(graph, data.points);
57 | attachLabels(graph, data.labels);
58 | });
59 |
60 | };
61 |
62 | function initGraph($el) {
63 | $el.addClass('graphie');
64 | opts.w = $el.width();
65 | opts.h = $el.height();
66 | $el.children().hide();
67 | return Raphael($el.attr('id'), opts.w, opts.h);
68 | }
69 |
70 | function parseData($el) {
71 | var data = {
72 | points: [],
73 | labels: []
74 | };
75 | var parsers = {
76 | 'dl': function() {
77 | data.labels.push($el.find('dt:first').text());
78 | data.labels.push($el.find('dt:last').text());
79 | $el.find('dd').each(function() {
80 | data.points.push(parseInt($(this).text(), 10));
81 | });
82 | return data;
83 | },
84 | 'ul': function() {
85 | $el.find('li').each(function() {
86 | data.points.push(parseInt($(this).text(), 10));
87 | });
88 | return data;
89 | }
90 | };
91 | parsers.ol = parsers.ul;
92 | return parsers[$el[0].tagName.toLowerCase()]();
93 | };
94 |
95 | function drawLine(graph, points) {
96 | var coords = 'M0 ' + opts.h,
97 | line = graph.path(coords).attr({stroke: opts.line.stroke, "stroke-width": opts.line.stroke_width, fill: opts.line.bgcolor}),
98 | scale = getYScale(points),
99 | x, y, interval;
100 | var types = {
101 | 'line': function() {
102 | interval = opts.w / (points.length - 1);
103 | opts.line.smoothing === 'auto' ? opts.line.smoothing = interval / 2 : false;
104 | if (!opts.line.bgcolor) {
105 | coords = 'M0 ' + (opts.h - (scale * points[0]));
106 | }
107 | for(var i = 0, j = points.length; i < j; i++) {
108 | x = interval * i;
109 | y = (opts.h - (scale * points[i]));
110 | coords += ' S' + (x - opts.line.smoothing) + ' ' + y + ' ' + x + ' ' + y;
111 | }
112 | if (opts.line.bgcolor) {
113 | coords += ' L' + opts.w + ' ' + opts.h;
114 | }
115 | return coords;
116 | },
117 | 'column': function() {
118 | if (opts.line.column_width === 'auto') {
119 | interval = (opts.w - points.length - 1) / points.length;
120 | } else {
121 | interval = +opts.line.column_width;
122 | }
123 | interval = interval > 1 ? Math.floor(interval) : 1;
124 | coords += ' L';
125 | x = 0;
126 | for(var i = 0, j = points.length; i < j; i++) {
127 | y = Math.floor(opts.h - (scale * points[i]));
128 | coords += x + ' ' + y + ' ' + (x + interval) + ' ' + y + ' ' + (x + interval) + ' ' + opts.h + ' ' + (x + interval + 1) + ' ' + opts.h + ' ';
129 | x = x + interval + 1;
130 | }
131 | return coords;
132 | }
133 | };
134 | return line.attr({path: types[opts.type]()});
135 | }
136 |
137 | function attachLabels(graph, labels) {
138 | var text_attrs = {
139 | font: opts.labels.weight + ' ' + opts.labels.size + 'px ' + opts.labels.family,
140 | fill: opts.labels.color,
141 | 'text-anchor': 'start'
142 | };
143 | graph.text(opts.labels.x, opts.h - opts.labels.y - opts.labels.size / 2, labels[0]).attr(text_attrs);
144 | var right_caption = graph.text(opts.w - opts.labels.x, opts.h - opts.labels.y - opts.labels.size / 2, labels.pop()).attr(text_attrs);
145 | right_caption.attr({ 'text-anchor': 'end' });
146 | }
147 |
148 | function getYScale(points) {
149 | return opts.h / Math.max.apply(Math, points);
150 | }
151 |
152 | })(jQuery);
--------------------------------------------------------------------------------
/public/javascript/lib/raphael.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Raphael 1.4.3 - JavaScript Vector Library
3 | *
4 | * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
5 | * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6 | */
7 | Raphael=function(){function m(){if(m.is(arguments[0],U)){for(var a=arguments[0],b=Aa[K](m,a.splice(0,3+m.is(a[0],O))),c=b.set(),d=0,f=a[o];d
";if(ha.childNodes[o]!=2)return m.type=null;ha=null}m.svg=!(m.vml=m.type=="VML");G[p]=m[p];m._id=0;m._oid=0;m.fn={};m.is=function(a,b){b=ca.call(b);return b=="object"&&a===Object(a)||b=="undefined"&&typeof a==b||b=="null"&&a==null||ca.call(ob.call(a).slice(8,-1))==b};m.setWindow=function(a){X=a;C=X.document};function ra(a){if(m.vml){var b=/^\s+|\s+$/g;ra=T(function(d){var f;d=(d+s)[I](b,
12 | s);try{var e=new X.ActiveXObject("htmlfile");e.write("");e.close();f=e.body}catch(g){f=X.createPopup().document.body}e=f.createTextRange();try{f.style.color=d;var h=e.queryCommandValue("ForeColor");h=(h&255)<<16|h&65280|(h&16711680)>>>16;return"#"+("000000"+h[N](16)).slice(-6)}catch(i){return"none"}})}else{var c=C.createElement("i");c.title="Rapha\u00ebl Colour Picker";c.style.display="none";C.body[y](c);ra=T(function(d){c.style.color=d;return C.defaultView.getComputedStyle(c,s).getPropertyValue("color")})}return ra(a)}
13 | function qb(){return"hsb("+[this.h,this.s,this.b]+")"}function rb(){return this.hex}m.hsb2rgb=T(function(a,b,c){if(m.is(a,"object")&&"h"in a&&"s"in a&&"b"in a){c=a.b;b=a.s;a=a.h}var d;if(c==0)return{r:0,g:0,b:0,hex:"#000"};if(a>1||b>1||c>1){a/=255;b/=255;c/=255}d=~~(a*6);a=a*6-d;var f=c*(1-b),e=c*(1-b*a),g=c*(1-b*(1-a));a=[c,e,f,f,g,c,c][d];b=[g,c,c,e,f,f,g][d];d=[f,f,g,c,c,e,f][d];a*=255;b*=255;d*=255;c={r:a,g:b,b:d,toString:rb};a=(~~a)[N](16);b=(~~b)[N](16);d=(~~d)[N](16);a=a[I](ga,"0");b=b[I](ga,
14 | "0");d=d[I](ga,"0");c.hex="#"+a+b+d;return c},m);m.rgb2hsb=T(function(a,b,c){if(m.is(a,"object")&&"r"in a&&"g"in a&&"b"in a){c=a.b;b=a.g;a=a.r}if(m.is(a,ea)){var d=m.getRGB(a);a=d.r;b=d.g;c=d.b}if(a>1||b>1||c>1){a/=255;b/=255;c/=255}var f=Y(a,b,c),e=$(a,b,c);d=f;if(e==f)return{h:0,s:0,b:f};else{var g=f-e;e=g/f;a=a==f?(b-c)/g:b==f?2+(c-a)/g:4+(a-b)/g;a/=6;a<0&&a++;a>1&&a--}return{h:a,s:e,b:d,toString:qb}},m);var sb=/,?([achlmqrstvxz]),?/gi,sa=/\s*,\s*/,tb={hs:1,rg:1};m._path2string=function(){return this.join(",")[I](sb,
15 | "$1")};function T(a,b,c){function d(){var f=Array[p].slice.call(arguments,0),e=f[Q]("\u25ba"),g=d.cache=d.cache||{},h=d.count=d.count||[];if(g[z](e))return c?c(g[e]):g[e];h[o]>=1000&&delete g[h.shift()];h[E](e);g[e]=a[K](b,f);return c?c(g[e]):g[e]}return d}m.getRGB=T(function(a){if(!a||(a+=s).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if(a=="none")return{r:-1,g:-1,b:-1,hex:"none"};!(tb[z](a.substring(0,2))||a.charAt()=="#")&&(a=ra(a));var b,c,d,f,e;if(a=a.match(pb)){if(a[2]){d=da(a[2].substring(5),
16 | 16);c=da(a[2].substring(3,5),16);b=da(a[2].substring(1,3),16)}if(a[3]){d=da((e=a[3].charAt(3))+e,16);c=da((e=a[3].charAt(2))+e,16);b=da((e=a[3].charAt(1))+e,16)}if(a[4]){a=a[4][H](sa);b=A(a[0]);c=A(a[1]);d=A(a[2]);f=A(a[3])}if(a[5]){a=a[5][H](sa);b=A(a[0])*2.55;c=A(a[1])*2.55;d=A(a[2])*2.55;f=A(a[3])}if(a[6]){a=a[6][H](sa);b=A(a[0]);c=A(a[1]);d=A(a[2]);return m.hsb2rgb(b,c,d)}if(a[7]){a=a[7][H](sa);b=A(a[0])*2.55;c=A(a[1])*2.55;d=A(a[2])*2.55;return m.hsb2rgb(b,c,d)}a={r:b,g:c,b:d};b=(~~b)[N](16);
17 | c=(~~c)[N](16);d=(~~d)[N](16);b=b[I](ga,"0");c=c[I](ga,"0");d=d[I](ga,"0");a.hex="#"+b+c+d;isFinite(A(f))&&(a.o=f);return a}return{r:-1,g:-1,b:-1,hex:"none",error:1}},m);m.getColor=function(a){a=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||0.75};var b=this.hsb2rgb(a.h,a.s,a.b);a.h+=0.075;if(a.h>1){a.h=0;a.s-=0.2;a.s<=0&&(this.getColor.start={h:0,s:1,b:a.b})}return b.hex};m.getColor.reset=function(){delete this.start};var ub=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,
18 | vb=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;m.parsePathString=T(function(a){if(!a)return null;var b={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},c=[];if(m.is(a,U)&&m.is(a[0],U))c=ta(a);c[o]||(a+s)[I](ub,function(d,f,e){var g=[];d=ca.call(f);e[I](vb,function(h,i){i&&g[E](+i)});if(d=="m"&&g[o]>2){c[E]([f][M](g.splice(0,2)));d="l";f=f=="m"?"l":"L"}for(;g[o]>=b[d];){c[E]([f][M](g.splice(0,b[d])));if(!b[d])break}});c[N]=m._path2string;return c});m.findDotsAtSegment=function(a,b,c,d,f,e,g,h,i){var j=1-i,l=
19 | D(j,3)*a+D(j,2)*3*i*c+j*3*i*i*f+D(i,3)*g;j=D(j,3)*b+D(j,2)*3*i*d+j*3*i*i*e+D(i,3)*h;var n=a+2*i*(c-a)+i*i*(f-2*c+a),r=b+2*i*(d-b)+i*i*(e-2*d+b),q=c+2*i*(f-c)+i*i*(g-2*f+c),k=d+2*i*(e-d)+i*i*(h-2*e+d);a=(1-i)*a+i*c;b=(1-i)*b+i*d;f=(1-i)*f+i*g;e=(1-i)*e+i*h;h=90-w.atan((n-q)/(r-k))*180/w.PI;(n>q||r1){B=w.sqrt(B);c=B*c;d=B*d}B=c*c;var L=d*d;B=(e==g?-1:1)*w.sqrt(w.abs((B*L-B*x*x-L*k*k)/(B*x*x+L*k*k)));e=B*c*x/d+(a+h)/2;var B=
25 | B*-d*k/c+(b+i)/2,x=w.asin(((b-B)/d).toFixed(7));k=w.asin(((i-B)/d).toFixed(7));x=ak)x-=l*2;if(!g&&k>x)k-=l*2}l=k-x;if(w.abs(l)>n){q=k;l=h;L=i;k=x+n*(g&&k>x?1:-1);h=e+c*w.cos(k);i=B+d*w.sin(k);q=Qa(h,i,c,d,f,0,g,l,L,[k,q,e,B])}l=k-x;f=w.cos(x);e=w.sin(x);g=w.cos(k);k=w.sin(k);l=w.tan(l/4);c=4/3*c*l;l=4/3*d*l;d=[a,b];a=[a+c*e,b-l*f];b=[h+c*k,i-l*g];h=[h,i];a[0]=2*d[0]-a[0];a[1]=2*d[1]-a[1];if(j)return[a,b,h][M](q);else{q=[a,b,h][M](q)[Q]()[H](",");
26 | j=[];h=0;for(i=q[o];h1000000000000&&(n=0.5);w.abs(i)>1000000000000&&(i=0.5);if(n>0&&n<1){n=la(a,b,c,d,f,e,g,h,n);q[E](n.x);r[E](n.y)}if(i>
27 | 0&&i<1){n=la(a,b,c,d,f,e,g,h,i);q[E](n.x);r[E](n.y)}i=e-2*d+b-(h-2*e+d);j=2*(d-b)-2*(e-d);l=b-d;n=(-j+w.sqrt(j*j-4*i*l))/2/i;i=(-j-w.sqrt(j*j-4*i*l))/2/i;w.abs(n)>1000000000000&&(n=0.5);w.abs(i)>1000000000000&&(i=0.5);if(n>0&&n<1){n=la(a,b,c,d,f,e,g,h,n);q[E](n.x);r[E](n.y)}if(i>0&&i<1){n=la(a,b,c,d,f,e,g,h,i);q[E](n.x);r[E](n.y)}return{min:{x:$[K](0,q),y:$[K](0,r)},max:{x:Y[K](0,q),y:Y[K](0,r)}}}),ua=T(function(a,b){var c=ka(a),d=b&&ka(b);a={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};b={x:0,y:0,
28 | bx:0,by:0,X:0,Y:0,qx:null,qy:null};function f(q,k){var t;if(!q)return["C",k.x,k.y,k.x,k.y,k.x,k.y];!(q[0]in{T:1,Q:1})&&(k.qx=k.qy=null);switch(q[0]){case "M":k.X=q[1];k.Y=q[2];break;case "A":q=["C"][M](Qa[K](0,[k.x,k.y][M](q.slice(1))));break;case "S":t=k.x+(k.x-(k.bx||k.x));k=k.y+(k.y-(k.by||k.y));q=["C",t,k][M](q.slice(1));break;case "T":k.qx=k.x+(k.x-(k.qx||k.x));k.qy=k.y+(k.y-(k.qy||k.y));q=["C"][M](Pa(k.x,k.y,k.qx,k.qy,q[1],q[2]));break;case "Q":k.qx=q[1];k.qy=q[2];q=["C"][M](Pa(k.x,k.y,q[1],
29 | q[2],q[3],q[4]));break;case "L":q=["C"][M](wa(k.x,k.y,q[1],q[2]));break;case "H":q=["C"][M](wa(k.x,k.y,q[1],k.y));break;case "V":q=["C"][M](wa(k.x,k.y,k.x,q[1]));break;case "Z":q=["C"][M](wa(k.x,k.y,k.X,k.Y));break}return q}function e(q,k){if(q[k][o]>7){q[k].shift();for(var t=q[k];t[o];)q.splice(k++,0,["C"][M](t.splice(0,6)));q.splice(k,1);i=Y(c[o],d&&d[o]||0)}}function g(q,k,t,L,B){if(q&&k&&q[B][0]=="M"&&k[B][0]!="M"){k.splice(B,0,["M",L.x,L.y]);t.bx=0;t.by=0;t.x=q[B][1];t.y=q[B][2];i=Y(c[o],d&&
30 | d[o]||0)}}for(var h=0,i=Y(c[o],d&&d[o]||0);h0.5)*2-1;D(f-0.5,2)+D(e-0.5,2)>0.25&&(e=w.sqrt(0.25-D(f-0.5,2))*l+0.5)&&e!=0.5&&(e=e.toFixed(5)-1.0E-5*l)}return s});b=b[H](/\s*\-\s*/);if(d=="linear"){var h=b.shift();h=-A(h);if(isNaN(h))return null;h=[0,0,w.cos(h*w.PI/180),w.sin(h*w.PI/180)];var i=1/(Y(w.abs(h[2]),w.abs(h[3]))||1);h[2]*=i;h[3]*=i;if(h[2]<0){h[0]=-h[2];h[2]=0}if(h[3]<0){h[1]=-h[3];h[3]=0}}b=Ra(b);if(!b)return null;
36 | i=a.getAttribute(aa);(i=i.match(/^url\(#(.*)\)$/))&&c.defs.removeChild(C.getElementById(i[1]));i=v(d+"Gradient");i.id="r"+(m._id++)[N](36);v(i,d=="radial"?{fx:f,fy:e}:{x1:h[0],y1:h[1],x2:h[2],y2:h[3]});c.defs[y](i);c=0;for(h=b[o];cb.height&&(b.height=e.y+e.height-b.y);e.x+e.width-b.x>b.width&&(b.width=e.x+e.width-b.x)}}a&&this.hide();return b};u[p].attr=function(a,b){if(this.removed)return this;if(a==null){a={};for(var c in this.attrs)if(this.attrs[z](c))a[c]=this.attrs[c];this._.rt.deg&&(a.rotation=this.rotate());(this._.sx!=1||this._.sy!=
50 | 1)&&(a.scale=this.scale());a.gradient&&a.fill=="none"&&(a.fill=a.gradient)&&delete a.gradient;return a}if(b==null&&m.is(a,ea)){if(a=="translation")return ya.call(this);if(a=="rotation")return this.rotate();if(a=="scale")return this.scale();if(a==aa&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[a]}if(b==null&&m.is(a,U)){b={};c=0;for(var d=a.length;c1&&(a=1);f.opacity=a}b.fill&&(f.on=true);if(f.on==null||b.fill=="none")f.on=false;if(f.on&&b.fill)if(a=b.fill.match(Na)){f.src=a[1];f.type="tile"}else{f.color=m.getRGB(b.fill).hex;f.src=
64 | s;f.type="solid";if(m.getRGB(b.fill).error&&(g.type in{circle:1,ellipse:1}||(b.fill+s).charAt()!="r")&&ma(g,b.fill)){d.fill="none";d.gradient=b.fill}}e&&c[y](f);f=c.getElementsByTagName("stroke")&&c.getElementsByTagName("stroke")[0];e=false;!f&&(e=f=R("stroke"));if(b.stroke&&b.stroke!="none"||b["stroke-width"]||b["stroke-opacity"]!=null||b["stroke-dasharray"]||b["stroke-miterlimit"]||b["stroke-linejoin"]||b["stroke-linecap"])f.on=true;(b.stroke=="none"||f.on==null||b.stroke==0||b["stroke-width"]==
65 | 0)&&(f.on=false);a=m.getRGB(b.stroke);f.on&&b.stroke&&(f.color=a.hex);a=((+d["stroke-opacity"]+1||2)-1)*((+d.opacity+1||2)-1)*((+a.o+1||2)-1);h=(A(b["stroke-width"])||1)*0.75;a<0&&(a=0);a>1&&(a=1);b["stroke-width"]==null&&(h=d["stroke-width"]);b["stroke-width"]&&(f.weight=h);h&&h<1&&(a*=h)&&(f.weight=1);f.opacity=a;b["stroke-linejoin"]&&(f.joinstyle=b["stroke-linejoin"]||"miter");f.miterlimit=b["stroke-miterlimit"]||8;b["stroke-linecap"]&&(f.endcap=b["stroke-linecap"]=="butt"?"flat":b["stroke-linecap"]==
66 | "square"?"square":"round");if(b["stroke-dasharray"]){a={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};f.dashstyle=a[z](b["stroke-dasharray"])?a[b["stroke-dasharray"]]:s}e&&c[y](f)}if(g.type=="text"){f=g.paper.span.style;d.font&&(f.font=d.font);d["font-family"]&&(f.fontFamily=d["font-family"]);d["font-size"]&&(f.fontSize=d["font-size"]);d["font-weight"]&&(f.fontWeight=d["font-weight"]);
67 | d["font-style"]&&(f.fontStyle=d["font-style"]);g.node.string&&(g.paper.span.innerHTML=(g.node.string+s)[I](/"));g.W=d.w=g.paper.span.offsetWidth;g.H=d.h=g.paper.span.offsetHeight;g.X=d.x;g.Y=d.y+F(g.H/2);switch(d["text-anchor"]){case "start":g.node.style["v-text-align"]="left";g.bbx=F(g.W/2);break;case "end":g.node.style["v-text-align"]="right";g.bbx=-F(g.W/2);break;default:g.node.style["v-text-align"]="center";break}}};ma=function(a,b){a.attrs=a.attrs||
68 | {};var c="linear",d=".5 .5";a.attrs.gradient=b;b=(b+s)[I](Ya,function(i,j,l){c="radial";if(j&&l){j=A(j);l=A(l);D(j-0.5,2)+D(l-0.5,2)>0.25&&(l=w.sqrt(0.25-D(j-0.5,2))*((l>0.5)*2-1)+0.5);d=j+P+l}return s});b=b[H](/\s*\-\s*/);if(c=="linear"){var f=b.shift();f=-A(f);if(isNaN(f))return null}var e=Ra(b);if(!e)return null;a=a.shape||a.node;b=a.getElementsByTagName(aa)[0]||R(aa);!b.parentNode&&a.appendChild(b);if(e[o]){b.on=true;b.method="none";b.color=e[0].color;b.color2=e[e[o]-1].color;a=[];for(var g=0,
69 | h=e[o];g')}}catch(Kb){R=function(a){return C.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}Aa=function(){var a=Sa[K](0,arguments),b=a.container,c=a.height,d=a.width,f=a.x;a=a.y;if(!b)throw new Error("VML container not found.");var e=new G,g=e.canvas=C.createElement("div"),h=g.style;f=f||0;a=a||0;d=d||512;
84 | c=c||342;d==+d&&(d+="px");c==+c&&(c+="px");e.width=1000;e.height=1000;e.coordsize=ja*1000+P+ja*1000;e.coordorigin="0 0";e.span=C.createElement("span");e.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";g[y](e.span);h.cssText=m.format("width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",d,c);if(b==1){C.body[y](g);h.left=f+"px";h.top=a+"px";h.position="absolute"}else b.firstChild?b.insertBefore(g,
85 | b.firstChild):b[y](g);Fa.call(e,e,m.fn);return e};G[p].clear=function(){this.canvas.innerHTML=s;this.span=C.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[y](this.span);this.bottom=this.top=null};G[p].remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=Xa(a);return true}}G[p].safari=/^Apple|^Google/.test(X.navigator.vendor)&&(!(X.navigator.userAgent.indexOf("Version/4.0")+
86 | 1)||X.navigator.platform.slice(0,2)=="iP")?function(){var a=this.rect(-99,-99,this.width+99,this.height+99);X.setTimeout(function(){a.remove()})}:function(){};function Db(){this.returnValue=false}function Eb(){return this.originalEvent.preventDefault()}function Fb(){this.cancelBubble=true}function Gb(){return this.originalEvent.stopPropagation()}var Hb=function(){if(C.addEventListener)return function(a,b,c,d){var f=Ba&&Ca[b]?Ca[b]:b;function e(g){if(Ba&&Ca[z](b))for(var h=0,i=g.targetTouches&&g.targetTouches.length;h<
87 | i;h++)if(g.targetTouches[h].target==a){i=g;g=g.targetTouches[h];g.originalEvent=i;g.preventDefault=Eb;g.stopPropagation=Gb;break}return c.call(d,g)}a.addEventListener(f,e,false);return function(){a.removeEventListener(f,e,false);return true}};else if(C.attachEvent)return function(a,b,c,d){function f(g){g=g||X.event;g.preventDefault=g.preventDefault||Db;g.stopPropagation=g.stopPropagation||Fb;return c.call(d,g)}a.attachEvent("on"+b,f);function e(){a.detachEvent("on"+b,f);return true}return e}}();for(ha=
88 | Ma[o];ha--;)(function(a){m[a]=u[p][a]=function(b){if(m.is(b,"function")){this.events=this.events||[];this.events.push({name:a,f:b,unbind:Hb(this.shape||this.node||C,a,b,this)})}return this};m["un"+a]=u[p]["un"+a]=function(b){for(var c=this.events,d=c[o];d--;)if(c[d].name==a&&c[d].f==b){c[d].unbind();c.splice(d,1);!c.length&&delete this.events;return this}return this}})(Ma[ha]);u[p].hover=function(a,b){return this.mouseover(a).mouseout(b)};u[p].unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};
89 | u[p].drag=function(a,b,c){this._drag={};var d=this.mousedown(function(g){(g.originalEvent?g.originalEvent:g).preventDefault();this._drag.x=g.clientX;this._drag.y=g.clientY;this._drag.id=g.identifier;b&&b.call(this,g.clientX,g.clientY);Raphael.mousemove(f).mouseup(e)});function f(g){var h=g.clientX,i=g.clientY;if(Ba)for(var j=g.touches.length,l;j--;){l=g.touches[j];if(l.identifier==d._drag.id){h=l.clientX;i=l.clientY;(g.originalEvent?g.originalEvent:g).preventDefault();break}}else g.preventDefault();
90 | a&&a.call(d,h-d._drag.x,i-d._drag.y,h,i)}function e(){d._drag={};Raphael.unmousemove(f).unmouseup(e);c&&c.call(d)}return this};G[p].circle=function(a,b,c){return ab(this,a||0,b||0,c||0)};G[p].rect=function(a,b,c,d,f){return bb(this,a||0,b||0,c||0,d||0,f||0)};G[p].ellipse=function(a,b,c,d){return cb(this,a||0,b||0,c||0,d||0)};G[p].path=function(a){a&&!m.is(a,ea)&&!m.is(a[0],U)&&(a+=s);return Za(m.format[K](m,arguments),this)};G[p].image=function(a,b,c,d,f){return db(this,a||"about:blank",b||0,c||0,
91 | d||0,f||0)};G[p].text=function(a,b,c){return eb(this,a||0,b||0,c||s)};G[p].set=function(a){arguments[o]>1&&(a=Array[p].splice.call(arguments,0,arguments[o]));return new Z(a)};G[p].setSize=fb;G[p].top=G[p].bottom=null;G[p].raphael=m;function ib(){return this.x+P+this.y}u[p].resetScale=function(){if(this.removed)return this;this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};u[p].scale=function(a,b,c,d){if(this.removed)return this;if(a==null&&b==null)return{x:this._.sx,y:this._.sy,toString:ib};b=b||a;!+b&&
92 | (b=a);var f,e,g=this.attrs;if(a!=0){var h=this.getBBox(),i=h.x+h.width/2,j=h.y+h.height/2;f=a/this._.sx;e=b/this._.sy;c=+c||c==0?c:i;d=+d||d==0?d:j;h=~~(a/w.abs(a));var l=~~(b/w.abs(b)),n=this.node.style,r=c+(i-c)*f;j=d+(j-d)*e;switch(this.type){case "rect":case "image":var q=g.width*h*f,k=g.height*l*e;this.attr({height:k,r:g.r*$(h*f,l*e),width:q,x:r-q/2,y:j-k/2});break;case "circle":case "ellipse":this.attr({rx:g.rx*h*f,ry:g.ry*l*e,r:g.r*$(h*f,l*e),cx:r,cy:j});break;case "text":this.attr({x:r,y:j});
93 | break;case "path":i=Oa(g.path);for(var t=true,L=0,B=i[o];L=i)return r;l=r}});function Ha(a,b){return function(c,d,f){c=ua(c);
96 | for(var e,g,h,i,j="",l={},n=0,r=0,q=c.length;rd){if(b&&!l.start){e=jb(e,g,h[1],h[2],h[3],h[4],h[5],h[6],d-n);j+=["C",e.start.x,e.start.y,e.m.x,e.m.y,e.x,e.y];if(f)return j;l.start=j;j=["M",e.x,e.y+"C",e.n.x,e.n.y,e.end.x,e.end.y,h[5],h[6]][Q]();n+=i;e=+h[5];g=+h[6];continue}if(!a&&!b){e=jb(e,g,h[1],h[2],h[3],h[4],h[5],h[6],d-n);return{x:e.x,y:e.y,alpha:e.alpha}}}n+=i;e=+h[5];g=+h[6]}j+=h}l.end=j;e=a?n:
97 | b?l:m.findDotsAtSegment(e,g,h[1],h[2],h[3],h[4],h[5],h[6],1);e.alpha&&(e={x:e.x,y:e.y,alpha:e.alpha});return e}}var Ib=T(function(a,b,c,d,f,e,g,h){for(var i={x:0,y:0},j=0,l=0;l<1.01;l+=0.01){var n=la(a,b,c,d,f,e,g,h,l);l&&(j+=D(D(i.x-n.x,2)+D(i.y-n.y,2),0.5));i=n}return j}),kb=Ha(1),za=Ha(),Ia=Ha(0,1);u[p].getTotalLength=function(){if(this.type=="path"){if(this.node.getTotalLength)return this.node.getTotalLength();return kb(this.attrs.path)}};u[p].getPointAtLength=function(a){if(this.type=="path")return za(this.attrs.path,
98 | a)};u[p].getSubpath=function(a,b){if(this.type=="path"){if(w.abs(this.getTotalLength()-b)<1.0E-6)return Ia(this.attrs.path,a).end;b=Ia(this.attrs.path,b,1);return a?Ia(b,a).end:b}};m.easing_formulas={linear:function(a){return a},"<":function(a){return D(a,3)},">":function(a){return D(a-1,3)+1},"<>":function(a){a*=2;if(a<1)return D(a,3)/2;a-=2;return(D(a,3)+2)/2},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==
99 | 0||a==1)return a;var b=0.3,c=b/4;return D(2,-10*a)*w.sin((a-c)*2*w.PI/b)+1},bounce:function(a){var b=7.5625,c=2.75;if(a<1/c)a=b*a*a;else if(a<2/c){a-=1.5/c;a=b*a*a+0.75}else if(a<2.5/c){a-=2.25/c;a=b*a*a+0.9375}else{a-=2.625/c;a=b*a*a+0.984375}return a}};var S={length:0};function lb(){var a=+new Date;for(var b in S)if(b!="length"&&S[z](b)){var c=S[b];if(c.stop||c.el.removed){delete S[b];S[o]--}else{var d=a-c.start,f=c.ms,e=c.easing,g=c.from,h=c.diff,i=c.to,j=c.t,l=c.prev||0,n=c.el,r=c.callback,q=
100 | {},k;if(d
17 | jQuery
18 | %span<> .graphie
19 | %h2 a cute little graphing plugin
20 | %p
21 | by
22 | %a(href="http://camerondaigle.com") Cameron Daigle
23 | :markdown
24 | To use, include [the plugin](https://github.com/camerond/jquery-graphie/blob/master/public/javascript/jquery.graphie.js) and call `$.graphie()` on a ``, `` or `` of numeric values. (Also requires [Raphael](http://raphaeljs.com/))
25 |
26 | For available options, check out the
27 | [source](https://github.com/camerond/jquery-graphie/blob/master/public/javascript/jquery.graphie.js) or the [readme](https://github.com/camerond/jquery-graphie).
28 |
29 | %h3 it has nice-looking defaults:
30 | %dl#normal
31 | - 10.times do
32 | %dt Label
33 | %dd=rand(300)
34 | %h3 it has some options:
35 | %dl#options
36 | - 10.times do
37 | %dt Label
38 | %dd=rand(30)
39 | %h3 it looks good teeny:
40 | %ul#teeny
41 | - 20.times do
42 | %li=rand(30)
43 | %ul#columns
44 | - 98.times do
45 | %li=rand(30)
46 | %ul#line
47 | - 150.times do
48 | %li=rand(30)
49 |
50 |
51 | - if production?
52 | :javascript
53 | var _gaq = _gaq || [];
54 | _gaq.push(['_setAccount', 'UA-308731-14']);
55 | _gaq.push(['_trackPageview']);
56 |
57 | (function() {
58 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
59 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
60 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
61 | })();
--------------------------------------------------------------------------------
/views/stylesheets/application.sass:
--------------------------------------------------------------------------------
1 | @import 'reset.scss'
2 |
3 | body
4 | font-family: 'Helvetica Neue', helvetica, sans-serif
5 | background: #1d1f21 url("/images/jq_bg.png")
6 | color: #d2d8e3
7 | text-shadow: 0 2px 1px #000
8 |
9 | #wrapper
10 | padding: 100px
11 |
12 | p
13 | font-weight: bold
14 | margin: 0 0 40px 0
15 | code
16 | font-weight: bold
17 | font-size: 1.1em
18 | background: #31363b
19 | padding: 2px 4px
20 | margin: 0 4px
21 | text-shadow: 0 1px 1px #000
22 | a
23 | text-decoration: none
24 | color: #d367b6
25 | &:hover
26 | text-decoration: underline
27 |
28 | hgroup
29 | margin: 0 0 40px 0
30 | font-family: "chunk-1","chunk-2", 'Helvetica Neue', helvetica, sans-serif
31 | h1
32 | font-size: 80px
33 | span
34 | color: #d367b6
35 | h2
36 | font-size: 40px
37 | form
38 | label
39 | font-size: 14px
40 | + form
41 |
42 | h3
43 | font-weight: bold
44 | margin: 0 0 20px 0
45 | .graphie
46 | width: 400px
47 | height: 140px
48 | background: #fff
49 | overflow: hidden
50 | margin: 0 0 40px 0
51 | text-shadow: none
52 | #options.graphie
53 | height: 100px
54 | width: 600px
55 | background: none
56 | #teeny.graphie
57 | height: 20px
58 | width: 400px
59 | margin: 0 0 20px 0
60 | #columns.graphie
61 | height: 10px
62 | width: 400px
63 | background: none
64 | margin: 0 0 20px 0
65 | #line.graphie
66 | height: 20px
67 | width: 400px
--------------------------------------------------------------------------------
/views/stylesheets/reset.scss:
--------------------------------------------------------------------------------
1 | /*
2 | ----------------------------------------
3 | Tantek Celik's Whitepsace Reset
4 | Author: Tantek Celik, Shane Riley, and Cameron Daigle (font weight! COME ON)
5 | Version: (CC) 2010 Some Rights Reserved - http://creativecommons.org/licenses/by/2.0
6 | Description: Resets default styling of common browsers to a common base
7 | ----------------------------------------
8 | */
9 |
10 | ul,ol { list-style: none; }
11 | h1,h2,h3,h4,h5,h6,pre,code { font-size: 1em; font-weight: normal; }
12 | ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input,dl,dt,dd {
13 | margin: 0;
14 | padding: 0; }
15 | a img,:link img,:visited img, fieldset { border: none; }
16 | address { font-style: normal; }
17 | header, section, article, nav, footer, hgroup { display: block; }
18 | a { text-decoration: none }
--------------------------------------------------------------------------------