├── .github └── workflows │ └── tests.yml ├── .gitignore ├── .prettierignore ├── CHANGELOG.md ├── Gemfile ├── Gemfile.lock ├── LICENCE ├── Makefile ├── README.md ├── bin └── update_docs ├── composer.json ├── docs └── style.css ├── index.html ├── jest.config.json ├── jquery.peity.js ├── jquery.peity.min.js ├── package-lock.json ├── package.json └── test ├── __snapshots__ └── jquery.peity.test.js.snap ├── app.js ├── chart.js ├── charts.json ├── jquery-1.6.2.min.js ├── jquery.peity.test.js ├── server.js ├── style.css └── views ├── chart.ejs ├── index.ejs └── show.ejs /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: push 4 | 5 | jobs: 6 | rspec: 7 | runs-on: ubuntu-latest 8 | name: Tests 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-node@v4 12 | with: 13 | node-version: 20 14 | cache: 'npm' 15 | - run: npm ci 16 | - run: npm test 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | jquery.peity.min.js.gz 2 | /node_modules 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | jquery.peity.js 2 | jquery.peity.min.js 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## Version 3.3.0 - 2018-01-18 4 | 5 | * Expose an item's value on bar and pie slice SVG nodes on the `data-value` attribute. 6 | 7 | ## Version 3.2.1 - 2016-10-10 8 | 9 | * Ensure NPM package includes only required files. 10 | * Now available in Packagist . 11 | * No functional changes. 12 | 13 | ## Version 3.2.0 - 2015-4-17 14 | 15 | * Add an `after` hook that can be used to decorate a chart. 16 | 17 | ## Version 3.1.2 - 2015-4-14 18 | 19 | * Allow line charts with no fill, just the line. 20 | 21 | ## Version 3.1.1 - 2015-2-11 22 | 23 | * Ensure a donut's default inner radius honours percentage dimensions by deriving it from its calculated radius. 24 | 25 | ## Version 3.1.0 - 2015-1-19 26 | 27 | * Bring back per-chart reading settings from data attributes but with a slightly different interface: all settings are stored on the `data-peity` attribute as JSON. 28 | 29 | ## Version 3.0.3 - 2015-1-16 30 | 31 | * Don't allow negative or zero values to blow up a pie chart. 32 | 33 | ## Version 3.0.2 - 2014-10-17 34 | 35 | * Fix `max`/`min` option when it's a string. 36 | 37 | ## Version 3.0.1 - 2014-10-16 38 | 39 | * jQuery > 1.6.2 doesn’t like `undefined` being passed to `#attr()`. 40 | 41 | ## Version 3.0.0 - 2014-10-15 42 | 43 | * Remove the ability to read options from data attributes. 44 | * Add donut chart type. 45 | * Switch from `diameter` pie chart option to `radius`. 46 | * Expose the internally-used scale functions to the outside world. 47 | * Rename `gap` bar chart option to `padding`. It is now specified as a portion of the width of each bar and is present on both sides. 48 | 49 | ## Version 2.0.5 - 2014-10-15 50 | 51 | * Changes to make the minified version 147 bytes smaller! 52 | 53 | ## Version 2.0.4 - 2014-10-8 54 | 55 | * Fix a null max argument being calculated as zero when all values are negative. 56 | * Ensure that a null min argument means that the minimum is calculated from a chart’s values. 57 | 58 | ## Version 2.0.3 - 2014-4-29 59 | 60 | * Don't blow up drawing a line chart of all zeros. 61 | 62 | ## Version 2.0.2 - 2014-3-26 63 | 64 | * Fix misaligned bar when its value is negative and equal to the minimum. 65 | 66 | ## Version 2.0.1 - 2014-1-22 67 | 68 | * Ensure bars are positioned correctly when a bar chart's values are all equal its minimum value. 69 | 70 | ## Version 2.0.0 - 2014-1-3 71 | 72 | * Switch from `` to ``. 73 | * Update jQuery dependency from 1.4.4 to 1.6.2 due to problems fetching a `` element's dimensions in Firefox. 74 | * Rename `colour`/`colours` options to `fill`. 75 | * Rename `spacing` bar chart option to `gap`. 76 | * Rename `strokeColour` line chart option to `stroke`. 77 | 78 | ## Version 1.2.1 - 2013-11-21 79 | 80 | * Ensure a line chart's outline doesn't spill off the canvas. 81 | 82 | ## Version 1.2.0 - 2013-3-11 83 | 84 | * Easier CSS targeting of Peity-created canvas elements. 85 | * Percentage dimensions (`width: "100%"`) now work. 86 | 87 | ## Version 1.1.2 - 2013-2-23 88 | 89 | * Fix reference to `devicePixelRatio` - thanks [@kcivey](https://github.com/kcivey). 90 | 91 | ## Version 1.1.1 - 2013-2-5 92 | 93 | * component.json for Bower. 94 | * Finally in the jQuery plugin registry: 95 | 96 | ## Version 1.1.0 - 2013-2-1 97 | 98 | * Multiple calls to `peity()` on the same element now update the existing chart rather than creating a new one. 99 | * Zero values in a bar chart are now present as a single-pixel bar. 100 | 101 | ## Version 1.0.0 - 2012-12-4 102 | 103 | * Spacing between bars can now be configured. 104 | * Pie charts can now be formed of more than 2 segments. 105 | * The colours of bar and pie charts can now be set dynamically based on their value. 106 | * Re-write of the internals so that the actual `` element is only created once and `$.wrapInner` is no longer used to contain everything in a separate ``. 107 | * Peity now automatically reads data-* attributes and passes them as options when instantiating a chart. [@buunguyen](https://github.com/buunguyen) 108 | 109 | ## Version 0.6.1 - 2012-10-12 110 | 111 | * Workaround for Linux/Chrome bug when using #arc to draw a full circle not having a zero starting angle. 112 | 113 | ## Version 0.6.0 - 2012-1-27 114 | 115 | * Line and bar charts now support negative numbers. 116 | 117 | ## Version 0.5.0 - 2011-12-6 118 | 119 | * Fix - rename radius to diameter. 120 | * Allow line charts with no stroke. 121 | * Support for iPhone 4 retina display. 122 | 123 | ## Version 0.4.1 - 2011-9-29 124 | 125 | * For a line graph with a single value show a straight line instead of nothing. 126 | 127 | ## Version 0.4.0 - 2011-6-30 128 | 129 | * Allow options to be passed a function called with a `this` value of the element in question. 130 | 131 | ## Version 0.3.5 - 2011-5-12 132 | 133 | * Fix that if the numerator of a pie is zero an empty pie is drawn instead of nothing. [@munikho](https://github.com/munikho) 134 | 135 | ## Version 0.3.4 - 2011-5-12 136 | 137 | * Remove the little border that appears around the slice of a pie when the slice has a darker colour than the plate. [@munikho](https://github.com/munikho) 138 | 139 | ## Version 0.3.3 - 2011-3-20 140 | 141 | * Tweaks to aid minification. 142 | 143 | ## Version 0.3.2 - 2010-5-9 144 | 145 | * Don't blow up if `` isn't supported. 146 | 147 | ## Version 0.3.1 - 2010-5-8 148 | 149 | * Add "strokeWidth" option to line charts. 150 | * Add "max" option to line and bar chart types. 151 | 152 | ## Version 0.3.0 - 2010-5-6 153 | 154 | * Add line and bar graph types and expose an interface for adding more. [@ismasan](https://github.com/ismasan) and me. 155 | 156 | ## Version 0.2.0 - 2010-4-29 157 | 158 | First official version. Thanks to [@ismasan](https://github.com/ismasan) and [@olivernn](https://github.com/olivernn) for adding support for the "change" event and making it work in Firefox respectively. 159 | 160 | ## Birthday - 2009-11-20 161 | 162 | It works! 163 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'hpricot' 4 | gem 'kramdown', '<2' 5 | gem 'rexml' # Needed for kramdown. 6 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | hpricot (0.8.6) 5 | kramdown (1.17.0) 6 | rexml (3.2.6) 7 | 8 | PLATFORMS 9 | arm64-darwin-23 10 | ruby 11 | 12 | DEPENDENCIES 13 | hpricot 14 | kramdown (< 2) 15 | rexml 16 | 17 | BUNDLED WITH 18 | 2.5.6 19 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2009-2020 Ben Pickles 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | UGLIFY=./node_modules/.bin/uglifyjs --compress --mangle -- 2 | VERSION = $(shell head -1 jquery.peity.js | awk '{print $$(NF)}') 3 | 4 | first: test 5 | 6 | %.json: jquery.peity.js 7 | sed -i '' 's/\"version":.*,/"version": "$(VERSION)",/' $@ 8 | 9 | jquery.peity.min.js: jquery.peity.js 10 | head -6 $< > $@ 11 | $(UGLIFY) $< >> $@ 12 | 13 | jquery.peity.min.js.gz: jquery.peity.min.js 14 | gzip -9f < $< > $@ 15 | 16 | clean: 17 | rm jquery.peity.min.js* 18 | 19 | docs: jquery.peity.min.js.gz 20 | bin/update_docs $(VERSION) 21 | 22 | release: test docs package.json 23 | @printf '\e[0;32m%-6s\e[m\n' "Happy days, everything passes. Make sure CHANGELOG.md is already up-to-date, commit everything, and tag it:" 24 | @echo ' $$ git commit -m "Version $(VERSION)."' 25 | @echo ' $$ git tag v$(VERSION)' 26 | @echo ' $$ npm publish' 27 | 28 | server: 29 | node test/server.js 30 | 31 | test: 32 | npm test 33 | 34 | .PHONY: clean release server test 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Peity 2 | 3 | [![Tests](https://github.com/benpickles/peity/actions/workflows/tests.yml/badge.svg)](https://github.com/benpickles/peity/actions/workflows/tests.yml) 4 | 5 | Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini `` pie, donut, line or bar chart. 6 | 7 | ## Basic Usage 8 | 9 | ### HTML 10 | 11 | ```html 12 | 3/5 13 | 5,2,3 14 | 3,5,1,6,2 15 | 2,5,3,6,2,1 16 | ``` 17 | 18 | ### JavaScript (jQuery) 19 | 20 | ```js 21 | $(".pie").peity("pie"); 22 | $(".donut").peity("donut"); 23 | $(".line").peity("line"); 24 | $(".bar").peity("bar"); 25 | ``` 26 | 27 | ## Docs 28 | 29 | More detailed usage can be found at [benpickles.github.io/peity](http://benpickles.github.io/peity/). 30 | 31 | ## Development 32 | 33 | Run the automated tests with: 34 | 35 | npm test 36 | 37 | To manually view all test cases run: 38 | 39 | make server 40 | 41 | And hit . 42 | 43 | ## Release 44 | 45 | Update the version string in `jquery.peity.js`, run `make release`, and follow the instructions. 46 | 47 | ## Copyright 48 | 49 | Copyright 2009-2020 [Ben Pickles](http://benpickles.com/). See [LICENCE](https://github.com/benpickles/peity/blob/master/LICENCE) for details. 50 | -------------------------------------------------------------------------------- /bin/update_docs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'bundler/setup' 4 | require 'hpricot' 5 | require 'kramdown' 6 | 7 | INDEX = 'index.html' 8 | VERSION = ARGV[0] 9 | 10 | def size(filename) 11 | '%.1fKb' % (File.size(filename).to_f / 1024) 12 | end 13 | 14 | doc = Hpricot(File.read(INDEX)) 15 | doc.at('.version').inner_html = "version #{VERSION}" 16 | doc.at('.size-js').inner_html = size('jquery.peity.js') 17 | doc.at('.size-min').inner_html = size('jquery.peity.min.js') 18 | doc.at('.size-gz').inner_html = size('jquery.peity.min.js.gz') 19 | 20 | changelog_md = File.read('CHANGELOG.md') 21 | changelog_html = Kramdown::Document.new(changelog_md, auto_ids: false, input: 'GFM').to_html 22 | changelog_doc = Hpricot(changelog_html) 23 | 24 | changelog_doc.search('h2').each do |h2| 25 | h2.name = 'h3' 26 | end 27 | 28 | h1 = changelog_doc.at('h1') 29 | h1.name = 'h2' 30 | h1['id'] = 'changelog' 31 | 32 | doc.at('.changelog').inner_html = changelog_doc.to_html 33 | 34 | File.write(INDEX, doc.to_original_html) 35 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "benpickles/peity", 3 | "description": "Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini `` pie, donut, line or bar chart.", 4 | "keywords": [ 5 | "jquery-plugin", 6 | "chart", 7 | "graph", 8 | "sparkline", 9 | "svg" 10 | ], 11 | "homepage": "http://benpickles.github.io/peity/", 12 | "license": "MIT", 13 | "authors": [ 14 | { 15 | "name": "Ben Pickles" 16 | } 17 | ], 18 | "require": { 19 | "components/jquery": "@stable" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #fff; 3 | font-family: Baskerville, Georgia, "Times New Roman", serif; 4 | font-size: 1em; 5 | line-height: 1.5em; 6 | margin: 0; 7 | padding: 0; 8 | } 9 | 10 | #fork-me { 11 | background: none; 12 | display: block; 13 | margin: 0; 14 | padding: 0; 15 | position: absolute; 16 | right: 0; 17 | top: 0; 18 | } 19 | #fork-me img { 20 | border: none; 21 | height: 149px; 22 | width: 149px; 23 | } 24 | 25 | #container { 26 | padding: 10px; 27 | } 28 | 29 | h1 { 30 | font-size: 3em; 31 | margin: 0.2em 0 0.4em; 32 | } 33 | 34 | h2 { 35 | font-size: 1.8em; 36 | margin: 0.7em 0 0.2em; 37 | } 38 | 39 | h3 { 40 | font-size: 1.2em; 41 | margin: 0.7em 0 0; 42 | } 43 | 44 | h4 { 45 | color: #666; 46 | font-size: 1em; 47 | margin: 0.7em 0 0; 48 | } 49 | 50 | p { 51 | margin: 0.2em 0 0.3em; 52 | } 53 | 54 | dl { 55 | margin: 0.2em 0 0.3em 10px; 56 | } 57 | 58 | dd { 59 | margin-left: 1em; 60 | } 61 | 62 | footer { 63 | display: block; 64 | margin: 1em 0; 65 | } 66 | 67 | .version { 68 | font-size: 0.6em; 69 | font-weight: normal; 70 | line-height: 1em; 71 | } 72 | 73 | a { 74 | background: #eef; 75 | color: #246; 76 | padding: 1px 2px; 77 | } 78 | a:hover { 79 | color: #123; 80 | text-decoration: none; 81 | } 82 | 83 | code { 84 | background: #f4f4ff; 85 | border: 1px solid #ddf; 86 | padding: 1px 2px; 87 | } 88 | 89 | pre { 90 | background: #f4f4ff; 91 | border-top: 1px solid #ddf; 92 | border-bottom: 1px solid #ddf; 93 | line-height: 1.4em; 94 | margin: 0.3em -10px; 95 | overflow-x: auto; 96 | padding: 0.5em 10px; 97 | } 98 | 99 | pre code { 100 | background: transparent; 101 | border: none; 102 | padding: 0; 103 | } 104 | 105 | /* Browser */ 106 | @media screen and (min-width: 481px) { 107 | body { 108 | text-align: center; 109 | } 110 | 111 | #container { 112 | margin: 0 auto; 113 | max-width: 600px; 114 | text-align: left; 115 | } 116 | 117 | pre { 118 | border-right: 1px solid #ddf; 119 | border-left: 1px solid #ddf; 120 | } 121 | } 122 | 123 | /* iPhone */ 124 | @media screen and (max-width: 480px) { 125 | html { 126 | -webkit-text-size-adjust: none; 127 | } 128 | } 129 | 130 | /* Retina */ 131 | @media screen and (-webkit-min-device-pixel-ratio: 2) { 132 | #fork-me img { 133 | height: 74.5px; 134 | width: 74.5px; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Peity • progressive <svg> pie, donut, bar and line charts 7 | 8 | 9 | 10 | 78 | 89 | 90 | 91 |
92 |

