├── .gitignore ├── run_jekyll.sh ├── _includes ├── reference │ ├── pen.html │ ├── paper.html │ ├── container.html │ ├── editing.html │ ├── change.html │ ├── strokes.html │ ├── raphael-sketchpad.html │ ├── json.html │ └── animate.html ├── reference.html ├── analytics.html ├── header.html ├── how-it-works.html ├── how-to-use-it.html └── editing.html ├── stylesheets ├── cw15gw20cc24 │ ├── print.css │ ├── ie.css │ └── screen.css └── main.css ├── README.md ├── index.html ├── javascripts ├── json2.min.js ├── json2.js └── raphael-2.0.1.min.js └── src └── raphael.sketchpad.js /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | -------------------------------------------------------------------------------- /run_jekyll.sh: -------------------------------------------------------------------------------- 1 | jekyll serve -P 5020 2 | -------------------------------------------------------------------------------- /_includes/reference/pen.html: -------------------------------------------------------------------------------- 1 |
2 |

pen

3 |

4 | Returns the pen associated with the widget. 5 |

6 |
7 |
8 | {% capture js %} 9 | // The pen has various properties that you can set. 10 | var pen = editor.pen(); 11 | {% endcapture %} 12 | 13 |
{{ js | strip | escape }}
14 |
15 | -------------------------------------------------------------------------------- /_includes/reference/paper.html: -------------------------------------------------------------------------------- 1 |
2 |

paper

3 |

4 | Returns the Raphael paper object. 5 |

6 |
7 |
8 | {% capture js %} 9 | // http://raphaeljs.com describes properties of the Raphael paper object. 10 | var paper = editor.paper(); 11 | {% endcapture %} 12 | 13 |
{{ js | strip | escape }}
14 |
15 | -------------------------------------------------------------------------------- /_includes/reference/container.html: -------------------------------------------------------------------------------- 1 |
2 |

container

3 |

4 | Returns the HTML element containing the Raphael paper object. 5 |

6 |
7 |
8 | {% capture js %} 9 | // The container is a regular HTML element. 10 | var container = editor.container(); 11 | {% endcapture %} 12 | 13 |
{{ js | strip | escape }}
14 |
15 | -------------------------------------------------------------------------------- /_includes/reference.html: -------------------------------------------------------------------------------- 1 |
2 |

Reference

3 | 4 | {% include reference/raphael-sketchpad.html %} 5 | {% include reference/paper.html %} 6 | {% include reference/container.html %} 7 | {% include reference/pen.html %} 8 | {% include reference/strokes.html %} 9 | {% include reference/json.html %} 10 | {% include reference/editing.html %} 11 | {% include reference/change.html %} 12 | {% include reference/animate.html %} 13 |
14 | -------------------------------------------------------------------------------- /_includes/analytics.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /_includes/reference/editing.html: -------------------------------------------------------------------------------- 1 |
2 |

editing

3 |

4 | Sets the editing mode of the sketchpad. 5 | The sketchpad has to be initialized as an editor. 6 | There are three modes: 7 |

8 | 13 | 14 |

Parameters

15 |
    16 |
  1. mode string or boolean
  2. 17 |
18 |
19 |
20 | {% capture js %} 21 | // When the sketchpad is in drawing mode. 22 | editor.editing(true); 23 | 24 | // When the sketchpad is in viewer mode. 25 | editor.editing(false); 26 | 27 | // When the sketchpad is in erase mode. 28 | editor.editing("erase"); 29 | {% endcapture %} 30 | 31 |
{{ js | strip | escape }}
32 |
-------------------------------------------------------------------------------- /_includes/reference/change.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

5 | Draw something here. 6 |

7 |
8 |

change

9 |

10 | Sets the function that handles the change event. 11 | onchange events happen when 12 |

13 | 14 |

Parameters

15 |
    16 |
  1. fn function
  2. 17 |
18 |
19 |
20 | {% capture js %} 21 | // When the sketch changes, an alert shows up. 22 | editor.change(function() { 23 | alert("Yay!"); 24 | }); 25 | {% endcapture %} 26 |
{{ js | strip | escape }}
27 | 28 | 40 |
41 | -------------------------------------------------------------------------------- /_includes/header.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | by Ian Li 5 |
6 |

Raphael SketchPad

7 |
8 | 9 |
10 |

11 | Raphael Sketchpad is a simple drawing editor that you can easily include with your forms.
12 | It is similar to Mai'Nada.net's InputDraw, 13 | but does not require Flash.
14 | It is built on top of the Raphael 15 | Javascript vector graphics library. 16 |

17 |

18 | Raphael Sketchpad requires these Javascript libraries: 19 | Raphael 2.0.1, 20 | jQuery, and 21 | JSON.stringify. 22 |

23 |
24 |
25 |
26 | Download 0.5.1 27 |
28 | or visit the 29 | GitHub project page. 30 |
31 |
32 | -------------------------------------------------------------------------------- /stylesheets/cw15gw20cc24/print.css: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- 2 | 3 | 4 | Blueprint CSS Framework 0.8 5 | http://blueprintcss.org 6 | 7 | * Copyright (c) 2007-Present. See LICENSE for more info. 8 | * See README for instructions on how to use Blueprint. 9 | * For credits and origins, see AUTHORS. 10 | * This is a compressed file. See the sources in the 'src' directory. 11 | 12 | ----------------------------------------------------------------------- */ 13 | 14 | /* print.css */ 15 | body {line-height:1.5;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;color:#000;background:none;font-size:10pt;} 16 | .container {background:none;} 17 | hr {background:#ccc;color:#ccc;width:100%;height:2px;margin:2em 0;padding:0;border:none;} 18 | hr.space {background:#fff;color:#fff;} 19 | h1, h2, h3, h4, h5, h6 {font-family:"Helvetica Neue", Arial, "Lucida Grande", sans-serif;} 20 | code {font:.9em "Courier New", Monaco, Courier, monospace;} 21 | img {float:left;margin:1.5em 1.5em 1.5em 0;} 22 | a img {border:none;} 23 | p img.top {margin-top:0;} 24 | blockquote {margin:1.5em;padding:1em;font-style:italic;font-size:.9em;} 25 | .small {font-size:.9em;} 26 | .large {font-size:1.1em;} 27 | .quiet {color:#999;} 28 | .hide {display:none;} 29 | a:link, a:visited {background:transparent;font-weight:700;text-decoration:underline;} 30 | a:link:after, a:visited:after {content:" (" attr(href) ") ";font-size:90%;} -------------------------------------------------------------------------------- /stylesheets/cw15gw20cc24/ie.css: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- 2 | 3 | 4 | Blueprint CSS Framework 0.8 5 | http://blueprintcss.org 6 | 7 | * Copyright (c) 2007-Present. See LICENSE for more info. 8 | * See README for instructions on how to use Blueprint. 9 | * For credits and origins, see AUTHORS. 10 | * This is a compressed file. See the sources in the 'src' directory. 11 | 12 | ----------------------------------------------------------------------- */ 13 | 14 | /* ie.css */ 15 | body {text-align:center;} 16 | .container {text-align:left;} 17 | * html .column, * html div.span-1, * html div.span-2, * html div.span-3, * html div.span-4, * html div.span-5, * html div.span-6, * html div.span-7, * html div.span-8, * html div.span-9, * html div.span-10, * html div.span-11, * html div.span-12, * html div.span-13, * html div.span-14, * html div.span-15, * html div.span-16, * html div.span-17, * html div.span-18, * html div.span-19, * html div.span-20, * html div.span-21, * html div.span-22, * html div.span-23, * html div.span-24 {overflow-x:hidden;} 18 | * html legend {margin:-18px -8px 16px 0;padding:0;} 19 | ol {margin-left:2em;} 20 | sup {vertical-align:text-top;} 21 | sub {vertical-align:text-bottom;} 22 | html>body p code {*white-space:normal;} 23 | hr {margin:-8px auto 11px;} 24 | .clearfix, .container {display:inline-block;} 25 | * html .clearfix, * html .container {height:1%;} 26 | fieldset {padding-top:0;} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Raphael SketchPad Version 0.5.1 2 | 3 | Raphael Sketchpad is a simple drawing editor that you can easily include with your forms. 4 | It is similar to Mai'Nada.net's InputDraw, but does not require Flash. 5 | It is built on top of the Raphael Javascript vector graphics library. 6 | 7 | Raphael Sketchpad requires these Javascript libraries: Raphael, jQuery, and JSON.stringify. 8 | 9 | http://ianli.github.io/raphael-sketchpad/ 10 | 11 | Copyright (c) 2011 Ian Li (http://ianli.com) 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /_includes/reference/strokes.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

strokes

6 |

7 | Sets the strokes in the widget. 8 | If the json parameter is not provided, 9 | returns an array of strokes. 10 |

11 | 12 |

Parameters

13 |
    14 |
  1. strokes array
  2. 15 |
16 |
17 |
18 | {% capture js %} 19 | // The viewer shows a black diagonal path. 20 | // path parameter can be array or SVG path format, e.g., "M10,10L90,90". 21 | viewer.strokes([{ 22 | "type":"path", 23 | "path":[["M",10,10],["L",90,90]], 24 | "fill":"none", 25 | "stroke":"#000000", 26 | "stroke-opacity":1, 27 | "stroke-width":5, 28 | "stroke-linecap":"round", 29 | "stroke-linejoin":"round" 30 | }]); 31 | 32 | // Returns an array of strokes. 33 | var strokes = viewer.strokes(); 34 | {% endcapture %} 35 |
{{ js | strip | escape }}
36 | 37 | 56 |
57 | -------------------------------------------------------------------------------- /_includes/reference/raphael-sketchpad.html: -------------------------------------------------------------------------------- 1 |
2 |

Raphael.sketchpad

3 |

4 | Creates a Raphael SketchPad widget. 5 |

6 | 7 |

Parameters

8 |
    9 |
  1. container Raphael or string
  2. 10 |
  3. options object
  4. 11 |
12 | 13 |

Possible options attributes

14 | 21 |
22 |
23 | {% capture js %} 24 | // Each of the examples creates a widget that is 100px wide and 100px high. 25 | 26 | // Creates an editor at the top left corner of the #editor element. 27 | // The editor is initialized with strokes from the #data form field. 28 | // Sketches are stored in the #data form field. 29 | var editor = Raphael.sketchpad("editor", { 30 | width: 100, 31 | height: 100, 32 | input: "#data" 33 | }); 34 | 35 | // Creates a viewer at the top left corner of the #viewer element 36 | // initialized with the stroke data. 37 | var viewer = Raphael.sketchpad("viewer", { 38 | width: 100, 39 | height: 100, 40 | strokes: [{ 41 | type:"path", 42 | path:[["M",10,10],["L",90,90]], 43 | fill:"none", "stroke":"#000000", 44 | stroke-opacity:1, 45 | stroke-width:5, 46 | stroke-linecap:"round", 47 | stroke-linejoin:"round" 48 | }] 49 | }); 50 | {% endcapture %} 51 | 52 |
{{ js | strip | escape }}
53 |
54 | -------------------------------------------------------------------------------- /stylesheets/main.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | background:#fff; 3 | } 4 | a, 5 | a:hover, 6 | a:visited { 7 | color:#1D72C2; 8 | } 9 | #hd { 10 | margin-top:40px; 11 | } 12 | #hd h1 { 13 | font-weight:bold; 14 | letter-spacing:-0.05em; 15 | } 16 | #hd a#download { 17 | display:block; 18 | padding:5px; 19 | font-size:24px; 20 | font-weight:bold; 21 | text-align:center; 22 | text-decoration:none; 23 | background-color:#D4ECFF; 24 | border:1px solid #57B6FF; 25 | } 26 | #bd { 27 | margin-bottom:40px; 28 | } 29 | #bd h2, 30 | #bd h3 { 31 | font-weight:bold; 32 | letter-spacing:-0.05em; 33 | } 34 | 35 | #bd pre.code { 36 | margin-top:0; 37 | padding:5px; 38 | background-color:#eee; 39 | } 40 | #bd .sample { 41 | float:right; 42 | margin-left:10px; 43 | } 44 | #bd div.widget { 45 | background-color:#ffc; 46 | border:1px solid #ccc; 47 | } 48 | /* Reference section */ 49 | #bd .reference code { 50 | margin:0 10px; 51 | } 52 | 53 | .widget_actions div { 54 | cursor:pointer; 55 | margin:4px 0 0; 56 | color:#1D72C2; 57 | background-color:#D4ECFF; 58 | border:1px solid #57B6FF; 59 | text-align:center; 60 | text-decoration:none; 61 | } 62 | .widget_actions div.disabled { 63 | text-decoration:none; 64 | color:#666; 65 | background-color:#eee; 66 | border:1px solid #ccc; 67 | } 68 | .widget_actions div.selected { 69 | font-weight:bold; 70 | } 71 | .widget_actions div._title { 72 | cursor:default; 73 | color:#666; 74 | background-color:transparent; 75 | border-color:transparent; 76 | } 77 | -------------------------------------------------------------------------------- /_includes/how-it-works.html: -------------------------------------------------------------------------------- 1 |