Peity

93 | 94 | 96 | 97 | 99 | 100 |

Peity (sounds like deity) is a jQuery 101 | plugin that converts an element's content into a <svg> 102 | mini pie 2/5 103 | donut 5,2,3 104 | line 5,3,9,6,5,9,7,3,5,2 105 | or bar chart 5,3,9,6,5,9,7,3,5,2 and is 106 | compatible with any browser that supports <svg>: 107 | Chrome, Firefox, IE9+, Opera, Safari.

108 | 109 | 124 | 125 |

Download version 3.3.0

126 | 127 |
128 |
Uncompressed 8.8Kb
129 |
jquery.peity.js
130 |
Minified 3.6Kb (+gzipped 1.7Kb)
131 |
jquery.peity.min.js
132 |
Source
133 |
github.com/benpickles/peity
134 |
135 | 136 | Fork me on GitHub 137 | 138 |

Pie Charts

139 | 140 |

Call peity("pie") on a jQuery selection. There are 141 | two subtly different pie chart semantics, a "/" delimiter is assumed to 142 | mean "three out of five" and only the first two values will be drawn, 143 | otherwise all of the values are included in the chart and the total is the 144 | sum of all values.

145 | 146 |

You can also pass delimiter, fill, 147 | height, radius and width 148 | options. Passing a radius will set the correct width and height, the pie 149 | will always be a circle that fits the available space.

150 | 151 |

152 | 1/5 153 | 226/360 154 | 0.52/1.561 155 | 1,4 156 | 226,134 157 | 0.52,1.041 158 | 1,2,3,2,2 159 |

160 | 161 |
162 |

HTML

163 | 164 |
<span class="pie">1/5</span>
165 | <span class="pie">226/360</span>
166 | <span class="pie">0.52/1.561</span>
167 | <span class="pie">1,4</span>
168 | <span class="pie">226,134</span>
169 | <span class="pie">0.52,1.041</span>
170 | <span class="pie">1,2,3,2,2</span>
171 | 172 |

JavaScript

173 | 174 |
$("span.pie").peity("pie")
175 |
176 | 177 |

Donut Charts

178 | 179 |

Donut charts are the same as pie charts and take the same options with 180 | an added innerRadius option which defaults to half the radius. 181 | 182 |

183 | 1/5 184 | 226/360 185 | 0.52/1.561 186 | 1,4 187 | 226,134 188 | 0.52,1.041 189 | 1,2,3,2,2 190 |

191 | 192 |
193 |

HTML

194 | 195 |
<span class="donut">1/5</span>
196 | <span class="donut">226/360</span>
197 | <span class="donut">0.52/1.561</span>
198 | <span class="donut">1,4</span>
199 | <span class="donut">226,134</span>
200 | <span class="donut">0.52,1.041</span>
201 | <span class="donut">1,2,3,2,2</span>
202 | 203 |

JavaScript

204 | 205 |
$('.donut').peity('donut')
206 |
207 | 208 |

Line Charts

209 | 210 |

Line charts work on a comma-separated list of digits. Line charts can 211 | take the following options: delimiter, fill, 212 | height, max, min, 213 | stroke, strokeWidth and width.

214 | 215 |

216 | 5,3,9,6,5,9,7,3,5,2 217 | 5,3,2,-1,-3,-2,2,3,5,2 218 | 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 219 |

220 | 221 |
222 |

HTML

223 |
<span class="line">5,3,9,6,5,9,7,3,5,2</span>
224 | <span class="line">5,3,2,-1,-3,-2,2,3,5,2</span>
225 | <span class="line">0,-3,-6,-4,-5,-4,-7,-3,-5,-2</span>
226 | 227 |

JavaScript

228 |
$(".line").peity("line")
229 |
230 | 231 |

Bar Charts

232 | 233 |

Bar charts work in the same way as line charts and take the following 234 | options: delimiter, fill, height, 235 | max, min, padding and 236 | width.

237 | 238 |

239 | 5,3,9,6,5,9,7,3,5,2 240 | 5,3,2,-1,-3,-2,2,3,5,2 241 | 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 242 |

243 | 244 |
245 |

HTML

246 |
<span class="bar">5,3,9,6,5,9,7,3,5,2</span>
247 | <span class="bar">5,3,2,-1,-3,-2,2,3,5,2</span>
248 | <span class="bar">0,-3,-6,-4,-5,-4,-7,-3,-5,-2</span>
249 | 250 |

JavaScript

251 |
$(".bar").peity("bar")
252 |
253 | 254 |

data-* attributes

255 | 256 |

Data attributes can be used to pass custom settings per-chart - options 257 | explicitly passed to the peity() function take precedence over 258 | data-* attributes.

259 | 260 |

261 | 1/7 262 | 2/7 263 | 3/7 264 | 4/7 265 | 5/7 266 | 6/7 267 | 7/7 268 |

269 | 270 |
271 |

HTML

272 | 273 |
<p class="data-attributes">
274 |   <span data-peity='{ "fill": ["red", "#eeeeee"],    "innerRadius": 10, "radius": 40 }'>1/7</span>
275 |   <span data-peity='{ "fill": ["orange", "#eeeeee"], "innerRadius": 14, "radius": 36 }'>2/7</span>
276 |   <span data-peity='{ "fill": ["yellow", "#eeeeee"], "innerRadius": 16, "radius": 32 }'>3/7</span>
277 |   <span data-peity='{ "fill": ["green", "#eeeeee"],  "innerRadius": 18, "radius": 28 }'>4/7</span>
278 |   <span data-peity='{ "fill": ["blue", "#eeeeee"],   "innerRadius": 20, "radius": 24 }'>5/7</span>
279 |   <span data-peity='{ "fill": ["indigo", "#eeeeee"], "innerRadius": 18, "radius": 20 }'>6/7</span>
280 |   <span data-peity='{ "fill": ["violet", "#eeeeee"], "innerRadius": 15, "radius": 16 }'>7/7</span>
281 | </p>
282 |

JavaScript

283 | 284 |
$(".data-attributes span").peity("donut")
285 |
286 | 287 |

Setting Colours Dynamically

288 | 289 |

Pie, donut and bar chart colours can be defined dynamically based on the 290 | values of the chart. When passing an array its values are cycled, when 291 | passing a function it is called once for each value allowing you to define 292 | each bar or segment's colour. The callback is invoked with the value, its 293 | index, and the full array of values - the same arguments as the callback for 294 | Array#forEach.

295 | 296 |

297 | 5,3,9,6,5,9,7,3,5,2 298 | 5,3,2,-1,-3,-2,2,3,5,2 299 | 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 300 | 4,7,6,5 301 | 5,3,9,6,5 302 |

303 | 304 |
305 |

HTML

306 |
<span class="bar-colours-1">5,3,9,6,5,9,7,3,5,2</span>
307 | <span class="bar-colours-2">5,3,2,-1,-3,-2,2,3,5,2</span>
308 | <span class="bar-colours-3">0,-3,-6,-4,-5,-4,-7,-3,-5,-2</span>
309 | <span class="pie-colours-1">4,7,6,5</span>
310 | <span class="pie-colours-2">5,3,9,6,5</span>
311 | 312 |

JavaScript

313 |
$(".bar-colours-1").peity("bar", {
314 |   fill: ["red", "green", "blue"]
315 | })
316 | 
317 | $(".bar-colours-2").peity("bar", {
318 |   fill: function(value) {
319 |     return value > 0 ? "green" : "red"
320 |   }
321 | })
322 | 
323 | $(".bar-colours-3").peity("bar", {
324 |   fill: function(_, i, all) {
325 |     var g = parseInt((i / all.length) * 255)
326 |     return "rgb(255, " + g + ", 0)"
327 |   }
328 | })
329 | 
330 | $(".pie-colours-1").peity("pie", {
331 |   fill: ["cyan", "magenta", "yellow", "black"]
332 | })
333 | 
334 | $(".pie-colours-2").peity("pie", {
335 |   fill: function(_, i, all) {
336 |     var g = parseInt((i / all.length) * 255)
337 |     return "rgb(255, " + g + ", 0)"
338 |   }
339 | })
340 |
341 | 342 |

Updating Charts

343 | 344 |

Charts can be updated by changing the the jQuery selection's text content 345 | and calling change() on it. The chart will be redrawn with 346 | the same options that were originally passed to it.

347 | 348 |

349 | 5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2 350 |

351 | 352 |
353 |

HTML

354 |
<span class="updating-chart">5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2</span>
355 | 356 |

JavaScript

357 |
var updatingChart = $(".updating-chart").peity("line", { width: 64 })
358 | 
359 | setInterval(function() {
360 |   var random = Math.round(Math.random() * 10)
361 |   var values = updatingChart.text().split(",")
362 |   values.shift()
363 |   values.push(random)
364 | 
365 |   updatingChart
366 |     .text(values.join(","))
367 |     .change()
368 | }, 1000)
369 |
370 | 371 |

Custom Charts

372 | 373 |

You can add a custom chart type by registering it with Peity with a name, 374 | defaults object, and custom chart drawing function which is called with an 375 | options object. See the existing charts for examples.

376 | 377 |
$.fn.peity.register('custom', {
378 |     option: defaults
379 |   }, function(opts) {
380 |     // Implementation.
381 |   }
382 | )
383 | 384 |

Events

385 | 386 |

Peity adds a "change" event trigger to your graph elements, so if you 387 | update their data your can regenerate one or more charts by triggering 388 | change() on them.

389 | 390 |
    391 |
  • 392 | 393 | 401 |
  • 402 |
  • 403 | 404 | 412 |
  • 413 |
  • 414 | 415 | 423 |
  • 424 |
425 | 426 |

Nothing's happened yet.

427 | 428 |
429 |

HTML

430 | 431 |
<ul>
432 |   <li>
433 |     <span class="graph"></span>
434 |     <select>
435 |       <option value="0">0</option>
436 |       <option value="1">1</option>
437 |       <option value="2">2</option>
438 |       <option value="3">3</option>
439 |       <option value="4" selected>4</option>
440 |       <option value="5">5</option>
441 |     </select>
442 |   </li>
443 |   <li>
444 |     <span class="graph"></span>
445 |     <select>
446 |       <option value="0">0</option>
447 |       <option value="1" selected>1</option>
448 |       <option value="2">2</option>
449 |       <option value="3">3</option>
450 |       <option value="4">4</option>
451 |       <option value="5">5</option>
452 |     </select>
453 |   </li>
454 |   <li>
455 |     <span class="graph"></span>
456 |     <select>
457 |       <option value="0">0</option>
458 |       <option value="1">1</option>
459 |       <option value="2">2</option>
460 |       <option value="3" selected>3</option>
461 |       <option value="4">4</option>
462 |       <option value="5">5</option>
463 |     </select>
464 |   </li>
465 | </ul>
466 | 
467 | <p id="notice">Nothing's happened yet.</p>
468 | 469 |

JavaScript

470 | 471 |
$('select').change(function() {
472 |   var text = $(this).val() + '/' + 5
473 | 
474 |   $(this)
475 |     .siblings('span.graph')
476 |     .text(text)
477 |     .change()
478 | 
479 |   $('#notice').text('Chart updated: ' + text)
480 | }).change()
481 | 
482 | $('span.graph').peity('pie')
483 |
484 | 485 |

Default Settings

486 | 487 |

Defaults can be overridden globally like so:

488 | 489 |
$.fn.peity.defaults.pie = {
490 |   delimiter: null,
491 |   fill: ["#ff9900", "#fff4dd", "#ffd592"],
492 |   height: null,
493 |   radius: 8,
494 |   width: null
495 | }
496 | 
497 | $.fn.peity.defaults.donut = {
498 |   delimiter: null,
499 |   fill: ["#ff9900", "#fff4dd", "#ffd592"],
500 |   height: null,
501 |   innerRadius: null,
502 |   radius: 8,
503 |   width: null
504 | }
505 | 
506 | $.fn.peity.defaults.line = {
507 |   delimiter: ",",
508 |   fill: "#c6d9fd",
509 |   height: 16,
510 |   max: null,
511 |   min: 0,
512 |   stroke: "#4d89f9",
513 |   strokeWidth: 1,
514 |   width: 32
515 | }
516 | 
517 | $.fn.peity.defaults.bar = {
518 |   delimiter: ",",
519 |   fill: ["#4d89f9"],
520 |   height: 16,
521 |   max: null,
522 |   min: 0,
523 |   padding: 0.1,
524 |   width: 32
525 | }
526 | 527 |

CHANGELOG

528 | 529 |

Version 3.3.0 - 2018-01-18

530 | 531 |
    532 |
  • Expose an item’s value on bar and pie slice SVG nodes on the data-value attribute.
  • 533 |
534 | 535 |

Version 3.2.1 - 2016-10-10

536 | 537 | 542 | 543 |

Version 3.2.0 - 2015-4-17

544 | 545 |
    546 |
  • Add an after hook that can be used to decorate a chart.
  • 547 |
548 | 549 |

Version 3.1.2 - 2015-4-14

550 | 551 |
    552 |
  • Allow line charts with no fill, just the line.
  • 553 |
554 | 555 |

Version 3.1.1 - 2015-2-11

556 | 557 |
    558 |
  • Ensure a donut’s default inner radius honours percentage dimensions by deriving it from its calculated radius.
  • 559 |
560 | 561 |

Version 3.1.0 - 2015-1-19

562 | 563 |
    564 |
  • Bring back per-chart reading settings from data attributes but with a slightly different interface: all settings are stored on the data-peity attribute as JSON.
  • 565 |
566 | 567 |

Version 3.0.3 - 2015-1-16

568 | 569 |
    570 |
  • Don’t allow negative or zero values to blow up a pie chart.
  • 571 |
572 | 573 |

Version 3.0.2 - 2014-10-17

574 | 575 |
    576 |
  • Fix max/min option when it’s a string.
  • 577 |
578 | 579 |

Version 3.0.1 - 2014-10-16

580 | 581 |
    582 |
  • jQuery > 1.6.2 doesn’t like undefined being passed to #attr().
  • 583 |
584 | 585 |

Version 3.0.0 - 2014-10-15

586 | 587 |
    588 |
  • Remove the ability to read options from data attributes.
  • 589 |
  • Add donut chart type.
  • 590 |
  • Switch from diameter pie chart option to radius.
  • 591 |
  • Expose the internally-used scale functions to the outside world.
  • 592 |
  • Rename gap bar chart option to padding. It is now specified as a portion of the width of each bar and is present on both sides.
  • 593 |
594 | 595 |

Version 2.0.5 - 2014-10-15

596 | 597 |
    598 |
  • Changes to make the minified version 147 bytes smaller!
  • 599 |