How It Works

2 | 3 |
4 |

Editor

5 |

6 | Draw a sketch below. 7 |

8 |
9 |
10 |
11 |
12 | 13 |
14 |

Result

15 |

16 | The sketch is stored as JSON in an input field. 17 |

18 |
19 | 20 |
21 |
22 | 23 |
24 |

Viewer

25 |

26 | Click 27 | to display the JSON data in the viewer. 28 |

29 |
30 |
31 |
32 |
33 | 34 | 59 | 60 |
61 | -------------------------------------------------------------------------------- /_includes/reference/json.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

json

6 |

7 | Sets the strokes in the widget. 8 | If the json parameter is not provided, 9 | returns a JSON representation of the strokes. 10 |

11 | 12 |

Parameters

13 |
    14 |
  1. json string
  2. 15 |
16 |
17 |
18 | {% capture js %} 19 | // The viewer shows a black diagonal path. 20 | // path parameter can be array or SVG path format, e.g., "M10,10L90,90". 21 | viewer.json('[{' + 22 | '"type":"path",' + 23 | '"path":[["M",10,10],["L",90,90]],' + 24 | '"fill":"none", "stroke":"#000000",' + 25 | '"stroke-opacity":1,' + 26 | '"stroke-width":5,' + 27 | '"stroke-linecap":"round",' + 28 | '"stroke-linejoin":"round"' + 29 | '}]' 30 | ); 31 | 32 | // Returns the JSON representation of the strokes. 33 | var json = viewer.json(); 34 | {% endcapture %} 35 |
{{ js | strip | escape }}
36 | 37 | 56 |
57 | -------------------------------------------------------------------------------- /_includes/reference/animate.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
Animate!
6 |
7 |
8 |

animate

9 |

10 | Animates the strokes in the widget. 11 | 12 |

13 | 14 |

Parameters

15 |
    16 |
  1. ms number
  2. 17 |
18 |
19 |
20 | {% capture js %} 21 | // Animates with 1 second (1000 ms) delay between frames. 22 | viewer.animate(1000); 23 | 24 | // If no parameter is provided, delay is 500 ms (default). 25 | viewer.animate(); 26 | {% endcapture %} 27 |
{{ js | strip | escape }}
28 | 29 | 62 |
63 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | --- 2 | # Front matter so that Jekyll processes the file 3 | --- 4 | 5 | 6 | 7 | Raphael SketchPad 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | {% include header.html %} 30 | 31 | 32 |
33 | 34 | {% include how-it-works.html %} 35 | 36 | {% include how-to-use-it.html %} 37 | 38 | {% include reference.html %} 39 | 40 | {% include editing.html %} 41 | 42 |
43 | 44 | 45 |
46 | © 2011 Raphael SketchPad by 47 | Ian Li. 48 | Licensed under the MIT license. 49 |
50 | 51 |
52 | 53 | {% include analytics.html %} 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /_includes/how-to-use-it.html: -------------------------------------------------------------------------------- 1 |

How to Use It

2 | 3 |
4 |
    5 |
  1. Include necessary javascript library files.
  2. 6 |
7 |
8 | 9 |
10 | {% capture html %} 11 | 12 | 13 | 14 | 15 | {% endcapture %} 16 | 17 |
{{ html | strip | escape }}
18 |
19 | 20 |
21 |
    22 |
  1. 23 | To create an editor, 24 | put a div with an id where you want the editor. 25 | Add a form with a hidden input field with a different id. 26 | Set the editing option to true (This is the default setting). 27 |
  2. 28 |
29 |
30 | 31 |
32 | {% capture html %} 33 |
34 | 35 |
36 | 37 | 38 |
39 | 40 | 52 | {% endcapture %} 53 | 54 |
{{ html | strip | escape }}
55 |
56 | 57 |
58 |
    59 |
  1. 60 | To create a viewer, 61 | put a div with an id where you want the viewer. 62 | Set strokes with an array of strokes. 63 | Set the editing option to false. 64 |
  2. 65 |
66 |
67 | 68 |
69 | {% capture html %} 70 |
71 | 72 | 89 | {% endcapture %} 90 | 91 |
{{ html | strip | escape }}
92 |
93 | 94 |
95 | -------------------------------------------------------------------------------- /javascripts/json2.min.js: -------------------------------------------------------------------------------- 1 | if(!this.JSON){this.JSON={};} 2 | (function(){function f(n){return n<10?'0'+n:n;} 3 | if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+ 4 | f(this.getUTCMonth()+1)+'-'+ 5 | f(this.getUTCDate())+'T'+ 6 | f(this.getUTCHours())+':'+ 7 | f(this.getUTCMinutes())+':'+ 8 | f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};} 9 | var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';} 10 | function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);} 11 | if(typeof rep==='function'){value=rep.call(holder,key,value);} 12 | switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';} 13 | gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i 2 |

Editing Actions and Pen Properties

3 | 4 |
5 | {% capture editor_js %} 6 |
7 | 8 | 9 |
10 |
Color
11 |
Black
12 |
Red
13 |
14 |
15 |
Width
16 |
Thin
17 |
Thick
18 |
19 |
20 |
Opacity
21 |
Solid
22 |
Fuzzy
23 |
24 |
25 |
Undo
26 |
Redo
27 |
Clear
28 |
29 |
30 |
31 |
Draw
32 |
33 |
34 |
Animate!
35 |
36 | 37 | 130 | {% endcapture %} 131 | 132 | {{ editor_js }} 133 |
134 | 135 |
136 |

Editing Actions

137 | 138 |

139 | The editor supports various editing actions. 140 |

141 | 142 |
143 |

clear

144 |
145 |
146 | {% capture js %} 147 | // Clear the editor. 148 | editor.clear(); 149 | {% endcapture %} 150 | 151 |
{{ js | strip | escape }}
152 |
153 | 154 |
155 |

undo

156 |
157 |
158 | {% capture js %} 159 | // Undo the last stroke. 160 | editor.undo(); 161 | {% endcapture %} 162 | 163 |
{{ js | strip | escape }}
164 |
165 | 166 |
167 |

undoable

168 |
169 |
170 | {% capture js %} 171 | // True if can undo. 172 | editor.undoable(); 173 | {% endcapture %} 174 | 175 |
{{ js | strip | escape }}
176 |
177 | 178 |
179 |

redo

180 |
181 |
182 | {% capture js %} 183 | // Redo the undone stroke. 184 | editor.redo(); 185 | {% endcapture %} 186 | 187 |
{{ js | strip | escape }}
188 |
189 | 190 |
191 |

redoable

192 |
193 |
194 | {% capture js %} 195 | // True if can redo. 196 | editor.redoable(); 197 | {% endcapture %} 198 | 199 |
{{ js | strip | escape }}
200 |
201 |
202 | 203 |
204 |

Pen Properties

205 | 206 |

207 | The pen has various properties that you can set. 208 |

209 | 210 |
211 |

color

212 |
213 |
214 | {% capture js %} 215 | // #ff0000 or #f00 216 | pen.color("#ff0000"); 217 | {% endcapture %} 218 | 219 |
{{ js | strip | escape }}
220 |
221 | 222 |
223 |

width

224 |
225 |
226 | {% capture js %} 227 | // min = 1, max = 1000 228 | pen.width(10); 229 | {% endcapture %} 230 | 231 |
{{ js | strip | escape }}
232 |
233 | 234 |
235 |

opacity