600 | 601 |

Version 2.0.4 - 2014-10-8

602 | 603 |
    604 |
  • Fix a null max argument being calculated as zero when all values are negative.
  • 605 |
  • Ensure that a null min argument means that the minimum is calculated from a chart’s values.
  • 606 |
607 | 608 |

Version 2.0.3 - 2014-4-29

609 | 610 |
    611 |
  • Don’t blow up drawing a line chart of all zeros.
  • 612 |
613 | 614 |

Version 2.0.2 - 2014-3-26

615 | 616 |
    617 |
  • Fix misaligned bar when its value is negative and equal to the minimum.
  • 618 |
619 | 620 |

Version 2.0.1 - 2014-1-22

621 | 622 |
    623 |
  • Ensure bars are positioned correctly when a bar chart’s values are all equal its minimum value.
  • 624 |
625 | 626 |

Version 2.0.0 - 2014-1-3

627 | 628 |
    629 |
  • Switch from <canvas> to <svg>.
  • 630 |
  • Update jQuery dependency from 1.4.4 to 1.6.2 due to problems fetching a <svg> element’s dimensions in Firefox.
  • 631 |
  • Rename colour/colours options to fill.
  • 632 |
  • Rename spacing bar chart option to gap.
  • 633 |
  • Rename strokeColour line chart option to stroke.
  • 634 |
635 | 636 |

Version 1.2.1 - 2013-11-21

637 | 638 |
    639 |
  • Ensure a line chart’s outline doesn’t spill off the canvas.
  • 640 |
641 | 642 |

Version 1.2.0 - 2013-3-11

643 | 644 |
    645 |
  • Easier CSS targeting of Peity-created canvas elements.
  • 646 |
  • Percentage dimensions (width: "100%") now work.
  • 647 |
648 | 649 |

Version 1.1.2 - 2013-2-23

650 | 651 |
    652 |
  • Fix reference to devicePixelRatio - thanks @kcivey.
  • 653 |
654 | 655 |

Version 1.1.1 - 2013-2-5

656 | 657 | 661 | 662 |

Version 1.1.0 - 2013-2-1

663 | 664 |
    665 |
  • Multiple calls to peity() on the same element now update the existing chart rather than creating a new one.
  • 666 |
  • Zero values in a bar chart are now present as a single-pixel bar.
  • 667 |
668 | 669 |

Version 1.0.0 - 2012-12-4

670 | 671 |
    672 |
  • Spacing between bars can now be configured.
  • 673 |
  • Pie charts can now be formed of more than 2 segments.
  • 674 |
  • The colours of bar and pie charts can now be set dynamically based on their value.
  • 675 |
  • Re-write of the internals so that the actual <canvas> element is only created once and $.wrapInner is no longer used to contain everything in a separate <span>.
  • 676 |
  • Peity now automatically reads data-* attributes and passes them as options when instantiating a chart. @buunguyen
  • 677 |
678 | 679 |

Version 0.6.1 - 2012-10-12

680 | 681 |
    682 |
  • Workaround for Linux/Chrome bug when using #arc to draw a full circle not having a zero starting angle.
  • 683 |
684 | 685 |

Version 0.6.0 - 2012-1-27

686 | 687 |
    688 |
  • Line and bar charts now support negative numbers.
  • 689 |
690 | 691 |

Version 0.5.0 - 2011-12-6

692 | 693 |
    694 |
  • Fix - rename radius to diameter.
  • 695 |
  • Allow line charts with no stroke.
  • 696 |
  • Support for iPhone 4 retina display.
  • 697 |
698 | 699 |

Version 0.4.1 - 2011-9-29

700 | 701 |
    702 |
  • For a line graph with a single value show a straight line instead of nothing.
  • 703 |
704 | 705 |

Version 0.4.0 - 2011-6-30

706 | 707 |
    708 |
  • Allow options to be passed a function called with a this value of the element in question.
  • 709 |
710 | 711 |

Version 0.3.5 - 2011-5-12

712 | 713 |
    714 |
  • Fix that if the numerator of a pie is zero an empty pie is drawn instead of nothing. @munikho
  • 715 |
716 | 717 |

Version 0.3.4 - 2011-5-12

718 | 719 |
    720 |
  • Remove the little border that appears around the slice of a pie when the slice has a darker colour than the plate. @munikho
  • 721 |
722 | 723 |

Version 0.3.3 - 2011-3-20

724 | 725 |
    726 |
  • Tweaks to aid minification.
  • 727 |
728 | 729 |

Version 0.3.2 - 2010-5-9

730 | 731 |
    732 |
  • Don’t blow up if <canvas> isn’t supported.
  • 733 |
734 | 735 |

Version 0.3.1 - 2010-5-8

736 | 737 |
    738 |
  • Add “strokeWidth” option to line charts.
  • 739 |
  • Add “max” option to line and bar chart types.
  • 740 |
741 | 742 |

Version 0.3.0 - 2010-5-6

743 | 744 |
    745 |
  • Add line and bar graph types and expose an interface for adding more. @ismasan and me.
  • 746 |
747 | 748 |

Version 0.2.0 - 2010-4-29

749 | 750 |

First official version. Thanks to @ismasan and @olivernn for adding support for the “change” event and making it work in Firefox respectively.

751 | 752 |

Birthday - 2009-11-20

753 | 754 |

It works!

755 |
756 | 757 | 763 |
764 | 765 | 766 | -------------------------------------------------------------------------------- /jest.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "jest-puppeteer" 3 | } 4 | -------------------------------------------------------------------------------- /jquery.peity.js: -------------------------------------------------------------------------------- 1 | // Peity jQuery plugin version 3.3.0 2 | // (c) 2018 Ben Pickles 3 | // 4 | // http://benpickles.github.io/peity 5 | // 6 | // Released under MIT license. 7 | (function($, document, Math, undefined) { 8 | var peity = $.fn.peity = function(type, options) { 9 | if (svgSupported) { 10 | this.each(function() { 11 | var $this = $(this) 12 | var chart = $this.data('_peity') 13 | 14 | if (chart) { 15 | if (type) chart.type = type 16 | $.extend(chart.opts, options) 17 | } else { 18 | chart = new Peity( 19 | $this, 20 | type, 21 | $.extend({}, 22 | peity.defaults[type], 23 | $this.data('peity'), 24 | options) 25 | ) 26 | 27 | $this 28 | .change(function() { chart.draw() }) 29 | .data('_peity', chart) 30 | } 31 | 32 | chart.draw() 33 | }); 34 | } 35 | 36 | return this; 37 | }; 38 | 39 | var Peity = function($el, type, opts) { 40 | this.$el = $el 41 | this.type = type 42 | this.opts = opts 43 | } 44 | 45 | var PeityPrototype = Peity.prototype 46 | 47 | var svgElement = PeityPrototype.svgElement = function(tag, attrs) { 48 | return $( 49 | document.createElementNS('http://www.w3.org/2000/svg', tag) 50 | ).attr(attrs) 51 | } 52 | 53 | // https://gist.github.com/madrobby/3201472 54 | var svgSupported = 'createElementNS' in document && svgElement('svg', {})[0].createSVGRect 55 | 56 | PeityPrototype.draw = function() { 57 | var opts = this.opts 58 | peity.graphers[this.type].call(this, opts) 59 | if (opts.after) opts.after.call(this, opts) 60 | } 61 | 62 | PeityPrototype.fill = function() { 63 | var fill = this.opts.fill 64 | 65 | return $.isFunction(fill) 66 | ? fill 67 | : function(_, i) { return fill[i % fill.length] } 68 | } 69 | 70 | PeityPrototype.prepare = function(width, height) { 71 | if (!this.$svg) { 72 | this.$el.hide().after( 73 | this.$svg = svgElement('svg', { 74 | "class": "peity" 75 | }) 76 | ) 77 | } 78 | 79 | return this.$svg 80 | .empty() 81 | .data('_peity', this) 82 | .attr({ 83 | height: height, 84 | width: width 85 | }) 86 | } 87 | 88 | PeityPrototype.values = function() { 89 | return $.map(this.$el.text().split(this.opts.delimiter), function(value) { 90 | return parseFloat(value) 91 | }) 92 | } 93 | 94 | peity.defaults = {} 95 | peity.graphers = {} 96 | 97 | peity.register = function(type, defaults, grapher) { 98 | this.defaults[type] = defaults 99 | this.graphers[type] = grapher 100 | } 101 | 102 | peity.register( 103 | 'pie', 104 | { 105 | fill: ['#ff9900', '#fff4dd', '#ffc66e'], 106 | radius: 8 107 | }, 108 | function(opts) { 109 | if (!opts.delimiter) { 110 | var delimiter = this.$el.text().match(/[^0-9\.]/) 111 | opts.delimiter = delimiter ? delimiter[0] : "," 112 | } 113 | 114 | var values = $.map(this.values(), function(n) { 115 | return n > 0 ? n : 0 116 | }) 117 | 118 | if (opts.delimiter == "/") { 119 | var v1 = values[0] 120 | var v2 = values[1] 121 | values = [v1, Math.max(0, v2 - v1)] 122 | } 123 | 124 | var i = 0 125 | var length = values.length 126 | var sum = 0 127 | 128 | for (; i < length; i++) { 129 | sum += values[i] 130 | } 131 | 132 | if (!sum) { 133 | length = 2 134 | sum = 1 135 | values = [0, 1] 136 | } 137 | 138 | var diameter = opts.radius * 2 139 | 140 | var $svg = this.prepare( 141 | opts.width || diameter, 142 | opts.height || diameter 143 | ) 144 | 145 | var width = $svg.width() 146 | , height = $svg.height() 147 | , cx = width / 2 148 | , cy = height / 2 149 | 150 | var radius = Math.min(cx, cy) 151 | , innerRadius = opts.innerRadius 152 | 153 | if (this.type == 'donut' && !innerRadius) { 154 | innerRadius = radius * 0.5 155 | } 156 | 157 | var pi = Math.PI 158 | var fill = this.fill() 159 | 160 | var scale = this.scale = function(value, radius) { 161 | var radians = value / sum * pi * 2 - pi / 2 162 | 163 | return [ 164 | radius * Math.cos(radians) + cx, 165 | radius * Math.sin(radians) + cy 166 | ] 167 | } 168 | 169 | var cumulative = 0 170 | 171 | for (i = 0; i < length; i++) { 172 | var value = values[i] 173 | , portion = value / sum 174 | , $node 175 | 176 | if (portion == 0) continue 177 | 178 | if (portion == 1) { 179 | if (innerRadius) { 180 | var x2 = cx - 0.01 181 | , y1 = cy - radius 182 | , y2 = cy - innerRadius 183 | 184 | $node = svgElement('path', { 185 | d: [ 186 | 'M', cx, y1, 187 | 'A', radius, radius, 0, 1, 1, x2, y1, 188 | 'L', x2, y2, 189 | 'A', innerRadius, innerRadius, 0, 1, 0, cx, y2 190 | ].join(' '), 191 | 'data-value': value, 192 | }) 193 | } else { 194 | $node = svgElement('circle', { 195 | cx: cx, 196 | cy: cy, 197 | 'data-value': value, 198 | r: radius 199 | }) 200 | } 201 | } else { 202 | var cumulativePlusValue = cumulative + value 203 | 204 | var d = ['M'].concat( 205 | scale(cumulative, radius), 206 | 'A', radius, radius, 0, portion > 0.5 ? 1 : 0, 1, 207 | scale(cumulativePlusValue, radius), 208 | 'L' 209 | ) 210 | 211 | if (innerRadius) { 212 | d = d.concat( 213 | scale(cumulativePlusValue, innerRadius), 214 | 'A', innerRadius, innerRadius, 0, portion > 0.5 ? 1 : 0, 0, 215 | scale(cumulative, innerRadius) 216 | ) 217 | } else { 218 | d.push(cx, cy) 219 | } 220 | 221 | cumulative += value 222 | 223 | $node = svgElement('path', { 224 | d: d.join(" "), 225 | 'data-value': value, 226 | }) 227 | } 228 | 229 | $node.attr('fill', fill.call(this, value, i, values)) 230 | 231 | $svg.append($node) 232 | } 233 | } 234 | ) 235 | 236 | peity.register( 237 | 'donut', 238 | $.extend(true, {}, peity.defaults.pie), 239 | function(opts) { 240 | peity.graphers.pie.call(this, opts) 241 | } 242 | ) 243 | 244 | peity.register( 245 | "line", 246 | { 247 | delimiter: ",", 248 | fill: "#c6d9fd", 249 | height: 16, 250 | min: 0, 251 | stroke: "#4d89f9", 252 | strokeWidth: 1, 253 | width: 32 254 | }, 255 | function(opts) { 256 | var values = this.values() 257 | if (values.length == 1) values.push(values[0]) 258 | var max = Math.max.apply(Math, opts.max == undefined ? values : values.concat(opts.max)) 259 | , min = Math.min.apply(Math, opts.min == undefined ? values : values.concat(opts.min)) 260 | 261 | var $svg = this.prepare(opts.width, opts.height) 262 | , strokeWidth = opts.strokeWidth 263 | , width = $svg.width() 264 | , height = $svg.height() - strokeWidth 265 | , diff = max - min 266 | 267 | var xScale = this.x = function(input) { 268 | return input * (width / (values.length - 1)) 269 | } 270 | 271 | var yScale = this.y = function(input) { 272 | var y = height 273 | 274 | if (diff) { 275 | y -= ((input - min) / diff) * height 276 | } 277 | 278 | return y + strokeWidth / 2 279 | } 280 | 281 | var zero = yScale(Math.max(min, 0)) 282 | , coords = [0, zero] 283 | 284 | for (var i = 0; i < values.length; i++) { 285 | coords.push( 286 | xScale(i), 287 | yScale(values[i]) 288 | ) 289 | } 290 | 291 | coords.push(width, zero) 292 | 293 | if (opts.fill) { 294 | $svg.append( 295 | svgElement('polygon', { 296 | fill: opts.fill, 297 | points: coords.join(' ') 298 | }) 299 | ) 300 | } 301 | 302 | if (strokeWidth) { 303 | $svg.append( 304 | svgElement('polyline', { 305 | fill: 'none', 306 | points: coords.slice(2, coords.length - 2).join(' '), 307 | stroke: opts.stroke, 308 | 'stroke-width': strokeWidth, 309 | 'stroke-linecap': 'square' 310 | }) 311 | ) 312 | } 313 | } 314 | ); 315 | 316 | peity.register( 317 | 'bar', 318 | { 319 | delimiter: ",", 320 | fill: ["#4D89F9"], 321 | height: 16, 322 | min: 0, 323 | padding: 0.1, 324 | width: 32 325 | }, 326 | function(opts) { 327 | var values = this.values() 328 | , max = Math.max.apply(Math, opts.max == undefined ? values : values.concat(opts.max)) 329 | , min = Math.min.apply(Math, opts.min == undefined ? values : values.concat(opts.min)) 330 | 331 | var $svg = this.prepare(opts.width, opts.height) 332 | , width = $svg.width() 333 | , height = $svg.height() 334 | , diff = max - min 335 | , padding = opts.padding 336 | , fill = this.fill() 337 | 338 | var xScale = this.x = function(input) { 339 | return input * width / values.length 340 | } 341 | 342 | var yScale = this.y = function(input) { 343 | return height - ( 344 | diff 345 | ? ((input - min) / diff) * height 346 | : 1 347 | ) 348 | } 349 | 350 | for (var i = 0; i < values.length; i++) { 351 | var x = xScale(i + padding) 352 | , w = xScale(i + 1 - padding) - x 353 | , value = values[i] 354 | , valueY = yScale(value) 355 | , y1 = valueY 356 | , y2 = valueY 357 | , h 358 | 359 | if (!diff) { 360 | h = 1 361 | } else if (value < 0) { 362 | y1 = yScale(Math.min(max, 0)) 363 | } else { 364 | y2 = yScale(Math.max(min, 0)) 365 | } 366 | 367 | h = y2 - y1 368 | 369 | if (h == 0) { 370 | h = 1 371 | if (max > 0 && diff) y1-- 372 | } 373 | 374 | $svg.append( 375 | svgElement('rect', { 376 | 'data-value': value, 377 | fill: fill.call(this, value, i, values), 378 | x: x, 379 | y: y1, 380 | width: w, 381 | height: h 382 | }) 383 | ) 384 | } 385 | } 386 | ); 387 | })(jQuery, document, Math); 388 | -------------------------------------------------------------------------------- /jquery.peity.min.js: -------------------------------------------------------------------------------- 1 | // Peity jQuery plugin version 3.3.0 2 | // (c) 2018 Ben Pickles 3 | // 4 | // http://benpickles.github.io/peity 5 | // 6 | // Released under MIT license. 7 | !function(t,i,e,n){var a=t.fn.peity=function(i,e){return l&&this.each(function(){var n=t(this),h=n.data("_peity");h?(i&&(h.type=i),t.extend(h.opts,e)):(h=new r(n,i,t.extend({},a.defaults[i],n.data("peity"),e)),n.change(function(){h.draw()}).data("_peity",h)),h.draw()}),this},r=function(t,i,e){this.$el=t,this.type=i,this.opts=e},h=r.prototype,s=h.svgElement=function(e,n){return t(i.createElementNS("http://www.w3.org/2000/svg",e)).attr(n)},l="createElementNS"in i&&s("svg",{})[0].createSVGRect;h.draw=function(){var t=this.opts;a.graphers[this.type].call(this,t),t.after&&t.after.call(this,t)},h.fill=function(){var i=this.opts.fill;return t.isFunction(i)?i:function(t,e){return i[e%i.length]}},h.prepare=function(t,i){return this.$svg||this.$el.hide().after(this.$svg=s("svg",{class:"peity"})),this.$svg.empty().data("_peity",this).attr({height:i,width:t})},h.values=function(){return t.map(this.$el.text().split(this.opts.delimiter),function(t){return parseFloat(t)})},a.defaults={},a.graphers={},a.register=function(t,i,e){this.defaults[t]=i,this.graphers[t]=e},a.register("pie",{fill:["#ff9900","#fff4dd","#ffc66e"],radius:8},function(i){if(!i.delimiter){var n=this.$el.text().match(/[^0-9\.]/);i.delimiter=n?n[0]:","}var a=t.map(this.values(),function(t){return t>0?t:0});if("/"==i.delimiter){var r=a[0],h=a[1];a=[r,e.max(0,h-r)]}for(var l=0,p=a.length,o=0;l.5?1:0,1,w(M,g),"L");v?S=S.concat(w(M,v),"A",v,v,0,j>.5?1:0,0,w(x,v)):S.push(u,d),x+=$,k=s("path",{d:S.join(" "),"data-value":$})}k.attr("fill",y.call(this,$,l,a)),c.append(k)}}}),a.register("donut",t.extend(!0,{},a.defaults.pie),function(t){a.graphers.pie.call(this,t)}),a.register("line",{delimiter:",",fill:"#c6d9fd",height:16,min:0,stroke:"#4d89f9",strokeWidth:1,width:32},function(t){var i=this.values();1==i.length&&i.push(i[0]);for(var a=e.max.apply(e,t.max==n?i:i.concat(t.max)),r=e.min.apply(e,t.min==n?i:i.concat(t.min)),h=this.prepare(t.width,t.height),l=t.strokeWidth,p=h.width(),o=h.height()-l,f=a-r,c=this.x=function(t){return t*(p/(i.length-1))},u=this.y=function(t){var i=o;return f&&(i-=(t-r)/f*o),i+l/2},d=u(e.max(r,0)),g=[0,d],v=0;v0&&o&&k--),h.append(s("rect",{"data-value":w,fill:c.call(this,w,g,i),x:m,y:k,width:y,height:v}))}})}(jQuery,document,Math); 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "peity", 3 | "version": "3.3.0", 4 | "description": "Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini `svg` pie, line or bar chart.", 5 | "main": "jquery.peity.js", 6 | "files": [ 7 | "CHANGELOG.md", 8 | "LICENCE", 9 | "README.md", 10 | "jquery.peity.js", 11 | "jquery.peity.min.js" 12 | ], 13 | "devDependencies": { 14 | "ejs": "^2.5.5", 15 | "express": "^4.14.1", 16 | "jest": "^29.7.0", 17 | "jest-puppeteer": "^10.0.1", 18 | "jsdom": "^24.0.0", 19 | "prettier": "^3.2.5", 20 | "uglify-js": "^3.3.7" 21 | }, 22 | "scripts": { 23 | "test": "jest" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/benpickles/peity.git" 28 | }, 29 | "keywords": [ 30 | "jquery-plugin", 31 | "ecosystem:jquery", 32 | "chart", 33 | "graph", 34 | "sparkline", 35 | "svg" 36 | ], 37 | "author": "Ben Pickles", 38 | "license": "MIT", 39 | "bugs": { 40 | "url": "https://github.com/benpickles/peity/issues" 41 | }, 42 | "homepage": "https://github.com/benpickles/peity", 43 | "prettier": { 44 | "arrowParens": "avoid", 45 | "semi": false, 46 | "singleQuote": true, 47 | "trailingComma": "es5" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/__snapshots__/jquery.peity.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`renders test chart bar1 correctly 1`] = ` 4 | 5 | 8 | 5,0,9,6,5,9,7,3,5,2 9 | 10 | 15 | 23 | 31 | 39 | 47 | 55 | 63 | 71 | 79 | 87 | 95 | 96 | 97 | `; 98 | 99 | exports[`renders test chart bar2 correctly 1`] = ` 100 | 101 | 104 | 0,3,2,-1,-3,-2,2,3,5,2 105 | 106 | 111 | 119 | 127 | 135 | 143 | 151 | 159 | 167 | 175 | 183 | 191 | 192 | 193 | `; 194 | 195 | exports[`renders test chart bar3 correctly 1`] = ` 196 | 197 | 200 | -3,0,-6,-4,-5,-4,-7,-3,-5,-2 201 | 202 | 207 | 215 | 223 | 231 | 239 | 247 | 255 | 263 | 271 | 279 | 287 | 288 | 289 | `; 290 | 291 | exports[`renders test chart bar4 correctly 1`] = ` 292 | 293 | 296 | 5,3,9,6,5,9,7,3,5,2 297 | 298 | 303 | 311 | 319 | 327 | 335 | 343 | 351 | 359 | 367 | 375 | 383 | 384 | 385 | `; 386 | 387 | exports[`renders test chart bar5 correctly 1`] = ` 388 | 389 | 392 | 5,3,2,-1,-3,-2,2,3,5,2 393 | 394 | 399 | 407 | 415 | 423 | 431 | 439 | 447 | 455 | 463 | 471 | 479 | 480 | 481 | `; 482 | 483 | exports[`renders test chart bar6 correctly 1`] = ` 484 | 485 | 488 | 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 489 | 490 | 495 | 503 | 511 | 519 | 527 | 535 | 543 | 551 | 559 | 567 | 575 | 576 | 577 | `; 578 | 579 | exports[`renders test chart bar7 correctly 1`] = ` 580 | 581 | 584 | 0,0,0,0,0 585 | 586 | 591 | 599 | 607 | 615 | 623 | 631 | 632 | 633 | `; 634 | 635 | exports[`renders test chart bar8 correctly 1`] = ` 636 | 637 | 640 | 1,1,1,1,1 641 | 642 | 647 | 655 | 663 | 671 | 679 | 687 | 688 | 689 | `; 690 | 691 | exports[`renders test chart bar9 correctly 1`] = ` 692 | 693 | 696 | 1,1,1,1,1 697 | 698 | 703 | 711 | 719 | 727 | 735 | 743 | 744 | 745 | `; 746 | 747 | exports[`renders test chart bar10 correctly 1`] = ` 748 | 749 | 752 | -10,-15,-13,-14,-11 753 | 754 | 759 | 767 | 775 | 783 | 791 | 799 | 800 | 801 | `; 802 | 803 | exports[`renders test chart bar11 correctly 1`] = ` 804 | 805 | 808 | -10,-15,-13,-14,-11 809 | 810 | 815 | 823 | 831 | 839 | 847 | 855 | 856 | 857 | `; 858 | 859 | exports[`renders test chart bar12 correctly 1`] = ` 860 | 861 | 864 | 1000,1005,1003,1004,1001 865 | 866 | 871 | 879 | 887 | 895 | 903 | 911 | 912 | 913 | `; 914 | 915 | exports[`renders test chart bar13 correctly 1`] = ` 916 | 917 | 920 | 5,3,9,6,5,9,7,3,5,2 921 | 922 | 927 | 935 | 943 | 951 | 959 | 967 | 975 | 983 | 991 | 999 | 1007 | 1008 | 1009 | `; 1010 | 1011 | exports[`renders test chart bar14 correctly 1`] = ` 1012 | 1013 | 1016 | 5,0,9,6,5,9,7,3,5,2 1017 | 1018 | 1023 | 1031 | 1039 | 1047 | 1055 | 1063 | 1071 | 1079 | 1087 | 1095 | 1103 | 1110 | 1111 | 1112 | `; 1113 | 1114 | exports[`renders test chart donut1 correctly 1`] = ` 1115 | 1116 | 1119 | 1/5 1120 | 1121 | 1126 | 1131 | 1136 | 1137 | 1138 | `; 1139 | 1140 | exports[`renders test chart donut2 correctly 1`] = ` 1141 | 1142 | 1145 | 0.52/1.561 1146 | 1147 | 1152 | 1157 | 1162 | 1163 | 1164 | `; 1165 | 1166 | exports[`renders test chart donut3 correctly 1`] = ` 1167 | 1168 | 1171 | 1,4 1172 | 1173 | 1178 | 1183 | 1188 | 1189 | 1190 | `; 1191 | 1192 | exports[`renders test chart donut4 correctly 1`] = ` 1193 | 1194 | 1197 | 4,7,6,5 1198 | 1199 | 1204 | 1209 | 1214 | 1219 | 1224 | 1225 | 1226 | `; 1227 | 1228 | exports[`renders test chart donut5 correctly 1`] = ` 1229 | 1230 | 1233 | 3/3 1234 | 1235 | 1240 | 1245 | 1246 | 1247 | `; 1248 | 1249 | exports[`renders test chart donut6 correctly 1`] = ` 1250 | 1251 | 1254 | 0/3 1255 | 1256 | 1261 | 1266 | 1267 | 1268 | `; 1269 | 1270 | exports[`renders test chart donut7 correctly 1`] = ` 1271 | 1272 | 1275 | 3,0 1276 | 1277 | 1282 | 1287 | 1288 | 1289 | `; 1290 | 1291 | exports[`renders test chart donut8 correctly 1`] = ` 1292 | 1293 | 1296 | 4/3 1297 | 1298 | 1303 | 1308 | 1309 | 1310 | `; 1311 | 1312 | exports[`renders test chart donut9 correctly 1`] = ` 1313 | 1314 | 1317 | 1/5 1318 | 1319 | 1324 | 1329 | 1334 | 1335 | 1336 | `; 1337 | 1338 | exports[`renders test chart donut10 correctly 1`] = ` 1339 | 1340 | 1343 | 1,-2,3 1344 | 1345 | 1350 | 1355 | 1360 | 1361 | 1362 | `; 1363 | 1364 | exports[`renders test chart donut11 correctly 1`] = ` 1365 | 1366 | 1369 | -2/3 1370 | 1371 | 1376 | 1381 | 1382 | 1383 | `; 1384 | 1385 | exports[`renders test chart donut12 correctly 1`] = ` 1386 | 1387 | 1390 | 0,0,0,0,0 1391 | 1392 | 1397 | 1402 | 1403 | 1404 | `; 1405 | 1406 | exports[`renders test chart donut13 correctly 1`] = ` 1407 | 1408 | 1411 | 2,4,5 1412 | 1413 | 1418 | 1423 | 1428 | 1433 | 1441 | 1442 | 1443 | `; 1444 | 1445 | exports[`renders test chart line1 correctly 1`] = ` 1446 | 1447 | 1450 | 5,3,9,6,5,9,7,3,5,2 1451 | 1452 | 1457 | 1461 | 1468 | 1469 | 1470 | `; 1471 | 1472 | exports[`renders test chart line2 correctly 1`] = ` 1473 | 1474 | 1477 | 5,3,2,-1,-3,-2,2,3,5,2 1478 | 1479 | 1484 | 1488 | 1495 | 1496 | 1497 | `; 1498 | 1499 | exports[`renders test chart line3 correctly 1`] = ` 1500 | 1501 | 1504 | 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 1505 | 1506 | 1511 | 1515 | 1522 | 1523 | 1524 | `; 1525 | 1526 | exports[`renders test chart line4 correctly 1`] = ` 1527 | 1528 | 1531 | 5,3,9,6,5,9,7,3,5,2 1532 | 1533 | 1538 | 1542 | 1549 | 1550 | 1551 | `; 1552 | 1553 | exports[`renders test chart line5 correctly 1`] = ` 1554 | 1555 | 1558 | 0,0,0,0,0 1559 | 1560 | 1565 | 1569 | 1576 | 1577 | 1578 | `; 1579 | 1580 | exports[`renders test chart line6 correctly 1`] = ` 1581 | 1582 | 1585 | 1,1,1,1,1 1586 | 1587 | 1592 | 1596 | 1603 | 1604 | 1605 | `; 1606 | 1607 | exports[`renders test chart line7 correctly 1`] = ` 1608 | 1609 | 1612 | -10,-15,-13,-14,-11 1613 | 1614 | 1619 | 1623 | 1630 | 1631 | 1632 | `; 1633 | 1634 | exports[`renders test chart line8 correctly 1`] = ` 1635 | 1636 | 1639 | -10,-15,-13,-14,-11 1640 | 1641 | 1646 | 1650 | 1657 | 1658 | 1659 | `; 1660 | 1661 | exports[`renders test chart line9 correctly 1`] = ` 1662 | 1663 | 1666 | 1000,1005,1003,1004,1001 1667 | 1668 | 1673 | 1677 | 1684 | 1685 | 1686 | `; 1687 | 1688 | exports[`renders test chart line10 correctly 1`] = ` 1689 | 1690 | 1693 | 5,3,9,6,5,9,7,3,5,2 1694 | 1695 | 1700 | 1704 | 1711 | 1712 | 1713 | `; 1714 | 1715 | exports[`renders test chart line11 correctly 1`] = ` 1716 | 1717 | 1720 | 5,3,9,6,5,9,7,3,5,2 1721 | 1722 | 1727 | 1734 | 1735 | 1736 | `; 1737 | 1738 | exports[`renders test chart line12 correctly 1`] = ` 1739 | 1740 | 1743 | 5,0,9,6,5,9,7,3,5,2 1744 | 1745 | 1750 | 1754 | 1761 | 1768 | 1769 | 1770 | `; 1771 | 1772 | exports[`renders test chart pie1 correctly 1`] = ` 1773 | 1774 | 1777 | 1/5 1778 | 1779 | 1784 | 1789 | 1794 | 1795 | 1796 | `; 1797 | 1798 | exports[`renders test chart pie2 correctly 1`] = ` 1799 | 1800 | 1803 | 0.52/1.561 1804 | 1805 | 1810 | 1815 | 1820 | 1821 | 1822 | `; 1823 | 1824 | exports[`renders test chart pie3 correctly 1`] = ` 1825 | 1826 | 1829 | 1,4 1830 | 1831 | 1836 | 1841 | 1846 | 1847 | 1848 | `; 1849 | 1850 | exports[`renders test chart pie4 correctly 1`] = ` 1851 | 1852 | 1855 | 4,7,6,5 1856 | 1857 | 1862 | 1867 | 1872 | 1877 | 1882 | 1883 | 1884 | `; 1885 | 1886 | exports[`renders test chart pie5 correctly 1`] = ` 1887 | 1888 | 1891 | 3/3 1892 | 1893 | 1898 | 1905 | 1906 | 1907 | `; 1908 | 1909 | exports[`renders test chart pie6 correctly 1`] = ` 1910 | 1911 | 1914 | 0/3 1915 | 1916 | 1921 | 1928 | 1929 | 1930 | `; 1931 | 1932 | exports[`renders test chart pie7 correctly 1`] = ` 1933 | 1934 | 1937 | 3,0 1938 | 1939 | 1944 | 1951 | 1952 | 1953 | `; 1954 | 1955 | exports[`renders test chart pie8 correctly 1`] = ` 1956 | 1957 | 1960 | 4/3 1961 | 1962 | 1967 | 1974 | 1975 | 1976 | `; 1977 | 1978 | exports[`renders test chart pie9 correctly 1`] = ` 1979 | 1980 | 1983 | 1,-2,3 1984 | 1985 | 1990 | 1995 | 2000 | 2001 | 2002 | `; 2003 | 2004 | exports[`renders test chart pie10 correctly 1`] = ` 2005 | 2006 | 2009 | -2/3 2010 | 2011 | 2016 | 2023 | 2024 | 2025 | `; 2026 | 2027 | exports[`renders test chart pie11 correctly 1`] = ` 2028 | 2029 | 2032 | 0,0,0,0,0 2033 | 2034 | 2039 | 2046 | 2047 | 2048 | `; 2049 | 2050 | exports[`renders test chart pie12 correctly 1`] = ` 2051 | 2052 | 2055 | 2,4,5 2056 | 2057 | 2062 | 2067 | 2072 | 2077 | 2085 | 2086 | 2087 | `; 2088 | -------------------------------------------------------------------------------- /test/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | 3 | const Chart = require('./chart') 4 | const data = require('./charts.json') 5 | 6 | const sendfile = (filename, root) => (_, res) => 7 | res.sendFile(filename, { root }) 8 | 9 | const jquery = sendfile('/jquery-1.6.2.min.js', __dirname) 10 | const peity = sendfile('/jquery.peity.js', __dirname + '/..') 11 | const style = sendfile('/style.css', __dirname) 12 | 13 | const index = function (_, res) { 14 | const charts = Object.keys(data).map(id => new Chart(id, data[id])) 15 | res.render('index', { charts }) 16 | } 17 | 18 | const show = function (req, res) { 19 | const { id } = req.params 20 | const props = data[id] 21 | 22 | if (!props) return res.status(404).end() 23 | 24 | const chart = new Chart(id, props) 25 | res.render('show', { chart }) 26 | } 27 | 28 | const app = express() 29 | .set('view engine', 'ejs') 30 | .set('views', __dirname + '/views') 31 | .get('/jquery.min.js', jquery) 32 | .get('/jquery.peity.js', peity) 33 | .get('/style.css', style) 34 | .get('/', index) 35 | .get('/:id', show) 36 | 37 | module.exports = app 38 | -------------------------------------------------------------------------------- /test/chart.js: -------------------------------------------------------------------------------- 1 | class Chart { 2 | constructor(id, props) { 3 | this.id = id 4 | this.opts = props.opts 5 | this.text = props.text 6 | this.type = props.type 7 | } 8 | 9 | optionsString() { 10 | switch (typeof this.opts) { 11 | case 'object': 12 | return JSON.stringify(this.opts) 13 | case 'string': 14 | return this.opts 15 | default: 16 | return '{}' 17 | } 18 | } 19 | } 20 | 21 | module.exports = Chart 22 | -------------------------------------------------------------------------------- /test/charts.json: -------------------------------------------------------------------------------- 1 | { 2 | "bar1": { 3 | "type": "bar", 4 | "text": "5,0,9,6,5,9,7,3,5,2", 5 | "width": 32, 6 | "height": 16 7 | }, 8 | "bar2": { 9 | "type": "bar", 10 | "text": "0,3,2,-1,-3,-2,2,3,5,2", 11 | "opts": { 12 | "width": 64, 13 | "height": 32 14 | }, 15 | "width": 64, 16 | "height": 32 17 | }, 18 | "bar3": { 19 | "type": "bar", 20 | "text": "-3,0,-6,-4,-5,-4,-7,-3,-5,-2", 21 | "width": 32, 22 | "height": 16 23 | }, 24 | "bar4": { 25 | "type": "bar", 26 | "text": "5,3,9,6,5,9,7,3,5,2", 27 | "opts": "{ fill: ['red', 'green', 'blue'] }", 28 | "width": 32, 29 | "height": 16 30 | }, 31 | "bar5": { 32 | "type": "bar", 33 | "text": "5,3,2,-1,-3,-2,2,3,5,2", 34 | "opts": "{ fill: function(value) { return value > 0 ? 'green' : 'red' } }", 35 | "width": 32, 36 | "height": 16 37 | }, 38 | "bar6": { 39 | "type": "bar", 40 | "text": "0,-3,-6,-4,-5,-4,-7,-3,-5,-2", 41 | "opts": "{ fill: function(_, i, all) { var g = parseInt((i / all.length) * 255); return 'rgb(255, ' + g + ', 0)' } }", 42 | "width": 32, 43 | "height": 16 44 | }, 45 | "bar7": { 46 | "type": "bar", 47 | "text": "0,0,0,0,0", 48 | "width": 32, 49 | "height": 16 50 | }, 51 | "bar8": { 52 | "type": "bar", 53 | "text": "1,1,1,1,1", 54 | "width": 32, 55 | "height": 16 56 | }, 57 | "bar9": { 58 | "type": "bar", 59 | "text": "1,1,1,1,1", 60 | "opts": { 61 | "min": 1 62 | }, 63 | "width": 32, 64 | "height": 16 65 | }, 66 | "bar10": { 67 | "type": "bar", 68 | "text": "-10,-15,-13,-14,-11", 69 | "width": 32, 70 | "height": 16 71 | }, 72 | "bar11": { 73 | "type": "bar", 74 | "text": "-10,-15,-13,-14,-11", 75 | "opts": { 76 | "max": 0 77 | }, 78 | "width": 32, 79 | "height": 16 80 | }, 81 | "bar12": { 82 | "type": "bar", 83 | "text": "1000,1005,1003,1004,1001", 84 | "opts": { 85 | "min": null 86 | }, 87 | "width": 32, 88 | "height": 16 89 | }, 90 | "bar13": { 91 | "type": "bar", 92 | "text": "5,3,9,6,5,9,7,3,5,2", 93 | "opts": { 94 | "max": "25" 95 | }, 96 | "width": 32, 97 | "height": 16 98 | }, 99 | "bar14": { 100 | "type": "bar", 101 | "text": "5,0,9,6,5,9,7,3,5,2", 102 | "opts": "{ after: function() { this.$svg.append(this.svgElement('line', { stroke: 'black', x1: 0, x2: this.x(9), y1: this.y(9), y2: this.y(0) })) } }", 103 | "width": 32, 104 | "height": 16 105 | }, 106 | "donut1": { 107 | "type": "donut", 108 | "text": "1/5", 109 | "width": 16, 110 | "height": 16 111 | }, 112 | "donut2": { 113 | "type": "donut", 114 | "text": "0.52/1.561", 115 | "opts": { 116 | "radius": 16 117 | }, 118 | "width": 32, 119 | "height": 32 120 | }, 121 | "donut3": { 122 | "type": "donut", 123 | "text": "1,4", 124 | "opts": { 125 | "width": 32 126 | }, 127 | "width": 32, 128 | "height": 16 129 | }, 130 | "donut4": { 131 | "type": "donut", 132 | "text": "4,7,6,5", 133 | "opts": { 134 | "fill": ["cyan", "magenta", "yellow", "black"], 135 | "height": 32 136 | }, 137 | "width": 16, 138 | "height": 32 139 | }, 140 | "donut5": { 141 | "type": "donut", 142 | "text": "3/3", 143 | "width": 16, 144 | "height": 16 145 | }, 146 | "donut6": { 147 | "type": "donut", 148 | "text": "0/3", 149 | "width": 16, 150 | "height": 16 151 | }, 152 | "donut7": { 153 | "type": "donut", 154 | "text": "3,0", 155 | "width": 16, 156 | "height": 16 157 | }, 158 | "donut8": { 159 | "type": "donut", 160 | "text": "4/3", 161 | "width": 16, 162 | "height": 16 163 | }, 164 | "donut9": { 165 | "type": "donut", 166 | "text": "1/5", 167 | "opts": { 168 | "innerRadius": 6 169 | }, 170 | "width": 16, 171 | "height": 16 172 | }, 173 | "donut10": { 174 | "type": "donut", 175 | "text": "1,-2,3", 176 | "width": 16, 177 | "height": 16 178 | }, 179 | "donut11": { 180 | "type": "donut", 181 | "text": "-2/3", 182 | "width": 16, 183 | "height": 16 184 | }, 185 | "donut12": { 186 | "type": "donut", 187 | "text": "0,0,0,0,0", 188 | "width": 16, 189 | "height": 16 190 | }, 191 | "donut13": { 192 | "type": "donut", 193 | "text": "2,4,5", 194 | "opts": "{ after: function() { var xy = this.scale(4, 4); this.$svg.append(this.svgElement('rect', { fill: 'none', height: 3, stroke: 'black', width: 3, x: xy[0], y: xy[1] })) } }", 195 | "width": 16, 196 | "height": 16 197 | }, 198 | "line1": { 199 | "type": "line", 200 | "text": "5,3,9,6,5,9,7,3,5,2", 201 | "opts": { 202 | "fill": "yellow", 203 | "stroke": "red", 204 | "strokeWidth": 2 205 | }, 206 | "width": 32, 207 | "height": 16 208 | }, 209 | "line2": { 210 | "type": "line", 211 | "text": "5,3,2,-1,-3,-2,2,3,5,2", 212 | "opts": { 213 | "width": 64, 214 | "height": 32 215 | }, 216 | "width": 64, 217 | "height": 32 218 | }, 219 | "line3": { 220 | "type": "line", 221 | "text": "0,-3,-6,-4,-5,-4,-7,-3,-5,-2", 222 | "width": 32, 223 | "height": 16 224 | }, 225 | "line4": { 226 | "type": "line", 227 | "text": "5,3,9,6,5,9,7,3,5,2", 228 | "opts": { 229 | "max": 25 230 | }, 231 | "width": 32, 232 | "height": 16 233 | }, 234 | "line5": { 235 | "type": "line", 236 | "text": "0,0,0,0,0", 237 | "width": 32, 238 | "height": 16 239 | }, 240 | "line6": { 241 | "type": "line", 242 | "text": "1,1,1,1,1", 243 | "opts": { 244 | "min": 1 245 | }, 246 | "width": 32, 247 | "height": 16 248 | }, 249 | "line7": { 250 | "type": "line", 251 | "text": "-10,-15,-13,-14,-11", 252 | "width": 32, 253 | "height": 16 254 | }, 255 | "line8": { 256 | "type": "line", 257 | "text": "-10,-15,-13,-14,-11", 258 | "opts": { 259 | "max": 0 260 | }, 261 | "width": 32, 262 | "height": 16 263 | }, 264 | "line9": { 265 | "type": "line", 266 | "text": "1000,1005,1003,1004,1001", 267 | "opts": { 268 | "min": null 269 | }, 270 | "width": 32, 271 | "height": 16 272 | }, 273 | "line10": { 274 | "type": "line", 275 | "text": "5,3,9,6,5,9,7,3,5,2", 276 | "opts": { 277 | "max": "25" 278 | }, 279 | "width": 32, 280 | "height": 16 281 | }, 282 | "line11": { 283 | "type": "line", 284 | "text": "5,3,9,6,5,9,7,3,5,2", 285 | "opts": { 286 | "fill": null 287 | }, 288 | "width": 32, 289 | "height": 16 290 | }, 291 | "line12": { 292 | "type": "line", 293 | "text": "5,0,9,6,5,9,7,3,5,2", 294 | "opts": "{ after: function() { this.$svg.append(this.svgElement('line', { stroke: 'black', x1: 0, x2: this.x(9), y1: this.y(9), y2: this.y(0) })) } }", 295 | "width": 32, 296 | "height": 16 297 | }, 298 | "pie1": { 299 | "type": "pie", 300 | "text": "1/5", 301 | "width": 16, 302 | "height": 16 303 | }, 304 | "pie2": { 305 | "type": "pie", 306 | "text": "0.52/1.561", 307 | "opts": { 308 | "radius": 16 309 | }, 310 | "width": 32, 311 | "height": 32 312 | }, 313 | "pie3": { 314 | "type": "pie", 315 | "text": "1,4", 316 | "opts": { 317 | "width": 32 318 | }, 319 | "width": 32, 320 | "height": 16 321 | }, 322 | "pie4": { 323 | "type": "pie", 324 | "text": "4,7,6,5", 325 | "opts": { 326 | "fill": ["cyan", "magenta", "yellow", "black"], 327 | "height": 32 328 | }, 329 | "width": 16, 330 | "height": 32 331 | }, 332 | "pie5": { 333 | "type": "pie", 334 | "text": "3/3", 335 | "width": 16, 336 | "height": 16 337 | }, 338 | "pie6": { 339 | "type": "pie", 340 | "text": "0/3", 341 | "width": 16, 342 | "height": 16 343 | }, 344 | "pie7": { 345 | "type": "pie", 346 | "text": "3,0", 347 | "width": 16, 348 | "height": 16 349 | }, 350 | "pie8": { 351 | "type": "pie", 352 | "text": "4/3", 353 | "width": 16, 354 | "height": 16 355 | }, 356 | "pie9": { 357 | "type": "pie", 358 | "text": "1,-2,3", 359 | "width": 16, 360 | "height": 16 361 | }, 362 | "pie10": { 363 | "type": "pie", 364 | "text": "-2/3", 365 | "width": 16, 366 | "height": 16 367 | }, 368 | "pie11": { 369 | "type": "pie", 370 | "text": "0,0,0,0,0", 371 | "width": 16, 372 | "height": 16 373 | }, 374 | "pie12": { 375 | "type": "pie", 376 | "text": "2,4,5", 377 | "opts": "{ after: function() { var xy = this.scale(4, 2); this.$svg.append(this.svgElement('rect', { fill: 'none', height: 3, stroke: 'black', width: 3, x: xy[0], y: xy[1] })) } }", 378 | "width": 16, 379 | "height": 16 380 | } 381 | } 382 | -------------------------------------------------------------------------------- /test/jquery-1.6.2.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v1.6.2 3 | * http://jquery.com/ 4 | * 5 | * Copyright 2011, John Resig 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | * http://jquery.org/license 8 | * 9 | * Includes Sizzle.js 10 | * http://sizzlejs.com/ 11 | * Copyright 2011, The Dojo Foundation 12 | * Released under the MIT, BSD, and GPL Licenses. 13 | * 14 | * Date: Thu Jun 30 14:16:56 2011 -0400 15 | */ 16 | (function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z])/ig,x=function(a,b){return b.toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!A){A=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||D.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]||i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=w:v&&c!=="className"&&(f.nodeName(a,"form")||u.test(c))&&(i=v)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}},value:{get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return f.prop(a,c)?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.attrHooks.title=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i. 17 | shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function(c){var d=c.target,e,g;if(!!y.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=I(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};bf.optgroup=bf.option,bf.tbody=bf.tfoot=bf.colgroup=bf.caption=bf.thead,bf.th=bf.td,f.support.htmlSerialize||(bf._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!bf[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j 18 | )}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!ba.test(k))k=b.createTextNode(k);else{k=k.replace(Z,"<$1>");var l=($.exec(k)||["",""])[1].toLowerCase(),m=bf[l]||bf._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=_.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bo.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bn.test(g)?g.replace(bn,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bB=/%20/g,bC=/\[\]$/,bD=/\r?\n/g,bE=/#.*$/,bF=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bG=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bH=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bI=/^(?:GET|HEAD)$/,bJ=/^\/\//,bK=/\?/,bL=/)<[^<]*)*<\/script>/gi,bM=/^(?:select|textarea)/i,bN=/\s+/,bO=/([?&])_=[^&]*/,bP=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bQ=f.fn.load,bR={},bS={},bT,bU;try{bT=e.href}catch(bV){bT=c.createElement("a"),bT.href="",bT=bT.href}bU=bP.exec(bT.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bQ)return bQ.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bL,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bM.test(this.nodeName)||bG.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bD,"\r\n")}}):{name:b.name,value:c.replace(bD,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bT,isLocal:bH.test(bU[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bW(bR),ajaxTransport:bW(bS),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?bZ(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b$(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bF.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bE,"").replace(bJ,bU[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bN),d.crossDomain==null&&(r=bP.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bU[1]&&r[2]==bU[2]&&(r[3]||(r[1]==="http:"?80:443))==(bU[3]||(bU[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bX(bR,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bI.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bK.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bO,"$1_="+x);d.url=y+(y===d.url?(bK.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bX(bS,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bB,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn,co=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cr("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cu.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cu.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cv(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cv(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); -------------------------------------------------------------------------------- /test/jquery.peity.test.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const { JSDOM } = require('jsdom') 3 | 4 | const app = require('./app') 5 | const server = http.createServer(app) 6 | const charts = require('./charts.json') 7 | 8 | let serverUrl 9 | const chartUrl = id => [serverUrl, id].join('/') 10 | 11 | beforeAll(async () => { 12 | await server.listen(0) 13 | const { port } = server.address() 14 | serverUrl = `http://localhost:${port}` 15 | }) 16 | 17 | afterAll(async () => server.close()) 18 | 19 | Object.keys(charts).forEach(id => { 20 | test(`renders test chart ${id} correctly`, async () => { 21 | await page.goto(chartUrl(id)) 22 | 23 | const html = await page.evaluate( 24 | id => document.querySelector(`.chart-${id}`).innerHTML, 25 | id 26 | ) 27 | 28 | // Pass through JSDOM for prettier snapshots. 29 | const dom = new JSDOM(html.trim()) 30 | expect(dom.window.document.body).toMatchSnapshot() 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /test/server.js: -------------------------------------------------------------------------------- 1 | const app = require('./app') 2 | const port = process.env.PORT || 8080 3 | 4 | app.listen(port, function () { 5 | console.log('Listening on port %d', port) 6 | }) 7 | -------------------------------------------------------------------------------- /test/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: orange; 3 | margin: 0; 4 | } 5 | 6 | svg { 7 | background: white; 8 | } 9 | 10 | .charts { 11 | align-items: center; 12 | display: flex; 13 | flex-wrap: wrap; 14 | } 15 | 16 | .charts .chart { 17 | padding: 5px; 18 | } 19 | -------------------------------------------------------------------------------- /test/views/chart.ejs: -------------------------------------------------------------------------------- 1 |
2 | <%= chart.text %> 3 |
4 | 5 | 8 | -------------------------------------------------------------------------------- /test/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Charts 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | <% charts.forEach(function(chart) { %> 14 | <% include chart %> 15 | <% }) %> 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /test/views/show.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= chart.id %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | <% include chart %> 13 | 14 | 15 | --------------------------------------------------------------------------------