236 |
237 |
238 | {% capture js %} 239 | // min = 0, max = 1.0 240 | pen.opacity(10); 241 | {% endcapture %} 242 | 243 |
{{ js | strip | escape }}
244 |
245 |
246 | 247 |
248 | Show source 249 | 251 |
252 | 253 |
254 | 255 | -------------------------------------------------------------------------------- /stylesheets/cw15gw20cc24/screen.css: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- 2 | 3 | 4 | Blueprint CSS Framework 0.8 5 | http://blueprintcss.org 6 | 7 | * Copyright (c) 2007-Present. See LICENSE for more info. 8 | * See README for instructions on how to use Blueprint. 9 | * For credits and origins, see AUTHORS. 10 | * This is a compressed file. See the sources in the 'src' directory. 11 | 12 | ----------------------------------------------------------------------- */ 13 | 14 | /* reset.css */ 15 | html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;} 16 | body {line-height:1.5;} 17 | table {border-collapse:separate;border-spacing:0;} 18 | caption, th, td {text-align:left;font-weight:normal;} 19 | table, td, th {vertical-align:middle;} 20 | blockquote:before, blockquote:after, q:before, q:after {content:"";} 21 | blockquote, q {quotes:"" "";} 22 | a img {border:none;} 23 | 24 | /* typography.css */ 25 | body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;} 26 | h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;} 27 | h1 {font-size:3em;line-height:1;margin-bottom:0.5em;} 28 | h2 {font-size:2em;margin-bottom:0.75em;} 29 | h3 {font-size:1.5em;line-height:1;margin-bottom:1em;} 30 | h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;} 31 | h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;} 32 | h6 {font-size:1em;font-weight:bold;} 33 | h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;} 34 | p {margin:0 0 1.5em;} 35 | p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;} 36 | p img.right {float:right;margin:1.5em 0 1.5em 1.5em;} 37 | a:focus, a:hover {color:#000;} 38 | a {color:#009;text-decoration:underline;} 39 | blockquote {margin:1.5em;color:#666;font-style:italic;} 40 | strong {font-weight:bold;} 41 | em, dfn {font-style:italic;} 42 | dfn {font-weight:bold;} 43 | sup, sub {line-height:0;} 44 | abbr, acronym {border-bottom:1px dotted #666;} 45 | address {margin:0 0 1.5em;font-style:italic;} 46 | del {color:#666;} 47 | pre {margin:1.5em 0;white-space:pre;} 48 | pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;} 49 | li ul, li ol {margin:0 1.5em;} 50 | ul, ol {margin:0 1.5em 1.5em 1.5em;} 51 | ul {list-style-type:disc;} 52 | ol {list-style-type:decimal;} 53 | dl {margin:0 0 1.5em 0;} 54 | dl dt {font-weight:bold;} 55 | dd {margin-left:1.5em;} 56 | table {margin-bottom:1.4em;width:100%;} 57 | th {font-weight:bold;} 58 | thead th {background:#c3d9ff;} 59 | th, td, caption {padding:4px 10px 4px 5px;} 60 | tr.even td {background:#e5ecf9;} 61 | tfoot {font-style:italic;} 62 | caption {background:#eee;} 63 | .small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;} 64 | .large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;} 65 | .hide {display:none;} 66 | .quiet {color:#666;} 67 | .loud {color:#000;} 68 | .highlight {background:#ff0;} 69 | .added {background:#060;color:#fff;} 70 | .removed {background:#900;color:#fff;} 71 | .first {margin-left:0;padding-left:0;} 72 | .last {margin-right:0;padding-right:0;} 73 | .top {margin-top:0;padding-top:0;} 74 | .bottom {margin-bottom:0;padding-bottom:0;} 75 | 76 | /* grid.css */ 77 | .container {width:820px;margin:0 auto;} 78 | .showgrid {background:url(src/grid.png);} 79 | .column, div.span-1, div.span-2, div.span-3, div.span-4, div.span-5, div.span-6, div.span-7, div.span-8, div.span-9, div.span-10, div.span-11, div.span-12, div.span-13, div.span-14, div.span-15, div.span-16, div.span-17, div.span-18, div.span-19, div.span-20, div.span-21, div.span-22, div.span-23, div.span-24 {float:left;margin-right:20px;} 80 | .last, div.last {margin-right:0;} 81 | .span-1 {width:15px;} 82 | .span-2 {width:50px;} 83 | .span-3 {width:85px;} 84 | .span-4 {width:120px;} 85 | .span-5 {width:155px;} 86 | .span-6 {width:190px;} 87 | .span-7 {width:225px;} 88 | .span-8 {width:260px;} 89 | .span-9 {width:295px;} 90 | .span-10 {width:330px;} 91 | .span-11 {width:365px;} 92 | .span-12 {width:400px;} 93 | .span-13 {width:435px;} 94 | .span-14 {width:470px;} 95 | .span-15 {width:505px;} 96 | .span-16 {width:540px;} 97 | .span-17 {width:575px;} 98 | .span-18 {width:610px;} 99 | .span-19 {width:645px;} 100 | .span-20 {width:680px;} 101 | .span-21 {width:715px;} 102 | .span-22 {width:750px;} 103 | .span-23 {width:785px;} 104 | .span-24, div.span-24 {width:820px;margin:0;} 105 | input.span-1, textarea.span-1, select.span-1 {width:15px!important;} 106 | input.span-2, textarea.span-2, select.span-2 {width:20px!important;} 107 | input.span-3, textarea.span-3, select.span-3 {width:55px!important;} 108 | input.span-4, textarea.span-4, select.span-4 {width:90px!important;} 109 | input.span-5, textarea.span-5, select.span-5 {width:125px!important;} 110 | input.span-6, textarea.span-6, select.span-6 {width:160px!important;} 111 | input.span-7, textarea.span-7, select.span-7 {width:195px!important;} 112 | input.span-8, textarea.span-8, select.span-8 {width:230px!important;} 113 | input.span-9, textarea.span-9, select.span-9 {width:265px!important;} 114 | input.span-10, textarea.span-10, select.span-10 {width:300px!important;} 115 | input.span-11, textarea.span-11, select.span-11 {width:335px!important;} 116 | input.span-12, textarea.span-12, select.span-12 {width:370px!important;} 117 | input.span-13, textarea.span-13, select.span-13 {width:405px!important;} 118 | input.span-14, textarea.span-14, select.span-14 {width:440px!important;} 119 | input.span-15, textarea.span-15, select.span-15 {width:475px!important;} 120 | input.span-16, textarea.span-16, select.span-16 {width:510px!important;} 121 | input.span-17, textarea.span-17, select.span-17 {width:545px!important;} 122 | input.span-18, textarea.span-18, select.span-18 {width:580px!important;} 123 | input.span-19, textarea.span-19, select.span-19 {width:615px!important;} 124 | input.span-20, textarea.span-20, select.span-20 {width:650px!important;} 125 | input.span-21, textarea.span-21, select.span-21 {width:685px!important;} 126 | input.span-22, textarea.span-22, select.span-22 {width:720px!important;} 127 | input.span-23, textarea.span-23, select.span-23 {width:755px!important;} 128 | input.span-24, textarea.span-24, select.span-24 {width:810px!important;} 129 | .append-1 {padding-right:35px;} 130 | .append-2 {padding-right:70px;} 131 | .append-3 {padding-right:105px;} 132 | .append-4 {padding-right:140px;} 133 | .append-5 {padding-right:175px;} 134 | .append-6 {padding-right:210px;} 135 | .append-7 {padding-right:245px;} 136 | .append-8 {padding-right:280px;} 137 | .append-9 {padding-right:315px;} 138 | .append-10 {padding-right:350px;} 139 | .append-11 {padding-right:385px;} 140 | .append-12 {padding-right:420px;} 141 | .append-13 {padding-right:455px;} 142 | .append-14 {padding-right:490px;} 143 | .append-15 {padding-right:525px;} 144 | .append-16 {padding-right:560px;} 145 | .append-17 {padding-right:595px;} 146 | .append-18 {padding-right:630px;} 147 | .append-19 {padding-right:665px;} 148 | .append-20 {padding-right:700px;} 149 | .append-21 {padding-right:735px;} 150 | .append-22 {padding-right:770px;} 151 | .append-23 {padding-right:805px;} 152 | .prepend-1 {padding-left:35px;} 153 | .prepend-2 {padding-left:70px;} 154 | .prepend-3 {padding-left:105px;} 155 | .prepend-4 {padding-left:140px;} 156 | .prepend-5 {padding-left:175px;} 157 | .prepend-6 {padding-left:210px;} 158 | .prepend-7 {padding-left:245px;} 159 | .prepend-8 {padding-left:280px;} 160 | .prepend-9 {padding-left:315px;} 161 | .prepend-10 {padding-left:350px;} 162 | .prepend-11 {padding-left:385px;} 163 | .prepend-12 {padding-left:420px;} 164 | .prepend-13 {padding-left:455px;} 165 | .prepend-14 {padding-left:490px;} 166 | .prepend-15 {padding-left:525px;} 167 | .prepend-16 {padding-left:560px;} 168 | .prepend-17 {padding-left:595px;} 169 | .prepend-18 {padding-left:630px;} 170 | .prepend-19 {padding-left:665px;} 171 | .prepend-20 {padding-left:700px;} 172 | .prepend-21 {padding-left:735px;} 173 | .prepend-22 {padding-left:770px;} 174 | .prepend-23 {padding-left:805px;} 175 | div.border {padding-right:9px;margin-right:10px;border-right:1px solid #eee;} 176 | div.colborder {padding-right:4px;margin-right:5px;border-right:1px solid #eee;} 177 | .pull-1 {margin-left:-35px;} 178 | .pull-2 {margin-left:-70px;} 179 | .pull-3 {margin-left:-105px;} 180 | .pull-4 {margin-left:-140px;} 181 | .pull-5 {margin-left:-175px;} 182 | .pull-6 {margin-left:-210px;} 183 | .pull-7 {margin-left:-245px;} 184 | .pull-8 {margin-left:-280px;} 185 | .pull-9 {margin-left:-315px;} 186 | .pull-10 {margin-left:-350px;} 187 | .pull-11 {margin-left:-385px;} 188 | .pull-12 {margin-left:-420px;} 189 | .pull-13 {margin-left:-455px;} 190 | .pull-14 {margin-left:-490px;} 191 | .pull-15 {margin-left:-525px;} 192 | .pull-16 {margin-left:-560px;} 193 | .pull-17 {margin-left:-595px;} 194 | .pull-18 {margin-left:-630px;} 195 | .pull-19 {margin-left:-665px;} 196 | .pull-20 {margin-left:-700px;} 197 | .pull-21 {margin-left:-735px;} 198 | .pull-22 {margin-left:-770px;} 199 | .pull-23 {margin-left:-805px;} 200 | .pull-24 {margin-left:-840px;} 201 | .pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 {float:left;position:relative;} 202 | .push-1 {margin:0 -35px 1.5em 35px;} 203 | .push-2 {margin:0 -70px 1.5em 70px;} 204 | .push-3 {margin:0 -105px 1.5em 105px;} 205 | .push-4 {margin:0 -140px 1.5em 140px;} 206 | .push-5 {margin:0 -175px 1.5em 175px;} 207 | .push-6 {margin:0 -210px 1.5em 210px;} 208 | .push-7 {margin:0 -245px 1.5em 245px;} 209 | .push-8 {margin:0 -280px 1.5em 280px;} 210 | .push-9 {margin:0 -315px 1.5em 315px;} 211 | .push-10 {margin:0 -350px 1.5em 350px;} 212 | .push-11 {margin:0 -385px 1.5em 385px;} 213 | .push-12 {margin:0 -420px 1.5em 420px;} 214 | .push-13 {margin:0 -455px 1.5em 455px;} 215 | .push-14 {margin:0 -490px 1.5em 490px;} 216 | .push-15 {margin:0 -525px 1.5em 525px;} 217 | .push-16 {margin:0 -560px 1.5em 560px;} 218 | .push-17 {margin:0 -595px 1.5em 595px;} 219 | .push-18 {margin:0 -630px 1.5em 630px;} 220 | .push-19 {margin:0 -665px 1.5em 665px;} 221 | .push-20 {margin:0 -700px 1.5em 700px;} 222 | .push-21 {margin:0 -735px 1.5em 735px;} 223 | .push-22 {margin:0 -770px 1.5em 770px;} 224 | .push-23 {margin:0 -805px 1.5em 805px;} 225 | .push-24 {margin:0 -840px 1.5em 840px;} 226 | .push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 {float:right;position:relative;} 227 | .prepend-top {margin-top:1.5em;} 228 | .append-bottom {margin-bottom:1.5em;} 229 | .box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;} 230 | hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;} 231 | hr.space {background:#fff;color:#fff;} 232 | .clearfix:after, .container:after {content:".";display:block;height:0;clear:both;visibility:hidden;} 233 | .clearfix, .container {display:block;} 234 | .clear {clear:both;} 235 | 236 | /* forms.css */ 237 | label {font-weight:bold;} 238 | fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;} 239 | legend {font-weight:bold;font-size:1.2em;} 240 | input.text, input.title, textarea, select {margin:0.5em 0;border:1px solid #bbb;} 241 | input.text:focus, input.title:focus, textarea:focus, select:focus {border:1px solid #666;} 242 | input.text, input.title {width:300px;padding:5px;} 243 | input.title {font-size:1.5em;} 244 | textarea {width:390px;height:250px;padding:5px;} 245 | .error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;} 246 | .error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;} 247 | .notice {background:#FFF6BF;color:#514721;border-color:#FFD324;} 248 | .success {background:#E6EFC2;color:#264409;border-color:#C6D880;} 249 | .error a {color:#8a1f11;} 250 | .notice a {color:#514721;} 251 | .success a {color:#264409;} -------------------------------------------------------------------------------- /javascripts/json2.js: -------------------------------------------------------------------------------- 1 | /* 2 | http://www.JSON.org/json2.js 3 | 2010-03-20 4 | 5 | Public Domain. 6 | 7 | NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 8 | 9 | See http://www.JSON.org/js.html 10 | 11 | 12 | This code should be minified before deployment. 13 | See http://javascript.crockford.com/jsmin.html 14 | 15 | USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO 16 | NOT CONTROL. 17 | 18 | 19 | This file creates a global JSON object containing two methods: stringify 20 | and parse. 21 | 22 | JSON.stringify(value, replacer, space) 23 | value any JavaScript value, usually an object or array. 24 | 25 | replacer an optional parameter that determines how object 26 | values are stringified for objects. It can be a 27 | function or an array of strings. 28 | 29 | space an optional parameter that specifies the indentation 30 | of nested structures. If it is omitted, the text will 31 | be packed without extra whitespace. If it is a number, 32 | it will specify the number of spaces to indent at each 33 | level. If it is a string (such as '\t' or ' '), 34 | it contains the characters used to indent at each level. 35 | 36 | This method produces a JSON text from a JavaScript value. 37 | 38 | When an object value is found, if the object contains a toJSON 39 | method, its toJSON method will be called and the result will be 40 | stringified. A toJSON method does not serialize: it returns the 41 | value represented by the name/value pair that should be serialized, 42 | or undefined if nothing should be serialized. The toJSON method 43 | will be passed the key associated with the value, and this will be 44 | bound to the value 45 | 46 | For example, this would serialize Dates as ISO strings. 47 | 48 | Date.prototype.toJSON = function (key) { 49 | function f(n) { 50 | // Format integers to have at least two digits. 51 | return n < 10 ? '0' + n : n; 52 | } 53 | 54 | return this.getUTCFullYear() + '-' + 55 | f(this.getUTCMonth() + 1) + '-' + 56 | f(this.getUTCDate()) + 'T' + 57 | f(this.getUTCHours()) + ':' + 58 | f(this.getUTCMinutes()) + ':' + 59 | f(this.getUTCSeconds()) + 'Z'; 60 | }; 61 | 62 | You can provide an optional replacer method. It will be passed the 63 | key and value of each member, with this bound to the containing 64 | object. The value that is returned from your method will be 65 | serialized. If your method returns undefined, then the member will 66 | be excluded from the serialization. 67 | 68 | If the replacer parameter is an array of strings, then it will be 69 | used to select the members to be serialized. It filters the results 70 | such that only members with keys listed in the replacer array are 71 | stringified. 72 | 73 | Values that do not have JSON representations, such as undefined or 74 | functions, will not be serialized. Such values in objects will be 75 | dropped; in arrays they will be replaced with null. You can use 76 | a replacer function to replace those with JSON values. 77 | JSON.stringify(undefined) returns undefined. 78 | 79 | The optional space parameter produces a stringification of the 80 | value that is filled with line breaks and indentation to make it 81 | easier to read. 82 | 83 | If the space parameter is a non-empty string, then that string will 84 | be used for indentation. If the space parameter is a number, then 85 | the indentation will be that many spaces. 86 | 87 | Example: 88 | 89 | text = JSON.stringify(['e', {pluribus: 'unum'}]); 90 | // text is '["e",{"pluribus":"unum"}]' 91 | 92 | 93 | text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); 94 | // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' 95 | 96 | text = JSON.stringify([new Date()], function (key, value) { 97 | return this[key] instanceof Date ? 98 | 'Date(' + this[key] + ')' : value; 99 | }); 100 | // text is '["Date(---current time---)"]' 101 | 102 | 103 | JSON.parse(text, reviver) 104 | This method parses a JSON text to produce an object or array. 105 | It can throw a SyntaxError exception. 106 | 107 | The optional reviver parameter is a function that can filter and 108 | transform the results. It receives each of the keys and values, 109 | and its return value is used instead of the original value. 110 | If it returns what it received, then the structure is not modified. 111 | If it returns undefined then the member is deleted. 112 | 113 | Example: 114 | 115 | // Parse the text. Values that look like ISO date strings will 116 | // be converted to Date objects. 117 | 118 | myData = JSON.parse(text, function (key, value) { 119 | var a; 120 | if (typeof value === 'string') { 121 | a = 122 | /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); 123 | if (a) { 124 | return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], 125 | +a[5], +a[6])); 126 | } 127 | } 128 | return value; 129 | }); 130 | 131 | myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { 132 | var d; 133 | if (typeof value === 'string' && 134 | value.slice(0, 5) === 'Date(' && 135 | value.slice(-1) === ')') { 136 | d = new Date(value.slice(5, -1)); 137 | if (d) { 138 | return d; 139 | } 140 | } 141 | return value; 142 | }); 143 | 144 | 145 | This is a reference implementation. You are free to copy, modify, or 146 | redistribute. 147 | */ 148 | 149 | /*jslint evil: true, strict: false */ 150 | 151 | /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, 152 | call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, 153 | getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, 154 | lastIndex, length, parse, prototype, push, replace, slice, stringify, 155 | test, toJSON, toString, valueOf 156 | */ 157 | 158 | 159 | // Create a JSON object only if one does not already exist. We create the 160 | // methods in a closure to avoid creating global variables. 161 | 162 | if (!this.JSON) { 163 | this.JSON = {}; 164 | } 165 | 166 | (function () { 167 | 168 | function f(n) { 169 | // Format integers to have at least two digits. 170 | return n < 10 ? '0' + n : n; 171 | } 172 | 173 | if (typeof Date.prototype.toJSON !== 'function') { 174 | 175 | Date.prototype.toJSON = function (key) { 176 | 177 | return isFinite(this.valueOf()) ? 178 | this.getUTCFullYear() + '-' + 179 | f(this.getUTCMonth() + 1) + '-' + 180 | f(this.getUTCDate()) + 'T' + 181 | f(this.getUTCHours()) + ':' + 182 | f(this.getUTCMinutes()) + ':' + 183 | f(this.getUTCSeconds()) + 'Z' : null; 184 | }; 185 | 186 | String.prototype.toJSON = 187 | Number.prototype.toJSON = 188 | Boolean.prototype.toJSON = function (key) { 189 | return this.valueOf(); 190 | }; 191 | } 192 | 193 | var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 194 | escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 195 | gap, 196 | indent, 197 | meta = { // table of character substitutions 198 | '\b': '\\b', 199 | '\t': '\\t', 200 | '\n': '\\n', 201 | '\f': '\\f', 202 | '\r': '\\r', 203 | '"' : '\\"', 204 | '\\': '\\\\' 205 | }, 206 | rep; 207 | 208 | 209 | function quote(string) { 210 | 211 | // If the string contains no control characters, no quote characters, and no 212 | // backslash characters, then we can safely slap some quotes around it. 213 | // Otherwise we must also replace the offending characters with safe escape 214 | // sequences. 215 | 216 | escapable.lastIndex = 0; 217 | return escapable.test(string) ? 218 | '"' + string.replace(escapable, function (a) { 219 | var c = meta[a]; 220 | return typeof c === 'string' ? c : 221 | '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 222 | }) + '"' : 223 | '"' + string + '"'; 224 | } 225 | 226 | 227 | function str(key, holder) { 228 | 229 | // Produce a string from holder[key]. 230 | 231 | var i, // The loop counter. 232 | k, // The member key. 233 | v, // The member value. 234 | length, 235 | mind = gap, 236 | partial, 237 | value = holder[key]; 238 | 239 | // If the value has a toJSON method, call it to obtain a replacement value. 240 | 241 | if (value && typeof value === 'object' && 242 | typeof value.toJSON === 'function') { 243 | value = value.toJSON(key); 244 | } 245 | 246 | // If we were called with a replacer function, then call the replacer to 247 | // obtain a replacement value. 248 | 249 | if (typeof rep === 'function') { 250 | value = rep.call(holder, key, value); 251 | } 252 | 253 | // What happens next depends on the value's type. 254 | 255 | switch (typeof value) { 256 | case 'string': 257 | return quote(value); 258 | 259 | case 'number': 260 | 261 | // JSON numbers must be finite. Encode non-finite numbers as null. 262 | 263 | return isFinite(value) ? String(value) : 'null'; 264 | 265 | case 'boolean': 266 | case 'null': 267 | 268 | // If the value is a boolean or null, convert it to a string. Note: 269 | // typeof null does not produce 'null'. The case is included here in 270 | // the remote chance that this gets fixed someday. 271 | 272 | return String(value); 273 | 274 | // If the type is 'object', we might be dealing with an object or an array or 275 | // null. 276 | 277 | case 'object': 278 | 279 | // Due to a specification blunder in ECMAScript, typeof null is 'object', 280 | // so watch out for that case. 281 | 282 | if (!value) { 283 | return 'null'; 284 | } 285 | 286 | // Make an array to hold the partial results of stringifying this object value. 287 | 288 | gap += indent; 289 | partial = []; 290 | 291 | // Is the value an array? 292 | 293 | if (Object.prototype.toString.apply(value) === '[object Array]') { 294 | 295 | // The value is an array. Stringify every element. Use null as a placeholder 296 | // for non-JSON values. 297 | 298 | length = value.length; 299 | for (i = 0; i < length; i += 1) { 300 | partial[i] = str(i, value) || 'null'; 301 | } 302 | 303 | // Join all of the elements together, separated with commas, and wrap them in 304 | // brackets. 305 | 306 | v = partial.length === 0 ? '[]' : 307 | gap ? '[\n' + gap + 308 | partial.join(',\n' + gap) + '\n' + 309 | mind + ']' : 310 | '[' + partial.join(',') + ']'; 311 | gap = mind; 312 | return v; 313 | } 314 | 315 | // If the replacer is an array, use it to select the members to be stringified. 316 | 317 | if (rep && typeof rep === 'object') { 318 | length = rep.length; 319 | for (i = 0; i < length; i += 1) { 320 | k = rep[i]; 321 | if (typeof k === 'string') { 322 | v = str(k, value); 323 | if (v) { 324 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 325 | } 326 | } 327 | } 328 | } else { 329 | 330 | // Otherwise, iterate through all of the keys in the object. 331 | 332 | for (k in value) { 333 | if (Object.hasOwnProperty.call(value, k)) { 334 | v = str(k, value); 335 | if (v) { 336 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 337 | } 338 | } 339 | } 340 | } 341 | 342 | // Join all of the member texts together, separated with commas, 343 | // and wrap them in braces. 344 | 345 | v = partial.length === 0 ? '{}' : 346 | gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + 347 | mind + '}' : '{' + partial.join(',') + '}'; 348 | gap = mind; 349 | return v; 350 | } 351 | } 352 | 353 | // If the JSON object does not yet have a stringify method, give it one. 354 | 355 | if (typeof JSON.stringify !== 'function') { 356 | JSON.stringify = function (value, replacer, space) { 357 | 358 | // The stringify method takes a value and an optional replacer, and an optional 359 | // space parameter, and returns a JSON text. The replacer can be a function 360 | // that can replace values, or an array of strings that will select the keys. 361 | // A default replacer method can be provided. Use of the space parameter can 362 | // produce text that is more easily readable. 363 | 364 | var i; 365 | gap = ''; 366 | indent = ''; 367 | 368 | // If the space parameter is a number, make an indent string containing that 369 | // many spaces. 370 | 371 | if (typeof space === 'number') { 372 | for (i = 0; i < space; i += 1) { 373 | indent += ' '; 374 | } 375 | 376 | // If the space parameter is a string, it will be used as the indent string. 377 | 378 | } else if (typeof space === 'string') { 379 | indent = space; 380 | } 381 | 382 | // If there is a replacer, it must be a function or an array. 383 | // Otherwise, throw an error. 384 | 385 | rep = replacer; 386 | if (replacer && typeof replacer !== 'function' && 387 | (typeof replacer !== 'object' || 388 | typeof replacer.length !== 'number')) { 389 | throw new Error('JSON.stringify'); 390 | } 391 | 392 | // Make a fake root object containing our value under the key of ''. 393 | // Return the result of stringifying the value. 394 | 395 | return str('', {'': value}); 396 | }; 397 | } 398 | 399 | 400 | // If the JSON object does not yet have a parse method, give it one. 401 | 402 | if (typeof JSON.parse !== 'function') { 403 | JSON.parse = function (text, reviver) { 404 | 405 | // The parse method takes a text and an optional reviver function, and returns 406 | // a JavaScript value if the text is a valid JSON text. 407 | 408 | var j; 409 | 410 | function walk(holder, key) { 411 | 412 | // The walk method is used to recursively walk the resulting structure so 413 | // that modifications can be made. 414 | 415 | var k, v, value = holder[key]; 416 | if (value && typeof value === 'object') { 417 | for (k in value) { 418 | if (Object.hasOwnProperty.call(value, k)) { 419 | v = walk(value, k); 420 | if (v !== undefined) { 421 | value[k] = v; 422 | } else { 423 | delete value[k]; 424 | } 425 | } 426 | } 427 | } 428 | return reviver.call(holder, key, value); 429 | } 430 | 431 | 432 | // Parsing happens in four stages. In the first stage, we replace certain 433 | // Unicode characters with escape sequences. JavaScript handles many characters 434 | // incorrectly, either silently deleting them, or treating them as line endings. 435 | 436 | text = String(text); 437 | cx.lastIndex = 0; 438 | if (cx.test(text)) { 439 | text = text.replace(cx, function (a) { 440 | return '\\u' + 441 | ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 442 | }); 443 | } 444 | 445 | // In the second stage, we run the text against regular expressions that look 446 | // for non-JSON patterns. We are especially concerned with '()' and 'new' 447 | // because they can cause invocation, and '=' because it can cause mutation. 448 | // But just to be safe, we want to reject all unexpected forms. 449 | 450 | // We split the second stage into 4 regexp operations in order to work around 451 | // crippling inefficiencies in IE's and Safari's regexp engines. First we 452 | // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we 453 | // replace all simple value tokens with ']' characters. Third, we delete all 454 | // open brackets that follow a colon or comma or that begin the text. Finally, 455 | // we look to see that the remaining characters are only whitespace or ']' or 456 | // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. 457 | 458 | if (/^[\],:{}\s]*$/. 459 | test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). 460 | replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). 461 | replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { 462 | 463 | // In the third stage we use the eval function to compile the text into a 464 | // JavaScript structure. The '{' operator is subject to a syntactic ambiguity 465 | // in JavaScript: it can begin a block or an object literal. We wrap the text 466 | // in parens to eliminate the ambiguity. 467 | 468 | j = eval('(' + text + ')'); 469 | 470 | // In the optional fourth stage, we recursively walk the new structure, passing 471 | // each name/value pair to a reviver function for possible transformation. 472 | 473 | return typeof reviver === 'function' ? 474 | walk({'': j}, '') : j; 475 | } 476 | 477 | // If the text is not JSON parseable, then a SyntaxError is thrown. 478 | 479 | throw new SyntaxError('JSON.parse'); 480 | }; 481 | } 482 | }()); -------------------------------------------------------------------------------- /src/raphael.sketchpad.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Raphael SketchPad 3 | * Version 0.5.1 4 | * Copyright (c) 2011 Ian Li (http://ianli.com) 5 | * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. 6 | * 7 | * Requires: 8 | * jQuery http://jquery.com 9 | * Raphael http://raphaeljs.com 10 | * JSON http://www.json.org/js.html 11 | * 12 | * Reference: 13 | * http://ianli.com/sketchpad/ for Usage 14 | * 15 | * Versions: 16 | * 0.5.1 - Fixed extraneous lines when first line is drawn. 17 | * Thanks to http://github.com/peterkeating for the fix! 18 | * 0.5.0 - Added freeze_history. Fixed bug with undoing erase actions. 19 | * 0.4.0 - Support undo/redo of strokes, erase, and clear. 20 | * - Removed input option. To make editors/viewers, set editing option to true/false, respectively. 21 | * To update an input field, listen to change event and update input field with json function. 22 | * - Reduce file size V1. Changed stored path info from array into a string in SVG format. 23 | * 0.3.0 - Added erase, supported initializing data from input field. 24 | * 0.2.0 - Added iPhone/iPod Touch support, onchange event, animate. 25 | * 0.1.0 - Started code. 26 | * 27 | * TODO: 28 | * - Speed up performance. 29 | * - Don't store strokes in two places. _strokes and ActionHistory.current_strokes() 30 | * - Don't rebuild strokes from history with ActionHistory.current_strokes() 31 | * - Reduce file size. 32 | * X V1. Changed stored path info from array into a string in SVG format. 33 | */ 34 | 35 | /** 36 | * We use this wrapper to control global variables. 37 | * The only global variable we expose is Raphael.sketchpad. 38 | */ 39 | (function(Raphael) { 40 | 41 | /** 42 | * Function to create SketchPad object. 43 | */ 44 | Raphael.sketchpad = function(paper, options) { 45 | return new SketchPad(paper, options); 46 | } 47 | 48 | // Current version. 49 | Raphael.sketchpad.VERSION = '0.5.1'; 50 | 51 | /** 52 | * The Sketchpad object. 53 | */ 54 | var SketchPad = function(paper, options) { 55 | // Use self to reduce confusion about this. 56 | var self = this; 57 | 58 | var _options = { 59 | width: 100, 60 | height: 100, 61 | strokes: [], 62 | editing: true 63 | }; 64 | jQuery.extend(_options, options); 65 | 66 | 67 | // The Raphael context to draw on. 68 | var _paper; 69 | if (paper.raphael && paper.raphael.constructor == Raphael.constructor) { 70 | _paper = paper; 71 | } else if (typeof paper == "string") { 72 | _paper = Raphael(paper, _options.width, _options.height); 73 | } else { 74 | throw "first argument must be a Raphael object, an element ID, an array with 3 elements"; 75 | } 76 | 77 | // The Raphael SVG canvas. 78 | var _canvas = _paper.canvas; 79 | 80 | // The HTML element that contains the canvas. 81 | var _container = $(_canvas).parent(); 82 | 83 | // The default pen. 84 | var _pen = new Pen(); 85 | 86 | 87 | // Public Methods 88 | //----------------- 89 | 90 | self.paper = function() { 91 | return _paper; 92 | }; 93 | 94 | self.canvas = function() { 95 | return _canvas; 96 | }; 97 | 98 | self.container = function() { 99 | return _container; 100 | }; 101 | 102 | self.pen = function(value) { 103 | if (value === undefined) { 104 | return _pen; 105 | } 106 | _pen = value; 107 | return self; // function-chaining 108 | }; 109 | 110 | // Convert an SVG path into a string, so that it's smaller when JSONified. 111 | // This function is used by json(). 112 | function svg_path_to_string(path) { 113 | var str = ""; 114 | for (var i = 0, n = path.length; i < n; i++) { 115 | var point = path[i]; 116 | str += point[0] + point[1] + "," + point[2]; 117 | } 118 | return str; 119 | } 120 | 121 | // Convert a string into an SVG path. This reverses the above code. 122 | function string_to_svg_path(str) { 123 | var path = []; 124 | var tokens = str.split("L"); 125 | 126 | if (tokens.length > 0) { 127 | var token = tokens[0].replace("M", ""); 128 | var points = token.split(","); 129 | path.push(["M", parseInt(points[0]), parseInt(points[1])]); 130 | 131 | for (var i = 1, n = tokens.length; i < n; i++) { 132 | token = tokens[i]; 133 | points = token.split(","); 134 | path.push(["L", parseInt(points[0]), parseInt(points[1])]); 135 | } 136 | } 137 | 138 | return path; 139 | } 140 | 141 | self.json = function(value) { 142 | if (value === undefined) { 143 | for (var i = 0, n = _strokes.length; i < n; i++) { 144 | var stroke = _strokes[i]; 145 | if (typeof stroke.path == "object") { 146 | stroke.path = svg_path_to_string(stroke.path); 147 | } 148 | } 149 | return JSON.stringify(_strokes); 150 | } 151 | 152 | return self.strokes(JSON.parse(value)); 153 | }; 154 | 155 | self.strokes = function(value) { 156 | if (value === undefined) { 157 | return _strokes; 158 | } 159 | if (jQuery.isArray(value)) { 160 | _strokes = value; 161 | 162 | for (var i = 0, n = _strokes.length; i < n; i++) { 163 | var stroke = _strokes[i]; 164 | if (typeof stroke.path == "string") { 165 | stroke.path = string_to_svg_path(stroke.path); 166 | } 167 | } 168 | 169 | _action_history.add({ 170 | type: "batch", 171 | strokes: jQuery.merge([], _strokes) // Make a copy. 172 | }) 173 | 174 | _redraw_strokes(); 175 | _fire_change(); 176 | } 177 | return self; // function-chaining 178 | } 179 | 180 | self.freeze_history = function() { 181 | _action_history.freeze(); 182 | }; 183 | 184 | self.undoable = function() { 185 | return _action_history.undoable(); 186 | }; 187 | 188 | self.undo = function() { 189 | if (_action_history.undoable()) { 190 | _action_history.undo(); 191 | _strokes = _action_history.current_strokes(); 192 | _redraw_strokes(); 193 | _fire_change(); 194 | } 195 | return self; // function-chaining 196 | }; 197 | 198 | self.redoable = function() { 199 | return _action_history.redoable(); 200 | }; 201 | 202 | self.redo = function() { 203 | if (_action_history.redoable()) { 204 | _action_history.redo(); 205 | _strokes = _action_history.current_strokes(); 206 | _redraw_strokes(); 207 | _fire_change(); 208 | } 209 | return self; // function-chaining 210 | }; 211 | 212 | self.clear = function() { 213 | _action_history.add({ 214 | type: "clear" 215 | }); 216 | 217 | _strokes = []; 218 | _redraw_strokes(); 219 | _fire_change(); 220 | 221 | return self; // function-chaining 222 | }; 223 | 224 | self.animate = function(ms) { 225 | if (ms === undefined) { 226 | ms = 500; 227 | } 228 | 229 | _paper.clear(); 230 | 231 | if (_strokes.length > 0) { 232 | var i = 0; 233 | 234 | function animate() { 235 | var stroke = _strokes[i]; 236 | var type = stroke.type; 237 | _paper[type]() 238 | .attr(stroke) 239 | .click(_pathclick); 240 | 241 | i++; 242 | if (i < _strokes.length) { 243 | setTimeout(animate, ms); 244 | } 245 | }; 246 | 247 | animate(); 248 | } 249 | 250 | return self; // function-chaining 251 | }; 252 | 253 | self.editing = function(mode) { 254 | if (mode === undefined) { 255 | return _options.editing; 256 | } 257 | 258 | _options.editing = mode; 259 | if (_options.editing) { 260 | if (_options.editing == "erase") { 261 | // Cursor is crosshair, so it looks like we can do something. 262 | $(_container).css("cursor", "crosshair"); 263 | $(_container).unbind("mousedown", _mousedown); 264 | $(_container).unbind("mousemove", _mousemove); 265 | $(_container).unbind("mouseup", _mouseup); 266 | $(document).unbind("mouseup", _mouseup); 267 | 268 | // iPhone Events 269 | var agent = navigator.userAgent; 270 | if (agent.indexOf("iPhone") > 0 || agent.indexOf("iPod") > 0) { 271 | $(_container).unbind("touchstart", _touchstart); 272 | $(_container).unbind("touchmove", _touchmove); 273 | $(_container).unbind("touchend", _touchend); 274 | } 275 | } else { 276 | // Cursor is crosshair, so it looks like we can do something. 277 | $(_container).css("cursor", "crosshair"); 278 | 279 | $(_container).mousedown(_mousedown); 280 | $(_container).mousemove(_mousemove); 281 | $(_container).mouseup(_mouseup); 282 | 283 | // Handle the case when the mouse is released outside the canvas. 284 | $(document).mouseup(_mouseup); 285 | 286 | // iPhone Events 287 | var agent = navigator.userAgent; 288 | if (agent.indexOf("iPhone") > 0 || agent.indexOf("iPod") > 0) { 289 | $(_container).bind("touchstart", _touchstart); 290 | $(_container).bind("touchmove", _touchmove); 291 | $(_container).bind("touchend", _touchend); 292 | } 293 | } 294 | } else { 295 | // Reverse the settings above. 296 | $(_container).attr("style", "cursor:default"); 297 | $(_container).unbind("mousedown", _mousedown); 298 | $(_container).unbind("mousemove", _mousemove); 299 | $(_container).unbind("mouseup", _mouseup); 300 | $(document).unbind("mouseup", _mouseup); 301 | 302 | // iPhone Events 303 | var agent = navigator.userAgent; 304 | if (agent.indexOf("iPhone") > 0 || agent.indexOf("iPod") > 0) { 305 | $(_container).unbind("touchstart", _touchstart); 306 | $(_container).unbind("touchmove", _touchmove); 307 | $(_container).unbind("touchend", _touchend); 308 | } 309 | } 310 | 311 | return self; // function-chaining 312 | } 313 | 314 | // Change events 315 | //---------------- 316 | 317 | var _change_fn = function() {}; 318 | self.change = function(fn) { 319 | if (fn == null || fn === undefined) { 320 | _change_fn = function() {}; 321 | } else if (typeof fn == "function") { 322 | _change_fn = fn; 323 | } 324 | }; 325 | 326 | function _fire_change() { 327 | _change_fn(); 328 | }; 329 | 330 | // Miscellaneous methods 331 | //------------------ 332 | 333 | function _redraw_strokes() { 334 | _paper.clear(); 335 | 336 | for (var i = 0, n = _strokes.length; i < n; i++) { 337 | var stroke = _strokes[i]; 338 | var type = stroke.type; 339 | _paper[type]() 340 | .attr(stroke) 341 | .click(_pathclick); 342 | } 343 | }; 344 | 345 | function _disable_user_select() { 346 | $("*").css("-webkit-user-select", "none"); 347 | $("*").css("-moz-user-select", "none"); 348 | if (jQuery.browser.msie) { 349 | $("body").attr("onselectstart", "return false;"); 350 | } 351 | } 352 | 353 | function _enable_user_select() { 354 | $("*").css("-webkit-user-select", "text"); 355 | $("*").css("-moz-user-select", "text"); 356 | if (jQuery.browser.msie) { 357 | $("body").removeAttr("onselectstart"); 358 | } 359 | } 360 | 361 | // Event handlers 362 | //----------------- 363 | // We can only attach events to the container, so do it. 364 | 365 | function _pathclick(e) { 366 | if (_options.editing == "erase") { 367 | var stroke = this.attr(); 368 | stroke.type = this.type; 369 | 370 | _action_history.add({ 371 | type: "erase", 372 | stroke: stroke 373 | }); 374 | 375 | for (var i = 0, n = _strokes.length; i < n; i++) { 376 | var s = _strokes[i]; 377 | if (equiv(s, stroke)) { 378 | _strokes.splice(i, 1); 379 | } 380 | } 381 | 382 | _fire_change(); 383 | 384 | this.remove(); 385 | } 386 | }; 387 | 388 | function _mousedown(e) { 389 | _disable_user_select(); 390 | 391 | _pen.start(e, self); 392 | }; 393 | 394 | function _mousemove(e) { 395 | _pen.move(e, self); 396 | }; 397 | 398 | function _mouseup(e) { 399 | _enable_user_select(); 400 | 401 | var path = _pen.finish(e, self); 402 | 403 | if (path != null) { 404 | // Add event when clicked. 405 | path.click(_pathclick); 406 | 407 | // Save the stroke. 408 | var stroke = path.attr(); 409 | stroke.type = path.type; 410 | 411 | _strokes.push(stroke); 412 | 413 | _action_history.add({ 414 | type: "stroke", 415 | stroke: stroke 416 | }); 417 | 418 | _fire_change(); 419 | } 420 | }; 421 | 422 | function _touchstart(e) { 423 | e = e.originalEvent; 424 | e.preventDefault(); 425 | 426 | if (e.touches.length == 1) { 427 | var touch = e.touches[0]; 428 | _mousedown(touch); 429 | } 430 | } 431 | 432 | function _touchmove(e) { 433 | e = e.originalEvent; 434 | e.preventDefault(); 435 | 436 | if (e.touches.length == 1) { 437 | var touch = e.touches[0]; 438 | _mousemove(touch); 439 | } 440 | } 441 | 442 | function _touchend(e) { 443 | e = e.originalEvent; 444 | e.preventDefault(); 445 | 446 | _mouseup(e); 447 | } 448 | 449 | // Setup 450 | //-------- 451 | 452 | var _action_history = new ActionHistory(); 453 | 454 | // Path data 455 | var _strokes = _options.strokes; 456 | if (jQuery.isArray(_strokes) && _strokes.length > 0) { 457 | _action_history.add({ 458 | type: "init", 459 | strokes: jQuery.merge([], _strokes) // Make a clone. 460 | }); 461 | _redraw_strokes(); 462 | } else { 463 | _strokes = []; 464 | _redraw_strokes(); 465 | } 466 | 467 | self.editing(_options.editing); 468 | }; 469 | 470 | var ActionHistory = function() { 471 | var self = this; 472 | 473 | var _history = []; 474 | 475 | // Index of the last state. 476 | var _current_state = -1; 477 | 478 | // Index of the freeze state. 479 | // The freeze state is the state where actions cannot be undone. 480 | var _freeze_state = -1; 481 | 482 | // The current set of strokes if strokes were to be rebuilt from history. 483 | // Set to null to force refresh. 484 | var _current_strokes = null; 485 | 486 | self.add = function(action) { 487 | if (_current_state + 1 < _history.length) { 488 | _history.splice(_current_state + 1, _history.length - (_current_state + 1)); 489 | } 490 | 491 | _history.push(action); 492 | _current_state = _history.length - 1; 493 | 494 | // Reset current strokes. 495 | _current_strokes = null; 496 | }; 497 | 498 | self.freeze = function(index) { 499 | if (index === undefined) { 500 | _freeze_state = _current_state; 501 | } else { 502 | _freeze_state = index; 503 | } 504 | }; 505 | 506 | self.undoable = function() { 507 | return (_current_state > -1 && _current_state > _freeze_state); 508 | }; 509 | 510 | self.undo = function() { 511 | if (self.undoable()) { 512 | _current_state--; 513 | 514 | // Reset current strokes. 515 | _current_strokes = null; 516 | } 517 | }; 518 | 519 | self.redoable = function() { 520 | return _current_state < _history.length - 1; 521 | }; 522 | 523 | self.redo = function() { 524 | if (self.redoable()) { 525 | _current_state++; 526 | 527 | // Reset current strokes. 528 | _current_strokes = null; 529 | } 530 | }; 531 | 532 | // Rebuild the strokes from history. 533 | self.current_strokes = function() { 534 | if (_current_strokes == null) { 535 | var strokes = []; 536 | for (var i = 0; i <= _current_state; i++) { 537 | var action = _history[i]; 538 | switch(action.type) { 539 | case "init": 540 | case "json": 541 | case "strokes": 542 | case "batch": 543 | jQuery.merge(strokes, action.strokes); 544 | break; 545 | case "stroke": 546 | strokes.push(action.stroke); 547 | break; 548 | case "erase": 549 | for (var s = 0, n = strokes.length; s < n; s++) { 550 | var stroke = strokes[s]; 551 | if (equiv(stroke, action.stroke)) { 552 | strokes.splice(s, 1); 553 | } 554 | } 555 | break; 556 | case "clear": 557 | strokes = []; 558 | break; 559 | } 560 | } 561 | 562 | _current_strokes = strokes; 563 | } 564 | return _current_strokes; 565 | }; 566 | }; 567 | 568 | /** 569 | * The default Pen object. 570 | */ 571 | var Pen = function() { 572 | var self = this; 573 | 574 | var _color = "#000000"; 575 | var _opacity = 1.0; 576 | var _width = 5; 577 | var _offset = null; 578 | 579 | // Drawing state 580 | var _drawing = false; 581 | var _c = null; 582 | var _points = []; 583 | 584 | self.color = function(value) { 585 | if (value === undefined){ 586 | return _color; 587 | } 588 | 589 | _color = value; 590 | 591 | return self; 592 | }; 593 | 594 | self.width = function(value) { 595 | if (value === undefined) { 596 | return _width; 597 | } 598 | 599 | if (value < Pen.MIN_WIDTH) { 600 | value = Pen.MIN_WIDTH; 601 | } else if (value > Pen.MAX_WIDTH) { 602 | value = Pen.MAX_WIDTH; 603 | } 604 | 605 | _width = value; 606 | 607 | return self; 608 | } 609 | 610 | self.opacity = function(value) { 611 | if (value === undefined) { 612 | return _opacity; 613 | } 614 | 615 | if (value < 0) { 616 | value = 0; 617 | } else if (value > 1) { 618 | value = 1; 619 | } 620 | 621 | _opacity = value; 622 | 623 | return self; 624 | } 625 | 626 | self.start = function(e, sketchpad) { 627 | _drawing = true; 628 | 629 | _offset = $(sketchpad.container()).offset(); 630 | 631 | var x = e.pageX - _offset.left, 632 | y = e.pageY - _offset.top; 633 | _points.push([x, y]); 634 | 635 | _c = sketchpad.paper().path(); 636 | 637 | _c.attr({ 638 | stroke: _color, 639 | "stroke-opacity": _opacity, 640 | "stroke-width": _width, 641 | "stroke-linecap": "round", 642 | "stroke-linejoin": "round" 643 | }); 644 | }; 645 | 646 | self.finish = function(e, sketchpad) { 647 | var path = null; 648 | 649 | if (_c != null) { 650 | if (_points.length <= 1) { 651 | _c.remove(); 652 | } else { 653 | path = _c; 654 | } 655 | } 656 | 657 | _drawing = false; 658 | _c = null; 659 | _points = []; 660 | 661 | return path; 662 | }; 663 | 664 | self.move = function(e, sketchpad) { 665 | if (_drawing == true) { 666 | var x = e.pageX - _offset.left, 667 | y = e.pageY - _offset.top; 668 | _points.push([x, y]); 669 | _c.attr({ path: points_to_svg() }); 670 | } 671 | }; 672 | 673 | function points_to_svg() { 674 | if (_points != null && _points.length > 1) { 675 | var p = _points[0]; 676 | var path = "M" + p[0] + "," + p[1]; 677 | for (var i = 1, n = _points.length; i < n; i++) { 678 | p = _points[i]; 679 | path += "L" + p[0] + "," + p[1]; 680 | } 681 | return path; 682 | } else { 683 | return ""; 684 | } 685 | }; 686 | }; 687 | 688 | Pen.MAX_WIDTH = 1000; 689 | Pen.MIN_WIDTH = 1; 690 | 691 | /** 692 | * Utility to generate string representation of an object. 693 | */ 694 | function inspect(obj) { 695 | var str = ""; 696 | for (var i in obj) { 697 | str += i + "=" + obj[i] + "\n"; 698 | } 699 | return str; 700 | } 701 | 702 | })(window.Raphael); 703 | 704 | Raphael.fn.display = function(elements) { 705 | for (var i = 0, n = elements.length; i < n; i++) { 706 | var e = elements[i]; 707 | var type = e.type; 708 | this[type]().attr(e); 709 | } 710 | }; 711 | 712 | 713 | /** 714 | * Utility functions to compare objects by Phil Rathe. 715 | * http://philrathe.com/projects/equiv 716 | */ 717 | 718 | // Determine what is o. 719 | function hoozit(o) { 720 | if (o.constructor === String) { 721 | return "string"; 722 | 723 | } else if (o.constructor === Boolean) { 724 | return "boolean"; 725 | 726 | } else if (o.constructor === Number) { 727 | 728 | if (isNaN(o)) { 729 | return "nan"; 730 | } else { 731 | return "number"; 732 | } 733 | 734 | } else if (typeof o === "undefined") { 735 | return "undefined"; 736 | 737 | // consider: typeof null === object 738 | } else if (o === null) { 739 | return "null"; 740 | 741 | // consider: typeof [] === object 742 | } else if (o instanceof Array) { 743 | return "array"; 744 | 745 | // consider: typeof new Date() === object 746 | } else if (o instanceof Date) { 747 | return "date"; 748 | 749 | // consider: /./ instanceof Object; 750 | // /./ instanceof RegExp; 751 | // typeof /./ === "function"; // => false in IE and Opera, 752 | // true in FF and Safari 753 | } else if (o instanceof RegExp) { 754 | return "regexp"; 755 | 756 | } else if (typeof o === "object") { 757 | return "object"; 758 | 759 | } else if (o instanceof Function) { 760 | return "function"; 761 | } else { 762 | return undefined; 763 | } 764 | } 765 | 766 | // Call the o related callback with the given arguments. 767 | function bindCallbacks(o, callbacks, args) { 768 | var prop = hoozit(o); 769 | if (prop) { 770 | if (hoozit(callbacks[prop]) === "function") { 771 | return callbacks[prop].apply(callbacks, args); 772 | } else { 773 | return callbacks[prop]; // or undefined 774 | } 775 | } 776 | } 777 | 778 | // Test for equality any JavaScript type. 779 | // Discussions and reference: http://philrathe.com/articles/equiv 780 | // Test suites: http://philrathe.com/tests/equiv 781 | // Author: Philippe Rathé 782 | 783 | var equiv = function () { 784 | 785 | var innerEquiv; // the real equiv function 786 | var callers = []; // stack to decide between skip/abort functions 787 | 788 | 789 | var callbacks = function () { 790 | 791 | // for string, boolean, number and null 792 | function useStrictEquality(b, a) { 793 | if (b instanceof a.constructor || a instanceof b.constructor) { 794 | // to catch short annotaion VS 'new' annotation of a declaration 795 | // e.g. var i = 1; 796 | // var j = new Number(1); 797 | return a == b; 798 | } else { 799 | return a === b; 800 | } 801 | } 802 | 803 | return { 804 | "string": useStrictEquality, 805 | "boolean": useStrictEquality, 806 | "number": useStrictEquality, 807 | "null": useStrictEquality, 808 | "undefined": useStrictEquality, 809 | 810 | "nan": function (b) { 811 | return isNaN(b); 812 | }, 813 | 814 | "date": function (b, a) { 815 | return hoozit(b) === "date" && a.valueOf() === b.valueOf(); 816 | }, 817 | 818 | "regexp": function (b, a) { 819 | return hoozit(b) === "regexp" && 820 | a.source === b.source && // the regex itself 821 | a.global === b.global && // and its modifers (gmi) ... 822 | a.ignoreCase === b.ignoreCase && 823 | a.multiline === b.multiline; 824 | }, 825 | 826 | // - skip when the property is a method of an instance (OOP) 827 | // - abort otherwise, 828 | // initial === would have catch identical references anyway 829 | "function": function () { 830 | var caller = callers[callers.length - 1]; 831 | return caller !== Object && 832 | typeof caller !== "undefined"; 833 | }, 834 | 835 | "array": function (b, a) { 836 | var i; 837 | var len; 838 | 839 | // b could be an object literal here 840 | if ( ! (hoozit(b) === "array")) { 841 | return false; 842 | } 843 | 844 | len = a.length; 845 | if (len !== b.length) { // safe and faster 846 | return false; 847 | } 848 | for (i = 0; i < len; i++) { 849 | if( ! innerEquiv(a[i], b[i])) { 850 | return false; 851 | } 852 | } 853 | return true; 854 | }, 855 | 856 | "object": function (b, a) { 857 | var i; 858 | var eq = true; // unless we can proove it 859 | var aProperties = [], bProperties = []; // collection of strings 860 | 861 | // comparing constructors is more strict than using instanceof 862 | if ( a.constructor !== b.constructor) { 863 | return false; 864 | } 865 | 866 | // stack constructor before traversing properties 867 | callers.push(a.constructor); 868 | 869 | for (i in a) { // be strict: don't ensures hasOwnProperty and go deep 870 | 871 | aProperties.push(i); // collect a's properties 872 | 873 | if ( ! innerEquiv(a[i], b[i])) { 874 | eq = false; 875 | } 876 | } 877 | 878 | callers.pop(); // unstack, we are done 879 | 880 | for (i in b) { 881 | bProperties.push(i); // collect b's properties 882 | } 883 | 884 | // Ensures identical properties name 885 | return eq && innerEquiv(aProperties.sort(), bProperties.sort()); 886 | } 887 | }; 888 | }(); 889 | 890 | innerEquiv = function () { // can take multiple arguments 891 | var args = Array.prototype.slice.apply(arguments); 892 | if (args.length < 2) { 893 | return true; // end transition 894 | } 895 | 896 | return (function (a, b) { 897 | if (a === b) { 898 | return true; // catch the most you can 899 | } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) { 900 | return false; // don't lose time with error prone cases 901 | } else { 902 | return bindCallbacks(a, callbacks, [b, a]); 903 | } 904 | 905 | // apply transition with (1..n) arguments 906 | })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1)); 907 | }; 908 | 909 | return innerEquiv; 910 | 911 | }(); -------------------------------------------------------------------------------- /javascripts/raphael-2.0.1.min.js: -------------------------------------------------------------------------------- 1 | // ┌─────────────────────────────────────────────────────────────────────┐ \\ 2 | // │ Raphaël 2.0.1 - JavaScript Vector Library │ \\ 3 | // ├─────────────────────────────────────────────────────────────────────┤ \\ 4 | // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ 5 | // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ 6 | // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ 7 | // └─────────────────────────────────────────────────────────────────────┘ \\ 8 | (function(a){var b="0.4.0",c="hasOwnProperty",d=/[\.\/]/,e="*",f=function(){},g=function(a,b){return a-b},h,i,j={n:{}},k=function(a,b){var c=j,d=i,e=Array.prototype.slice.call(arguments,2),f=k.listeners(a),l=0,m=!1,n,o=[],p={},q=[],r=[];h=a,i=0;for(var s=0,t=f.length;sf*b.top){e=b.percents[y],p=b.percents[y-1]||0,t=t/b.top*(e-p),o=b.percents[y+1],j=b.anim[e];break}f&&d.attr(b.anim[b.percents[y]])}if(!!j){if(!k){for(var A in j)if(j[g](A))if(U[g](A)||d.paper.customAttributes[g](A)){u[A]=d.attr(A),u[A]==null&&(u[A]=T[A]),v[A]=j[A];switch(U[A]){case C:w[A]=(v[A]-u[A])/t;break;case"colour":u[A]=a.getRGB(u[A]);var B=a.getRGB(v[A]);w[A]={r:(B.r-u[A].r)/t,g:(B.g-u[A].g)/t,b:(B.b-u[A].b)/t};break;case"path":var D=bG(u[A],v[A]),E=D[1];u[A]=D[0],w[A]=[];for(y=0,z=u[A].length;yd)return d;while(cf?c=e:d=e,e=(d-c)/2+c}return e}function n(a,b){var c=o(a,b);return((l*c+k)*c+j)*c}function m(a){return((i*a+h)*a+g)*a}var g=3*b,h=3*(d-b)-g,i=1-g-h,j=3*c,k=3*(e-c)-j,l=1-j-k;return n(a,1/(200*f))}function cd(){return this.x+q+this.y+q+this.width+" × "+this.height}function cc(){return this.x+q+this.y}function bQ(a,b,c,d,e,f){a!=null?(this.a=+a,this.b=+b,this.c=+c,this.d=+d,this.e=+e,this.f=+f):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0)}function bw(a){var b=[];for(var c=0,d=a.length;d-2>c;c+=2){var e=[{x:+a[c],y:+a[c+1]},{x:+a[c],y:+a[c+1]},{x:+a[c+2],y:+a[c+3]},{x:+a[c+4],y:+a[c+5]}];d-4==c?(e[0]={x:+a[c-2],y:+a[c-1]},e[3]=e[2]):c&&(e[0]={x:+a[c-2],y:+a[c-1]}),b.push(["C",(-e[0].x+6*e[1].x+e[2].x)/6,(-e[0].y+6*e[1].y+e[2].y)/6,(e[1].x+6*e[2].x-e[3].x)/6,(e[1].y+6*e[2].y-e[3].y)/6,e[2].x,e[2].y])}return b}function bv(){return this.hex}function bt(a,b,c){function d(){var e=Array.prototype.slice.call(arguments,0),f=e.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];if(h[g](f)){bs(i,f);return c?c(h[f]):h[f]}i.length>=1e3&&delete h[i.shift()],i.push(f),h[f]=a[m](b,e);return c?c(h[f]):h[f]}return d}function bs(a,b){for(var c=0,d=a.length;c',bk=bj.firstChild,bk.style.behavior="url(#default#VML)";if(!bk||typeof bk.adj!="object")return a.type=p;bj=null}a.svg=!(a.vml=a.type=="VML"),a._Paper=j,a.fn=k=j.prototype=a.prototype,a._id=0,a._oid=0,a.is=function(a,b){b=v.call(b);if(b=="finite")return!M[g](+a);if(b=="array")return a instanceof Array;return b=="null"&&a===null||b==typeof a&&a!==null||b=="object"&&a===Object(a)||b=="array"&&Array.isArray&&Array.isArray(a)||H.call(a).slice(8,-1).toLowerCase()==b},a.angle=function(b,c,d,e,f,g){if(f==null){var h=b-d,i=c-e;if(!h&&!i)return 0;return(180+w.atan2(-i,-h)*180/B+360)%360}return a.angle(b,c,f,g)-a.angle(d,e,f,g)},a.rad=function(a){return a%360*B/180},a.deg=function(a){return a*180/B%360},a.snapTo=function(b,c,d){d=a.is(d,"finite")?d:10;if(a.is(b,E)){var e=b.length;while(e--)if(z(b[e]-c)<=d)return b[e]}else{b=+b;var f=c%b;if(fb-d)return c-f+b}return c};var bl=a.createUUID=function(a,b){return function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(a,b).toUpperCase()}}(/[xy]/g,function(a){var b=w.random()*16|0,c=a=="x"?b:b&3|8;return c.toString(16)});a.setWindow=function(b){eve("setWindow",a,h.win,b),h.win=b,h.doc=h.win.document,a._engine.initWin&&a._engine.initWin(h.win)};var bm=function(b){if(a.vml){var c=/^\s+|\s+$/g,d;try{var e=new ActiveXObject("htmlfile");e.write(""),e.close(),d=e.body}catch(f){d=createPopup().document.body}var g=d.createTextRange();bm=bt(function(a){try{d.style.color=r(a).replace(c,p);var b=g.queryCommandValue("ForeColor");b=(b&255)<<16|b&65280|(b&16711680)>>>16;return"#"+("000000"+b.toString(16)).slice(-6)}catch(e){return"none"}})}else{var i=h.doc.createElement("i");i.title="Raphaël Colour Picker",i.style.display="none",h.doc.body.appendChild(i),bm=bt(function(a){i.style.color=a;return h.doc.defaultView.getComputedStyle(i,p).getPropertyValue("color")})}return bm(b)},bn=function(){return"hsb("+[this.h,this.s,this.b]+")"},bo=function(){return"hsl("+[this.h,this.s,this.l]+")"},bp=function(){return this.hex},bq=function(b,c,d){c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b&&(d=b.b,c=b.g,b=b.r);if(c==null&&a.is(b,D)){var e=a.getRGB(b);b=e.r,c=e.g,d=e.b}if(b>1||c>1||d>1)b/=255,c/=255,d/=255;return[b,c,d]},br=function(b,c,d,e){b*=255,c*=255,d*=255;var f={r:b,g:c,b:d,hex:a.rgb(b,c,d),toString:bp};a.is(e,"finite")&&(f.opacity=e);return f};a.color=function(b){var c;a.is(b,"object")&&"h"in b&&"s"in b&&"b"in b?(c=a.hsb2rgb(b),b.r=c.r,b.g=c.g,b.b=c.b,b.hex=c.hex):a.is(b,"object")&&"h"in b&&"s"in b&&"l"in b?(c=a.hsl2rgb(b),b.r=c.r,b.g=c.g,b.b=c.b,b.hex=c.hex):(a.is(b,"string")&&(b=a.getRGB(b)),a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b?(c=a.rgb2hsl(b),b.h=c.h,b.s=c.s,b.l=c.l,c=a.rgb2hsb(b),b.v=c.b):(b={hex:"none"},b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1)),b.toString=bp;return b},a.hsb2rgb=function(a,b,c,d){this.is(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(c=a.b,b=a.s,a=a.h,d=a.o),a*=360;var e,f,g,h,i;a=a%360/60,i=c*b,h=i*(1-z(a%2-1)),e=f=g=c-i,a=~~a,e+=[i,h,0,0,h,i][a],f+=[h,i,i,h,0,0][a],g+=[0,0,h,i,i,h][a];return br(e,f,g,d)},a.hsl2rgb=function(a,b,c,d){this.is(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(c=a.l,b=a.s,a=a.h);if(a>1||b>1||c>1)a/=360,b/=100,c/=100;a*=360;var e,f,g,h,i;a=a%360/60,i=2*b*(c<.5?c:1-c),h=i*(1-z(a%2-1)),e=f=g=c-i/2,a=~~a,e+=[i,h,0,0,h,i][a],f+=[h,i,i,h,0,0][a],g+=[0,0,h,i,i,h][a];return br(e,f,g,d)},a.rgb2hsb=function(a,b,c){c=bq(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;f=x(a,b,c),g=f-y(a,b,c),d=g==0?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=(d+360)%6*60/360,e=g==0?0:g/f;return{h:d,s:e,b:f,toString:bn}},a.rgb2hsl=function(a,b,c){c=bq(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;g=x(a,b,c),h=y(a,b,c),i=g-h,d=i==0?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=(d+360)%6*60/360,f=(g+h)/2,e=i==0?0:f<.5?i/(2*f):i/(2-2*f);return{h:d,s:e,l:f,toString:bo}},a._path2string=function(){return this.join(",").replace(X,"$1")};var bu=a._preload=function(a,b){var c=h.doc.createElement("img");c.style.cssText="position:absolute;left:-9999em;top:-9999em",c.onload=function(){b.call(this),this.onload=null,h.doc.body.removeChild(this)},c.onerror=function(){h.doc.body.removeChild(this)},h.doc.body.appendChild(c),c.src=a};a.getRGB=bt(function(b){if(!b||!!((b=r(b)).indexOf("-")+1))return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:bv};if(b=="none")return{r:-1,g:-1,b:-1,hex:"none",toString:bv};!W[g](b.toLowerCase().substring(0,2))&&b.charAt()!="#"&&(b=bm(b));var c,d,e,f,h,i,j,k=b.match(L);if(k){k[2]&&(f=R(k[2].substring(5),16),e=R(k[2].substring(3,5),16),d=R(k[2].substring(1,3),16)),k[3]&&(f=R((i=k[3].charAt(3))+i,16),e=R((i=k[3].charAt(2))+i,16),d=R((i=k[3].charAt(1))+i,16)),k[4]&&(j=k[4][s](V),d=Q(j[0]),j[0].slice(-1)=="%"&&(d*=2.55),e=Q(j[1]),j[1].slice(-1)=="%"&&(e*=2.55),f=Q(j[2]),j[2].slice(-1)=="%"&&(f*=2.55),k[1].toLowerCase().slice(0,4)=="rgba"&&(h=Q(j[3])),j[3]&&j[3].slice(-1)=="%"&&(h/=100));if(k[5]){j=k[5][s](V),d=Q(j[0]),j[0].slice(-1)=="%"&&(d*=2.55),e=Q(j[1]),j[1].slice(-1)=="%"&&(e*=2.55),f=Q(j[2]),j[2].slice(-1)=="%"&&(f*=2.55),(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360),k[1].toLowerCase().slice(0,4)=="hsba"&&(h=Q(j[3])),j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsb2rgb(d,e,f,h)}if(k[6]){j=k[6][s](V),d=Q(j[0]),j[0].slice(-1)=="%"&&(d*=2.55),e=Q(j[1]),j[1].slice(-1)=="%"&&(e*=2.55),f=Q(j[2]),j[2].slice(-1)=="%"&&(f*=2.55),(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360),k[1].toLowerCase().slice(0,4)=="hsla"&&(h=Q(j[3])),j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsl2rgb(d,e,f,h)}k={r:d,g:e,b:f,toString:bv},k.hex="#"+(16777216|f|e<<8|d<<16).toString(16).slice(1),a.is(h,"finite")&&(k.opacity=h);return k}return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:bv}},a),a.hsb=bt(function(b,c,d){return a.hsb2rgb(b,c,d).hex}),a.hsl=bt(function(b,c,d){return a.hsl2rgb(b,c,d).hex}),a.rgb=bt(function(a,b,c){return"#"+(16777216|c|b<<8|a<<16).toString(16).slice(1)}),a.getColor=function(a){var b=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||.75},c=this.hsb2rgb(b.h,b.s,b.b);b.h+=.075,b.h>1&&(b.h=0,b.s-=.2,b.s<=0&&(this.getColor.start={h:0,s:1,b:b.b}));return c.hex},a.getColor.reset=function(){delete this.start},a.parsePathString=bt(function(b){if(!b)return null;var c={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},d=[];a.is(b,E)&&a.is(b[0],E)&&(d=by(b)),d.length||r(b).replace(Y,function(a,b,e){var f=[],g=b.toLowerCase();e.replace($,function(a,b){b&&f.push(+b)}),g=="m"&&f.length>2&&(d.push([b][n](f.splice(0,2))),g="l",b=b=="m"?"l":"L");if(g=="r")d.push([b][n](f));else while(f.length>=c[g]){d.push([b][n](f.splice(0,c[g])));if(!c[g])break}}),d.toString=a._path2string;return d}),a.parseTransformString=bt(function(b){if(!b)return null;var c={r:3,s:4,t:2,m:6},d=[];a.is(b,E)&&a.is(b[0],E)&&(d=by(b)),d.length||r(b).replace(Z,function(a,b,c){var e=[],f=v.call(b);c.replace($,function(a,b){b&&e.push(+b)}),d.push([b][n](e))}),d.toString=a._path2string;return d}),a.findDotsAtSegment=function(a,b,c,d,e,f,g,h,i){var j=1-i,k=A(j,3),l=A(j,2),m=i*i,n=m*i,o=k*a+l*3*i*c+j*3*i*i*e+n*g,p=k*b+l*3*i*d+j*3*i*i*f+n*h,q=a+2*i*(c-a)+m*(e-2*c+a),r=b+2*i*(d-b)+m*(f-2*d+b),s=c+2*i*(e-c)+m*(g-2*e+c),t=d+2*i*(f-d)+m*(h-2*f+d),u=j*a+i*c,v=j*b+i*d,x=j*e+i*g,y=j*f+i*h,z=90-w.atan2(q-s,r-t)*180/B;(q>s||r1&&(v=w.sqrt(v),c=v*c,d=v*d);var x=c*c,y=d*d,A=(f==g?-1:1)*w.sqrt(z((x*y-x*u*u-y*t*t)/(x*u*u+y*t*t))),C=A*c*u/d+(a+h)/2,D=A*-d*t/c+(b+i)/2,E=w.asin(((b-D)/d).toFixed(9)),F=w.asin(((i-D)/d).toFixed(9));E=aF&&(E=E-B*2),!g&&F>E&&(F=F-B*2)}else E=j[0],F=j[1],C=j[2],D=j[3];var G=F-E;if(z(G)>k){var H=F,I=h,J=i;F=E+k*(g&&F>E?1:-1),h=C+c*w.cos(F),i=D+d*w.sin(F),m=bD(h,i,c,d,e,0,g,I,J,[F,H,C,D])}G=F-E;var K=w.cos(E),L=w.sin(E),M=w.cos(F),N=w.sin(F),O=w.tan(G/4),P=4/3*c*O,Q=4/3*d*O,R=[a,b],S=[a+P*L,b-Q*K],T=[h+P*N,i-Q*M],U=[h,i];S[0]=2*R[0]-S[0],S[1]=2*R[1]-S[1];if(j)return[S,T,U][n](m);m=[S,T,U][n](m).join()[s](",");var V=[];for(var W=0,X=m.length;W"1e12"&&(l=.5),z(n)>"1e12"&&(n=.5),l>0&&l<1&&(q=bE(a,b,c,d,e,f,g,h,l),p.push(q.x),o.push(q.y)),n>0&&n<1&&(q=bE(a,b,c,d,e,f,g,h,n),p.push(q.x),o.push(q.y)),i=f-2*d+b-(h-2*f+d),j=2*(d-b)-2*(f-d),k=b-d,l=(-j+w.sqrt(j*j-4*i*k))/2/i,n=(-j-w.sqrt(j*j-4*i*k))/2/i,z(l)>"1e12"&&(l=.5),z(n)>"1e12"&&(n=.5),l>0&&l<1&&(q=bE(a,b,c,d,e,f,g,h,l),p.push(q.x),o.push(q.y)),n>0&&n<1&&(q=bE(a,b,c,d,e,f,g,h,n),p.push(q.x),o.push(q.y));return{min:{x:y[m](0,p),y:y[m](0,o)},max:{x:x[m](0,p),y:x[m](0,o)}}}),bG=a._path2curve=bt(function(a,b){var c=bA(a),d=b&&bA(b),e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},f={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},g=function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null);switch(a[0]){case"M":b.X=a[1],b.Y=a[2];break;case"A":a=["C"][n](bD[m](0,[b.x,b.y][n](a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x)),d=b.y+(b.y-(b.by||b.y)),a=["C",c,d][n](a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x)),b.qy=b.y+(b.y-(b.qy||b.y)),a=["C"][n](bC(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1],b.qy=a[2],a=["C"][n](bC(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"][n](bB(b.x,b.y,a[1],a[2]));break;case"H":a=["C"][n](bB(b.x,b.y,a[1],b.y));break;case"V":a=["C"][n](bB(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"][n](bB(b.x,b.y,b.X,b.Y))}return a},h=function(a,b){if(a[b].length>7){a[b].shift();var e=a[b];while(e.length)a.splice(b++,0,["C"][n](e.splice(0,6)));a.splice(b,1),k=x(c.length,d&&d.length||0)}},i=function(a,b,e,f,g){a&&b&&a[g][0]=="M"&&b[g][0]!="M"&&(b.splice(g,0,["M",f.x,f.y]),e.bx=0,e.by=0,e.x=a[g][1],e.y=a[g][2],k=x(c.length,d&&d.length||0))};for(var j=0,k=x(c.length,d&&d.length||0);j=j)return p;o=p}if(j==null)return k},cg=function(b,c){return function(d,e,f){d=bG(d);var g,h,i,j,k="",l={},m,n=0;for(var o=0,p=d.length;oe){if(c&&!l.start){m=cf(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n),k+=["C"+m.start.x,m.start.y,m.m.x,m.m.y,m.x,m.y];if(f)return k;l.start=k,k=["M"+m.x,m.y+"C"+m.n.x,m.n.y,m.end.x,m.end.y,i[5],i[6]].join(),n+=j,g=+i[5],h=+i[6];continue}if(!b&&!c){m=cf(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);return{x:m.x,y:m.y,alpha:m.alpha}}}n+=j,g=+i[5],h=+i[6]}k+=i.shift()+i}l.end=k,m=b?n:c?l:a.findDotsAtSegment(g,h,i[0],i[1],i[2],i[3],i[4],i[5],1),m.alpha&&(m={x:m.x,y:m.y,alpha:m.alpha});return m}},ch=cg(1),ci=cg(),cj=cg(0,1);a.getTotalLength=ch,a.getPointAtLength=ci,a.getSubpath=function(a,b,c){if(this.getTotalLength(a)-c<1e-6)return cj(a,b).end;var d=cj(a,c,1);return b?cj(d,b).end:d},b$.getTotalLength=function(){if(this.type=="path"){if(this.node.getTotalLength)return this.node.getTotalLength();return ch(this.attrs.path)}},b$.getPointAtLength=function(a){if(this.type=="path")return ci(this.attrs.path,a)},b$.getSubpath=function(b,c){if(this.type=="path")return a.getSubpath(this.attrs.path,b,c)};var ck=a.easing_formulas={linear:function(a){return a},"<":function(a){return A(a,1.7)},">":function(a){return A(a,.48)},"<>":function(a){var b=.48-a/1.04,c=w.sqrt(.1734+b*b),d=c-b,e=A(z(d),1/3)*(d<0?-1:1),f=-c-b,g=A(z(f),1/3)*(f<0?-1:1),h=e+g+.5;return(1-h)*3*h*h+h*h*h},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){a=a-1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==!!a)return a;return A(2,-10*a)*w.sin((a-.075)*2*B/.3)+1},bounce:function(a){var b=7.5625,c=2.75,d;a<1/c?d=b*a*a:a<2/c?(a-=1.5/c,d=b*a*a+.75):a<2.5/c?(a-=2.25/c,d=b*a*a+.9375):(a-=2.625/c,d=b*a*a+.984375);return d}};ck.easeIn=ck["ease-in"]=ck["<"],ck.easeOut=ck["ease-out"]=ck[">"],ck.easeInOut=ck["ease-in-out"]=ck["<>"],ck["back-in"]=ck.backIn,ck["back-out"]=ck.backOut;var cl=[],cm=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,16)},cn=function(){var b=+(new Date),c=0;for(;c1&&!d.next){for(s in k)k[g](s)&&(r[s]=d.totalOrigin[s]);d.el.attr(r),cr(d.anim,d.el,d.anim.percents[0],null,d.totalOrigin,d.repeat-1)}d.next&&!d.stop&&cr(d.anim,d.el,d.next,null,d.totalOrigin,d.repeat)}}a.svg&&m&&m.paper&&m.paper.safari(),cl.length&&cm(cn)},co=function(a){return a>255?255:a<0?0:a};b$.animateWith=function(b,c,d,e,f,g){var h=d?a.animation(d,e,f,g):c,i=b.status(c);return this.animate(h).status(h,i*c.ms/h.ms)},b$.onAnimation=function(a){a?eve.on("anim.frame."+this.id,a):eve.unbind("anim.frame."+this.id);return this},cq.prototype.delay=function(a){var b=new cq(this.anim,this.ms);b.times=this.times,b.del=+a||0;return b},cq.prototype.repeat=function(a){var b=new cq(this.anim,this.ms);b.del=this.del,b.times=w.floor(x(a,0))||1;return b},a.animation=function(b,c,d,e){if(b instanceof cq)return b;if(a.is(d,"function")||!d)e=e||d||null,d=null;b=Object(b),c=+c||0;var f={},h,i;for(i in b)b[g](i)&&Q(i)!=i&&Q(i)+"%"!=i&&(h=!0,f[i]=b[i]);if(!h)return new cq(b,c);d&&(f.easing=d),e&&(f.callback=e);return new cq({100:f},c)},b$.animate=function(b,c,d,e){var f=this;if(f.removed){e&&e.call(f);return f}var g=b instanceof cq?b:a.animation(b,c,d,e);cr(g,f,g.percents[0],null,f.attr());return f},b$.setTime=function(a,b){a&&b!=null&&this.status(a,y(b,a.ms)/a.ms);return this},b$.status=function(a,b){var c=[],d=0,e,f;if(b!=null){cr(a,this,-1,y(b,1));return this}e=cl.length;for(;d.5)*2-1;i(m-.5,2)+i(n-.5,2)>.25&&(n=f.sqrt(.25-i(m-.5,2))*e+.5)&&n!=.5&&(n=n.toFixed(5)-1e-5*e)}return l}),e=e.split(/\s*\-\s*/);if(j=="linear"){var t=e.shift();t=-d(t);if(isNaN(t))return null;var u=[0,0,f.cos(a.rad(t)),f.sin(a.rad(t))],v=1/(g(h(u[2]),h(u[3]))||1);u[2]*=v,u[3]*=v,u[2]<0&&(u[0]=-u[2],u[2]=0),u[3]<0&&(u[1]=-u[3],u[3]=0)}var w=a._parseDots(e);if(!w)return null;k=k.replace(/[\(\)\s,\xb0#]/g,"_"),b.gradient&&k!=b.gradient.id&&(p.defs.removeChild(b.gradient),delete b.gradient);if(!b.gradient){s=q(j+"Gradient",{id:k}),b.gradient=s,q(s,j=="radial"?{fx:m,fy:n}:{x1:u[0],y1:u[1],x2:u[2],y2:u[3],gradientTransform:b.matrix.invert()}),p.defs.appendChild(s);for(var x=0,y=w.length;x1?G.opacity/100:G.opacity});case"stroke":G=a.getRGB(p),i.setAttribute(o,G.hex),o=="stroke"&&G[b]("opacity")&&q(i,{"stroke-opacity":G.opacity>1?G.opacity/100:G.opacity}),o=="stroke"&&d._.arrows&&("startString"in d._.arrows&&t(d,d._.arrows.startString),"endString"in d._.arrows&&t(d,d._.arrows.endString,1));break;case"gradient":(d.type=="circle"||d.type=="ellipse"||c(p).charAt()!="r")&&r(d,p);break;case"opacity":k.gradient&&!k[b]("stroke-opacity")&&q(i,{"stroke-opacity":p>1?p/100:p});case"fill-opacity":if(k.gradient){H=a._g.doc.getElementById(i.getAttribute("fill").replace(/^url\(#|\)$/g,l)),H&&(I=H.getElementsByTagName("stop"),q(I[I.length-1],{"stop-opacity":p}));break};default:o=="font-size"&&(p=e(p,10)+"px");var J=o.replace(/(\-.)/g,function(a){return a.substring(1).toUpperCase()});i.style[J]=p,d._.dirty=1,i.setAttribute(o,p)}}y(d,f),i.style.visibility=m},x=1.2,y=function(d,f){if(d.type=="text"&&!!(f[b]("text")||f[b]("font")||f[b]("font-size")||f[b]("x")||f[b]("y"))){var g=d.attrs,h=d.node,i=h.firstChild?e(a._g.doc.defaultView.getComputedStyle(h.firstChild,l).getPropertyValue("font-size"),10):10;if(f[b]("text")){g.text=f.text;while(h.firstChild)h.removeChild(h.firstChild);var j=c(f.text).split("\n"),k=[],m;for(var n=0,o=j.length;n"));var $=X.getBoundingClientRect();t.W=m.w=($.right-$.left)/Y,t.H=m.h=($.bottom-$.top)/Y,t.X=m.x,t.Y=m.y+t.H/2,("x"in i||"y"in i)&&(t.path.v=a.format("m{0},{1}l{2},{1}",f(m.x*u),f(m.y*u),f(m.x*u)+1));var _=["x","y","text","font","font-family","font-weight","font-style","font-size"];for(var ba=0,bb=_.length;ba.25&&(c=e.sqrt(.25-i(b-.5,2))*((c>.5)*2-1)+.5),m=b+n+c);return o}),f=f.split(/\s*\-\s*/);if(l=="linear"){var p=f.shift();p=-d(p);if(isNaN(p))return null}var q=a._parseDots(f);if(!q)return null;b=b.shape||b.node;if(q.length){b.removeChild(g),g.on=!0,g.method="none",g.color=q[0].color,g.color2=q[q.length-1].color;var r=[];for(var s=0,t=q.length;s')}}catch(c){F=function(a){return b.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}},a._engine.initWin(a._g.win),a._engine.create=function(){var b=a._getContainer.apply(0,arguments),c=b.container,d=b.height,e,f=b.width,g=b.x,h=b.y;if(!c)throw new Error("VML container not found.");var i=new a._Paper,j=i.canvas=a._g.doc.createElement("div"),k=j.style;g=g||0,h=h||0,f=f||512,d=d||342,i.width=f,i.height=d,f==+f&&(f+="px"),d==+d&&(d+="px"),i.coordsize=u*1e3+n+u*1e3,i.coordorigin="0 0",i.span=a._g.doc.createElement("span"),i.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;",j.appendChild(i.span),k.cssText=a.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",f,d),c==1?(a._g.doc.body.appendChild(j),k.left=g+"px",k.top=h+"px",k.position="absolute"):c.firstChild?c.insertBefore(j,c.firstChild):c.appendChild(j),i.renderfix=function(){};return i},a.prototype.clear=function(){a.eve("clear",this),this.canvas.innerHTML=o,this.span=a._g.doc.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},a.prototype.remove=function(){a.eve("remove",this),this.canvas.parentNode.removeChild(this.canvas);for(var b in this)this[b]=typeof this[b]=="function"?a._removedFactory(b):null;return!0};var G=a.st;for(var H in E)E[b](H)&&!G[b](H)&&(G[H]=function(a){return function(){var b=arguments;return this.forEach(function(c){c[a].apply(c,b)})}}(H))}(window.Raphael) --------------------------------------------------------------------------------