├── www
├── img
│ └── logo.png
├── fonts
│ ├── ionicons.eot
│ ├── ionicons.ttf
│ └── ionicons.woff
├── js
│ ├── app.js
│ ├── dashboard1.js
│ ├── dashboard2.js
│ └── dashboard3.js
├── index.html
├── summary.js
├── css
│ └── app.css
├── lib
│ ├── xcharts.min.css
│ ├── xcharts.css
│ ├── fastclick.js
│ ├── xcharts.min.js
│ ├── xcharts.js
│ └── jquery.js
└── data.js
└── README.md
/www/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ccoenraets/olympic-dashboard-d3/HEAD/www/img/logo.png
--------------------------------------------------------------------------------
/www/fonts/ionicons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ccoenraets/olympic-dashboard-d3/HEAD/www/fonts/ionicons.eot
--------------------------------------------------------------------------------
/www/fonts/ionicons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ccoenraets/olympic-dashboard-d3/HEAD/www/fonts/ionicons.ttf
--------------------------------------------------------------------------------
/www/fonts/ionicons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ccoenraets/olympic-dashboard-d3/HEAD/www/fonts/ionicons.woff
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Interactive Mobile Dashboard using D3 and Cordova ###
2 |
3 | To run in your browser:
4 |
5 | 1. Open www/index.html in your browser
6 |
7 |
8 | To run as a Cordova app:
9 |
10 | 1. Open Terminal and type:
11 |
12 | ```
13 | cordova create olympic-dashboard-d3
14 | cd olympic-dashboard-d3
15 | cordova platforms add ios
16 | cordova plugin add org.apache.cordova.device
17 | cordova plugin add org.apache.cordova.console
18 | cordova plugin add org.apache.cordova.statusbar
19 | ```
20 |
21 | 2. Delete the www folder that was created and replace it with the www folder from this repo
22 |
23 | 3. In terminal type:
24 |
25 | ```
26 | cordova build ios
27 | ```
28 |
29 | 4. Open the .xcodeproj file in the platforms/ios folder and run the app in the emulator or on your iOS device. To run the app on your iOS device, you need an Apple developer certificate and an app provisioning profile.
30 |
31 |
--------------------------------------------------------------------------------
/www/js/app.js:
--------------------------------------------------------------------------------
1 | (function () {
2 |
3 | "use strict";
4 |
5 | document.addEventListener("deviceready", function () {
6 | FastClick.attach(document.body);
7 | StatusBar.overlaysWebView(false);
8 | }, false);
9 |
10 |
11 | // Show/hide menu toggle
12 | $('#btn-menu').click(function () {
13 | if ($('#container').hasClass('offset')) {
14 | $('#container').removeClass('offset');
15 | } else {
16 | $('#container').addClass('offset');
17 | }
18 | return false;
19 | });
20 |
21 | // Basic view routing
22 | $(window).on('hashchange', route);
23 |
24 | function route() {
25 | var hash = window.location.hash;
26 | if (hash === "#dashboard/1") {
27 | dashboard1.render();
28 | } else if (hash === "#dashboard/2") {
29 | dashboard2.render();
30 | } else if (hash === "#dashboard/3") {
31 | dashboard3.render();
32 | }
33 | }
34 |
35 | dashboard1.render();
36 |
37 | }());
--------------------------------------------------------------------------------
/www/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Winter Olympics
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Welcome, Christophe
16 |
Menu
17 |
40 |
41 |
42 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/www/summary.js:
--------------------------------------------------------------------------------
1 | var summary = [
2 | {
3 | "className": ".Canada",
4 | "country": "Canada",
5 | "data": [
6 | {
7 | "x": 1994,
8 | "y": 13
9 | },
10 | {
11 | "x": 1998,
12 | "y": 15
13 | },
14 | {
15 | "x": 2002,
16 | "y": 17
17 | },
18 | {
19 | "x": 2006,
20 | "y": 24
21 | },
22 | {
23 | "x": 2010,
24 | "y": 26
25 | }
26 | ]
27 | },
28 | {
29 | "className": ".Germany",
30 | "country": "Germany",
31 | "data": [
32 | {
33 | "x": 1994,
34 | "y": 22
35 | },
36 | {
37 | "x": 1998,
38 | "y": 27
39 | },
40 | {
41 | "x": 2002,
42 | "y": 34
43 | },
44 | {
45 | "x": 2006,
46 | "y": 28
47 | },
48 | {
49 | "x": 2010,
50 | "y": 30
51 | }
52 | ]
53 | },
54 | {
55 | "className": ".Norway",
56 | "country": "Norway",
57 | "data": [
58 | {
59 | "x": 1994,
60 | "y": 26
61 | },
62 | {
63 | "x": 1998,
64 | "y": 25
65 | },
66 | {
67 | "x": 2002,
68 | "y": 25
69 | },
70 | {
71 | "x": 2006,
72 | "y": 19
73 | },
74 | {
75 | "x": 2010,
76 | "y": 23
77 | }
78 | ]
79 | },
80 | {
81 | "className": ".Russia",
82 | "country": "Russia",
83 | "data": [
84 | {
85 | "x": 1994,
86 | "y": 23
87 | },
88 | {
89 | "x": 1998,
90 | "y": 14
91 | },
92 | {
93 | "x": 2002,
94 | "y": 13
95 | },
96 | {
97 | "x": 2006,
98 | "y": 20
99 | },
100 | {
101 | "x": 2010,
102 | "y": 15
103 | }
104 | ]
105 | },
106 | {
107 | "className": ".USA",
108 | "country": "USA",
109 | "data": [
110 | {
111 | "x": 1994,
112 | "y": 13
113 | },
114 | {
115 | "x": 1998,
116 | "y": 13
117 | },
118 | {
119 | "x": 2002,
120 | "y": 34
121 | },
122 | {
123 | "x": 2006,
124 | "y": 25
125 | },
126 | {
127 | "x": 2010,
128 | "y": 37
129 | }
130 | ]
131 | }
132 | ];
--------------------------------------------------------------------------------
/www/css/app.css:
--------------------------------------------------------------------------------
1 | #left-nav {
2 | position: absolute;
3 | width: 200px;
4 | top: 0px;
5 | left:0px;
6 | bottom: 0px;
7 | background: #484B4C;
8 | border-right: solid 1px #000;
9 | color: #ddd;
10 | }
11 |
12 | #left-nav>.welcome {
13 | padding: 8px;
14 | }
15 |
16 | #left-nav>.list>li {
17 | border-bottom: solid 1px #444;
18 | padding: 8px;
19 | }
20 |
21 | .list-item:not(:first-of-type) {
22 | border-top: solid 1px #555;
23 | }
24 |
25 | #left-nav>.list>.list-item h3 {
26 | margin: 0px;
27 | font-size: 16px;
28 | color: #e5e5e5;
29 | }
30 |
31 | #left-nav>.list>.list-item p {
32 | margin: 0px;
33 | }
34 |
35 | #left-nav>.list>li:active {
36 | background-color: #393939;
37 | }
38 |
39 | #left-nav>.title {
40 | background: #444;
41 | /*opacity: .3;*/
42 | padding: 4px;
43 | border-top: solid 1px #555;
44 | border-bottom: solid 1px #333;
45 | /*border-bottom: solid 1px #555;*/
46 | }
47 |
48 | #left-nav i {
49 | font-size: 28px;
50 | float:left;
51 | margin-right: 8px;
52 | width: 28px;
53 | }
54 |
55 | #container {
56 | position: absolute;
57 | top: 0px;
58 | right: 0px;
59 | bottom: 0px;
60 | left: 0px;
61 | }
62 |
63 | #container.offset {
64 | -webkit-transform: translate3d(200px, 0, 0);
65 | transform: translate3d(200px, 0, 0);
66 | }
67 |
68 | #container.transition {
69 | -webkit-transition-duration: .25s;
70 | transition-duration: .25s;
71 | }
72 |
73 | #content {
74 | position: absolute;
75 | overflow: auto;
76 | -webkit-overflow-scrolling: touch;
77 | top: 44px;
78 | right: 0px;
79 | bottom: 0px;
80 | left: 0px;
81 | background: #ffffff;
82 | }
83 |
84 | .chart {
85 | font-family: Helvetica, Arial, Verdana, sans-serif;
86 | fill: #666;
87 | font-size: 12px;
88 | display: table;
89 | width: 490px;
90 | height: 320px;
91 | float: left;
92 | margin: 10px;
93 | overflow: hidden;
94 | }
95 |
96 | .chart2 {
97 | height: 650px;
98 | }
99 |
100 | .chart>.title {
101 | display: table-cell;
102 | text-align: center;
103 | vertical-align: middle;
104 | height: 34px;
105 | font-family: 'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana;
106 | font-weight: 200;
107 | font-size: 24px;
108 | }
109 |
110 | .chart>.graph {
111 | display: table-row;
112 | width: 100%;
113 | height: 100%;
114 | }
115 |
116 | .chart>.legend {
117 | display: table-cell;
118 | height: 34px;
119 | width: 100%;
120 | text-align: center;
121 | vertical-align: top;
122 | }
123 |
124 | .chart>.vertical-legend {
125 | display: table-cell;
126 | height: 150px;
127 | width: 200px;
128 | }
129 |
130 | .chart2 {
131 | width: 460px;
132 | height: 680px;
133 | float: left;
134 | padding: 10px;
135 | }
136 |
137 | .color0 {
138 | fill: #3880aa;
139 | }
140 |
141 | .color1 {
142 | fill: #4da944;
143 | }
144 | .color2 {
145 | fill: #f26522;
146 | }
147 | .color3 {
148 | fill: #c6080d;
149 | }
150 | .color4 {
151 | fill: #672d8b;
152 | }
153 |
--------------------------------------------------------------------------------
/www/lib/xcharts.min.css:
--------------------------------------------------------------------------------
1 | .xchart .line{stroke-width:3px;fill:none}.xchart .fill{stroke-width:0}.xchart circle{stroke:#FFF;stroke-width:3px}.xchart .axis .domain{fill:none}.xchart .axis .tick line{stroke:#EEE;stroke-width:1px}.xchart .axis text{font-family:Helvetica,Arial,Verdana,sans-serif;fill:#666;font-size:12px}.xchart .color0 .line{stroke:#3880aa}.xchart .color0 .line .fill{pointer-events:none}.xchart .color0 rect,.xchart .color0 circle{fill:#3880aa}.xchart .color0 .fill{fill:rgba(56,128,170,0.1)}.xchart .color0.comp .line{stroke:#89bbd8}.xchart .color0.comp rect{fill:#89bbd8}.xchart .color0.comp .fill{display:none}.xchart .color0.comp circle,.xchart .color0.comp .pointer{fill:#89bbd8}.xchart .color1 .line{stroke:#4da944}.xchart .color1 .line .fill{pointer-events:none}.xchart .color1 rect,.xchart .color1 circle{fill:#4da944}.xchart .color1 .fill{fill:rgba(77,169,68,0.1)}.xchart .color1.comp .line{stroke:#9dd597}.xchart .color1.comp rect{fill:#9dd597}.xchart .color1.comp .fill{display:none}.xchart .color1.comp circle,.xchart .color1.comp .pointer{fill:#9dd597}.xchart .color2 .line{stroke:#f26522}.xchart .color2 .line .fill{pointer-events:none}.xchart .color2 rect,.xchart .color2 circle{fill:#f26522}.xchart .color2 .fill{fill:rgba(242,101,34,0.1)}.xchart .color2.comp .line{stroke:#f9b99a}.xchart .color2.comp rect{fill:#f9b99a}.xchart .color2.comp .fill{display:none}.xchart .color2.comp circle,.xchart .color2.comp .pointer{fill:#f9b99a}.xchart .color3 .line{stroke:#c6080d}.xchart .color3 .line .fill{pointer-events:none}.xchart .color3 rect,.xchart .color3 circle{fill:#c6080d}.xchart .color3 .fill{fill:rgba(198,8,13,0.1)}.xchart .color3.comp .line{stroke:#f8555a}.xchart .color3.comp rect{fill:#f8555a}.xchart .color3.comp .fill{display:none}.xchart .color3.comp circle,.xchart .color3.comp .pointer{fill:#f8555a}.xchart .color4 .line{stroke:#672d8b}.xchart .color4 .line .fill{pointer-events:none}.xchart .color4 rect,.xchart .color4 circle{fill:#672d8b}.xchart .color4 .fill{fill:rgba(103,45,139,0.1)}.xchart .color4.comp .line{stroke:#a869ce}.xchart .color4.comp rect{fill:#a869ce}.xchart .color4.comp .fill{display:none}.xchart .color4.comp circle,.xchart .color4.comp .pointer{fill:#a869ce}.xchart .color5 .line{stroke:#ce1797}.xchart .color5 .line .fill{pointer-events:none}.xchart .color5 rect,.xchart .color5 circle{fill:#ce1797}.xchart .color5 .fill{fill:rgba(206,23,151,0.1)}.xchart .color5.comp .line{stroke:#f075cb}.xchart .color5.comp rect{fill:#f075cb}.xchart .color5.comp .fill{display:none}.xchart .color5.comp circle,.xchart .color5.comp .pointer{fill:#f075cb}.xchart .color6 .line{stroke:#d9ce00}.xchart .color6 .line .fill{pointer-events:none}.xchart .color6 rect,.xchart .color6 circle{fill:#d9ce00}.xchart .color6 .fill{fill:rgba(217,206,0,0.1)}.xchart .color6.comp .line{stroke:#fff75a}.xchart .color6.comp rect{fill:#fff75a}.xchart .color6.comp .fill{display:none}.xchart .color6.comp circle,.xchart .color6.comp .pointer{fill:#fff75a}.xchart .color7 .line{stroke:#754c24}.xchart .color7 .line .fill{pointer-events:none}.xchart .color7 rect,.xchart .color7 circle{fill:#754c24}.xchart .color7 .fill{fill:rgba(117,76,36,0.1)}.xchart .color7.comp .line{stroke:#c98c50}.xchart .color7.comp rect{fill:#c98c50}.xchart .color7.comp .fill{display:none}.xchart .color7.comp circle,.xchart .color7.comp .pointer{fill:#c98c50}.xchart .color8 .line{stroke:#2eb9b4}.xchart .color8 .line .fill{pointer-events:none}.xchart .color8 rect,.xchart .color8 circle{fill:#2eb9b4}.xchart .color8 .fill{fill:rgba(46,185,180,0.1)}.xchart .color8.comp .line{stroke:#86e1de}.xchart .color8.comp rect{fill:#86e1de}.xchart .color8.comp .fill{display:none}.xchart .color8.comp circle,.xchart .color8.comp .pointer{fill:#86e1de}.xchart .color9 .line{stroke:#0e2e42}.xchart .color9 .line .fill{pointer-events:none}.xchart .color9 rect,.xchart .color9 circle{fill:#0e2e42}.xchart .color9 .fill{fill:rgba(14,46,66,0.1)}.xchart .color9.comp .line{stroke:#2477ab}.xchart .color9.comp rect{fill:#2477ab}.xchart .color9.comp .fill{display:none}.xchart .color9.comp circle,.xchart .color9.comp .pointer{fill:#2477ab}
--------------------------------------------------------------------------------
/www/js/dashboard1.js:
--------------------------------------------------------------------------------
1 | var dashboard1 = (function () {
2 |
3 | "use strict";
4 |
5 | // Currently selected dashboard values
6 | var chart1,
7 | chart2,
8 | selectedYear = 2010;
9 |
10 | /* Functions to create the individual charts involved in the dashboard */
11 |
12 | function createSummaryChart(selector, dataset) {
13 |
14 | var data = {
15 | "xScale": "ordinal",
16 | "yScale": "linear",
17 | "main": dataset
18 | },
19 |
20 | options = {
21 | "axisPaddingLeft": 0,
22 | "paddingLeft": 20,
23 | "paddingRight": 0,
24 | "axisPaddingRight": 0,
25 | "axisPaddingTop": 5,
26 | "yMin": 9,
27 | "yMax": 40,
28 | "interpolation": "linear",
29 | "click": yearSelectionHandler
30 | },
31 |
32 | legend = d3.select(selector).append("svg")
33 | .attr("class", "legend")
34 | .selectAll("g")
35 | .data(dataset)
36 | .enter()
37 | .append("g")
38 | .attr("transform", function (d, i) {
39 | return "translate(" + (64 + (i * 84)) + ", 0)";
40 | });
41 |
42 | legend.append("rect")
43 | .attr("width", 18)
44 | .attr("height", 18)
45 | .attr("class", function (d, i) {
46 | return 'color' + i;
47 | });
48 |
49 | legend.append("text")
50 | .attr("x", 24)
51 | .attr("y", 9)
52 | .attr("dy", ".35em")
53 | .text(function (d, i) {
54 | return dataset[i].country;
55 | });
56 |
57 | return new xChart('line-dotted', data, selector + " .graph", options);
58 | }
59 |
60 | function createCountryBreakdownChart(selector, dataset) {
61 |
62 | var data = {
63 | "xScale": "ordinal",
64 | "yScale": "linear",
65 | "type": "bar",
66 | "main": dataset
67 | },
68 |
69 | options = {
70 | "axisPaddingLeft": 0,
71 | "axisPaddingTop": 5,
72 | "paddingLeft": 20,
73 | "yMin": 8,
74 | "yMax": 40
75 | };
76 |
77 | return new xChart('bar', data, selector + " .graph", options);
78 |
79 | }
80 |
81 | /* Data selection handlers */
82 |
83 | function yearSelectionHandler(d, i) {
84 | selectedYear = d.x;
85 | var data = {
86 | "xScale": "ordinal",
87 | "yScale": "linear",
88 | "type": "bar",
89 | "main": getCountryBreakdownForYear(selectedYear)
90 | };
91 | $('#chart2>.title').html('Total Medals by Country in ' + selectedYear);
92 | chart2.setData(data);
93 | }
94 |
95 | /* Functions to transform/format the data as required by specific charts */
96 |
97 | function getCountryBreakdownForYear(year) {
98 | var result = [];
99 | for (var i = 0; i < results[year].length; i++) {
100 | result.push({x: results[year][i].Country, y: results[year][i].Total});
101 | }
102 | return [
103 | {
104 | "className": ".medals",
105 | "data": result
106 | }
107 | ]
108 | }
109 |
110 | /* Render the dashboard */
111 |
112 | function render() {
113 |
114 | var html =
115 | '' +
116 | '
Top 5 Medal Countries
' +
117 | '
' +
118 | '
' +
119 |
120 | '' +
121 | '
Total Medals by Country in 2010
' +
122 | '
' +
123 | '
';
124 |
125 | $("#content").html(html);
126 |
127 | chart1 = createSummaryChart('#chart1', summary);
128 | chart2 = createCountryBreakdownChart('#chart2', getCountryBreakdownForYear(selectedYear));
129 | }
130 |
131 | return {
132 | render: render
133 | }
134 |
135 | }());
--------------------------------------------------------------------------------
/www/data.js:
--------------------------------------------------------------------------------
1 | var results = {};
2 |
3 | results["1994"] =
4 |
5 | [
6 | {
7 | "Country": "Canada",
8 | "Gold": 3,
9 | "Silver": 6,
10 | "Bronze": 4,
11 | "Total": 13
12 | },
13 | {
14 | "Country": "Germany",
15 | "Gold": 8,
16 | "Silver": 7,
17 | "Bronze": 7,
18 | "Total": 22
19 | },
20 | {
21 | "Country": "Norway",
22 | "Gold": 10,
23 | "Silver": 11,
24 | "Bronze": 5,
25 | "Total": 26
26 | },
27 | {
28 | "Country": "Russia",
29 | "Gold": 11,
30 | "Silver": 8,
31 | "Bronze": 4,
32 | "Total": 23
33 | },
34 | {
35 | "Country": "USA",
36 | "Gold": 6,
37 | "Silver": 5,
38 | "Bronze": 2,
39 | "Total": 13
40 | }
41 | ];
42 |
43 | results["1998"] =
44 |
45 | [
46 | {
47 | "Country": "Canada",
48 | "Gold": 6,
49 | "Silver": 5,
50 | "Bronze": 4,
51 | "Total": 15
52 | },
53 | {
54 | "Country": "Germany",
55 | "Gold": 11,
56 | "Silver": 8,
57 | "Bronze": 8,
58 | "Total": 27
59 | },
60 | {
61 | "Country": "Norway",
62 | "Gold": 10,
63 | "Silver": 10,
64 | "Bronze": 5,
65 | "Total": 25
66 | },
67 | {
68 | "Country": "Russia",
69 | "Gold": 7,
70 | "Silver": 5,
71 | "Bronze": 2,
72 | "Total": 14
73 | },
74 | {
75 | "Country": "USA",
76 | "Gold": 6,
77 | "Silver": 3,
78 | "Bronze": 4,
79 | "Total": 13
80 | }
81 | ];
82 |
83 |
84 | results["2002"] =
85 |
86 | [
87 | {
88 | "Country": "Canada",
89 | "Gold": 7,
90 | "Silver": 3,
91 | "Bronze": 7,
92 | "Total": 17
93 | },
94 | {
95 | "Country": "Germany",
96 | "Gold": 10,
97 | "Silver": 16,
98 | "Bronze": 8,
99 | "Total": 34
100 | },
101 | {
102 | "Country": "Norway",
103 | "Gold": 13,
104 | "Silver": 5,
105 | "Bronze": 7,
106 | "Total": 25
107 | },
108 | {
109 | "Country": "Russia",
110 | "Gold": 5,
111 | "Silver": 4,
112 | "Bronze": 4,
113 | "Total": 13
114 | },
115 | {
116 | "Country": "USA",
117 | "Gold": 10,
118 | "Silver": 13,
119 | "Bronze": 11,
120 | "Total": 34
121 | },
122 | ];
123 |
124 | results["2006"] =
125 |
126 | [
127 | {
128 | "Country": "Canada",
129 | "Gold": 7,
130 | "Silver": 10,
131 | "Bronze": 7,
132 | "Total": 24
133 | },
134 | {
135 | "Country": "Germany",
136 | "Gold": 11,
137 | "Silver": 11,
138 | "Bronze": 6,
139 | "Total": 28
140 | },
141 | {
142 | "Country": "Norway",
143 | "Gold": 2,
144 | "Silver": 8,
145 | "Bronze": 9,
146 | "Total": 19
147 | },
148 | {
149 | "Country": "Russia",
150 | "Gold": 8,
151 | "Silver": 6,
152 | "Bronze": 6,
153 | "Total": 20
154 | },
155 | {
156 | "Country": "USA",
157 | "Gold": 9,
158 | "Silver": 9,
159 | "Bronze": 7,
160 | "Total": 25
161 | }
162 | ];
163 |
164 |
165 | results["2010"] =
166 | [
167 | {
168 | "Country": "Canada",
169 | "Gold": 14,
170 | "Silver": 7,
171 | "Bronze": 5,
172 | "Total": 26
173 | },
174 | {
175 | "Country": "Germany",
176 | "Gold": 10,
177 | "Silver": 13,
178 | "Bronze": 7,
179 | "Total": 30
180 | },
181 | {
182 | "Country": "Norway",
183 | "Gold": 9,
184 | "Silver": 8,
185 | "Bronze": 6,
186 | "Total": 23
187 | },
188 | {
189 | "Country": "Russia",
190 | "Gold": 3,
191 | "Silver": 5,
192 | "Bronze": 7,
193 | "Total": 15
194 | },
195 | {
196 | "Country": "USA",
197 | "Gold": 9,
198 | "Silver": 15,
199 | "Bronze": 13,
200 | "Total": 37
201 | }
202 | ];
--------------------------------------------------------------------------------
/www/js/dashboard2.js:
--------------------------------------------------------------------------------
1 | var dashboard2 = (function () {
2 |
3 | "use strict";
4 |
5 | // Currently selected dashboard values
6 | var chart1,
7 | chart2,
8 | selectedYear = 2010;
9 |
10 | /* Functions to create the individual charts involved in the dashboard */
11 |
12 | function createSummaryChart(selector, dataset) {
13 |
14 | var data = {
15 | "xScale": "ordinal",
16 | "yScale": "linear",
17 | "main": dataset
18 | },
19 |
20 | options = {
21 | "axisPaddingLeft": 0,
22 | "paddingLeft": 20,
23 | "paddingRight": 0,
24 | "axisPaddingRight": 0,
25 | "axisPaddingTop": 5,
26 | "yMin": 9,
27 | "yMax": 40,
28 | "interpolation": "linear",
29 | "click": yearSelectionHandler
30 | },
31 |
32 | legend = d3.select(selector).append("svg")
33 | .attr("class", "legend")
34 | .selectAll("g")
35 | .data(dataset)
36 | .enter()
37 | .append("g")
38 | .attr("transform", function (d, i) {
39 | return "translate(" + (64 + (i * 84)) + ", 0)";
40 | });
41 |
42 | legend.append("rect")
43 | .attr("width", 18)
44 | .attr("height", 18)
45 | .attr("class", function (d, i) {
46 | return 'color' + i;
47 | });
48 |
49 | legend.append("text")
50 | .attr("x", 24)
51 | .attr("y", 9)
52 | .attr("dy", ".35em")
53 | .text(function (d, i) {
54 | return dataset[i].country;
55 | });
56 |
57 | return new xChart('line-dotted', data, selector + " .graph", options);
58 | }
59 |
60 | function createCountryBreakdownChart(selector, dataset) {
61 |
62 | var width = 490,
63 | height = 450,
64 | radius = Math.min(width, height) / 2,
65 |
66 | color = d3.scale.category10(),
67 |
68 | pie = d3.layout.pie()
69 | .value(function (d) {
70 | return d.Total;
71 | })
72 | .sort(null),
73 |
74 | arc = d3.svg.arc()
75 | .innerRadius(radius - 120)
76 | .outerRadius(radius - 20),
77 |
78 | svg = d3.select(selector + " .graph").append("svg")
79 | .attr("width", width)
80 | .attr("height", height)
81 | .append("g")
82 | .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"),
83 |
84 | path = svg.datum(dataset).selectAll("path")
85 | .data(pie)
86 | .enter().append("path")
87 | .attr("fill", function (d, i) {
88 | return color(i);
89 | })
90 | .attr("d", arc)
91 | .each(function (d) {
92 | this._selected = d;
93 | }), // store the initial angles
94 |
95 | legend = d3.select(selector).append("svg")
96 | .attr("class", "vertical-legend")
97 | .attr("width", 400)
98 | .attr("height", 100)
99 | .selectAll("g")
100 | .data(color.domain().slice())
101 | .enter().append("g")
102 | .attr("transform", function (d, i) {
103 | return "translate(80, " + i * 30 + ")";
104 | });
105 |
106 | legend.append("rect")
107 | .attr("width", 18)
108 | .attr("height", 18)
109 | .style("fill", color);
110 |
111 | legend.append("text")
112 | .attr("x", 24)
113 | .attr("y", 9)
114 | .attr("dy", ".35em")
115 | .text(function (d) {
116 | return dataset[d].Country + ' (' + dataset[d].Total + ')';
117 | });
118 |
119 | function change(dataset) {
120 | svg.datum(dataset);
121 | path = path.data(pie); // compute the new angles
122 | path.transition().duration(500).attrTween("d", arcTween); // redraw the arcs
123 | legend.select('text').text(function (d) {
124 | return dataset[d].Country + ' (' + dataset[d].Total + ')';
125 | });
126 | }
127 |
128 | function arcTween(a) {
129 | var i = d3.interpolate(this._selected, a);
130 | this._selected = i(0);
131 | return function (t) {
132 | return arc(i(t));
133 | };
134 | }
135 |
136 | return {
137 | change: change
138 | };
139 |
140 | }
141 |
142 | /* Data selection handlers */
143 |
144 | function yearSelectionHandler(d, i) {
145 | selectedYear = d.x;
146 | $('#chart2>.title').html('Total Medals by Country in ' + selectedYear);
147 | chart2.change(results[selectedYear]);
148 | }
149 |
150 | /* Render the dashboard */
151 |
152 | function render() {
153 |
154 | var html =
155 | '' +
156 | '
Top 5 Medal Countries
' +
157 | '
' +
158 | '
' +
159 |
160 | '' +
161 | '
Total Medals by Country in 2010
' +
162 | '
' +
163 | '
';
164 |
165 | $("#content").html(html);
166 |
167 | chart1 = createSummaryChart('#chart1', summary);
168 | chart2 = createCountryBreakdownChart('#chart2', results[selectedYear]);
169 | }
170 |
171 | return {
172 | render: render
173 | }
174 |
175 | }());
--------------------------------------------------------------------------------
/www/lib/xcharts.css:
--------------------------------------------------------------------------------
1 | .xchart .line {
2 | stroke-width: 3px;
3 | fill: none;
4 | }
5 | .xchart .fill {
6 | stroke-width: 0;
7 | }
8 | .xchart circle {
9 | stroke: #fff;
10 | stroke-width: 8px;
11 | }
12 | .xchart .axis .domain {
13 | fill: none;
14 | }
15 | .xchart .axis .tick line {
16 | stroke: #EEE;
17 | stroke-width: 1px;
18 | }
19 | .xchart .axis text {
20 | font-family: Helvetica, Arial, Verdana, sans-serif;
21 | fill: #666;
22 | font-size: 12px;
23 | }
24 | .xchart .color0 .line {
25 | stroke: #3880aa;
26 | }
27 | .xchart .color0 .line .fill {
28 | pointer-events: none;
29 | }
30 | .xchart .color0 rect,
31 | .xchart .color0 circle {
32 | fill: #3880aa;
33 | stroke: #3880aa;
34 | }
35 | .xchart .color0 .fill {
36 | /*fill: rgba(56, 128, 170, 0.1);*/
37 | }
38 | .xchart .color0.comp .line {
39 | stroke: #89bbd8;
40 | }
41 | .xchart .color0.comp rect {
42 | fill: #89bbd8;
43 | }
44 | .xchart .color0.comp .fill {
45 | display: none;
46 | }
47 | .xchart .color0.comp circle,
48 | .xchart .color0.comp .pointer {
49 | fill: #89bbd8;
50 | }
51 | .xchart .color1 .line {
52 | stroke: #4da944;
53 | }
54 | .xchart .color1 .line .fill {
55 | pointer-events: none;
56 | }
57 | .xchart .color1 rect,
58 | .xchart .color1 circle {
59 | fill: #4da944;
60 | stroke: #4da944;
61 | }
62 | .xchart .color1 .fill {
63 | /*fill: rgba(77, 169, 68, 0.1);*/
64 | }
65 | .xchart .color1.comp .line {
66 | stroke: #9dd597;
67 | }
68 | .xchart .color1.comp rect {
69 | fill: #9dd597;
70 | }
71 | .xchart .color1.comp .fill {
72 | display: none;
73 | }
74 | .xchart .color1.comp circle,
75 | .xchart .color1.comp .pointer {
76 | fill: #9dd597;
77 | }
78 | .xchart .color2 .line {
79 | stroke: #f26522;
80 | }
81 | .xchart .color2 .line .fill {
82 | pointer-events: none;
83 | }
84 | .xchart .color2 rect,
85 | .xchart .color2 circle {
86 | fill: #f26522;
87 | stroke: #f26522;
88 | }
89 | .xchart .color2 .fill {
90 | /*fill: rgba(242, 101, 34, 0.1);*/
91 | }
92 | .xchart .color2.comp .line {
93 | stroke: #f9b99a;
94 | }
95 | .xchart .color2.comp rect {
96 | fill: #f9b99a;
97 | }
98 | .xchart .color2.comp .fill {
99 | display: none;
100 | }
101 | .xchart .color2.comp circle,
102 | .xchart .color2.comp .pointer {
103 | fill: #f9b99a;
104 | }
105 | .xchart .color3 .line {
106 | stroke: #c6080d;
107 | }
108 | .xchart .color3 .line .fill {
109 | pointer-events: none;
110 | }
111 | .xchart .color3 rect,
112 | .xchart .color3 circle {
113 | fill: #c6080d;
114 | stroke: #c6080d;
115 | }
116 | .xchart .color3 .fill {
117 | /*fill: rgba(198, 8, 13, 0.1);*/
118 | }
119 | .xchart .color3.comp .line {
120 | stroke: #f8555a;
121 | }
122 | .xchart .color3.comp rect {
123 | fill: #f8555a;
124 | }
125 | .xchart .color3.comp .fill {
126 | display: none;
127 | }
128 | .xchart .color3.comp circle,
129 | .xchart .color3.comp .pointer {
130 | fill: #f8555a;
131 | }
132 | .xchart .color4 .line {
133 | stroke: #672d8b;
134 | }
135 | .xchart .color4 .line .fill {
136 | pointer-events: none;
137 | }
138 | .xchart .color4 rect,
139 | .xchart .color4 circle {
140 | fill: #672d8b;
141 | stroke: #672d8b;
142 | }
143 | .xchart .color4 .fill {
144 | /*fill: rgba(103, 45, 139, 0.1);*/
145 | }
146 | .xchart .color4.comp .line {
147 | stroke: #a869ce;
148 | }
149 | .xchart .color4.comp rect {
150 | fill: #a869ce;
151 | }
152 | .xchart .color4.comp .fill {
153 | display: none;
154 | }
155 | .xchart .color4.comp circle,
156 | .xchart .color4.comp .pointer {
157 | fill: #a869ce;
158 | }
159 | .xchart .color5 .line {
160 | stroke: #ce1797;
161 | }
162 | .xchart .color5 .line .fill {
163 | pointer-events: none;
164 | }
165 | .xchart .color5 rect,
166 | .xchart .color5 circle {
167 | fill: #ce1797;
168 | }
169 | .xchart .color5 .fill {
170 | /*fill: rgba(206, 23, 151, 0.1);*/
171 | }
172 | .xchart .color5.comp .line {
173 | stroke: #f075cb;
174 | }
175 | .xchart .color5.comp rect {
176 | fill: #f075cb;
177 | }
178 | .xchart .color5.comp .fill {
179 | display: none;
180 | }
181 | .xchart .color5.comp circle,
182 | .xchart .color5.comp .pointer {
183 | fill: #f075cb;
184 | }
185 | .xchart .color6 .line {
186 | stroke: #d9ce00;
187 | }
188 | .xchart .color6 .line .fill {
189 | pointer-events: none;
190 | }
191 | .xchart .color6 rect,
192 | .xchart .color6 circle {
193 | fill: #d9ce00;
194 | }
195 | .xchart .color6 .fill {
196 | fill: rgba(217, 206, 0, 0.1);
197 | }
198 | .xchart .color6.comp .line {
199 | stroke: #fff75a;
200 | }
201 | .xchart .color6.comp rect {
202 | fill: #fff75a;
203 | }
204 | .xchart .color6.comp .fill {
205 | display: none;
206 | }
207 | .xchart .color6.comp circle,
208 | .xchart .color6.comp .pointer {
209 | fill: #fff75a;
210 | }
211 | .xchart .color7 .line {
212 | stroke: #754c24;
213 | }
214 | .xchart .color7 .line .fill {
215 | pointer-events: none;
216 | }
217 | .xchart .color7 rect,
218 | .xchart .color7 circle {
219 | fill: #754c24;
220 | }
221 | .xchart .color7 .fill {
222 | fill: rgba(117, 76, 36, 0.1);
223 | }
224 | .xchart .color7.comp .line {
225 | stroke: #c98c50;
226 | }
227 | .xchart .color7.comp rect {
228 | fill: #c98c50;
229 | }
230 | .xchart .color7.comp .fill {
231 | display: none;
232 | }
233 | .xchart .color7.comp circle,
234 | .xchart .color7.comp .pointer {
235 | fill: #c98c50;
236 | }
237 | .xchart .color8 .line {
238 | stroke: #2eb9b4;
239 | }
240 | .xchart .color8 .line .fill {
241 | pointer-events: none;
242 | }
243 | .xchart .color8 rect,
244 | .xchart .color8 circle {
245 | fill: #2eb9b4;
246 | }
247 | .xchart .color8 .fill {
248 | fill: rgba(46, 185, 180, 0.1);
249 | }
250 | .xchart .color8.comp .line {
251 | stroke: #86e1de;
252 | }
253 | .xchart .color8.comp rect {
254 | fill: #86e1de;
255 | }
256 | .xchart .color8.comp .fill {
257 | display: none;
258 | }
259 | .xchart .color8.comp circle,
260 | .xchart .color8.comp .pointer {
261 | fill: #86e1de;
262 | }
263 | .xchart .color9 .line {
264 | stroke: #0e2e42;
265 | }
266 | .xchart .color9 .line .fill {
267 | pointer-events: none;
268 | }
269 | .xchart .color9 rect,
270 | .xchart .color9 circle {
271 | fill: #0e2e42;
272 | }
273 | .xchart .color9 .fill {
274 | fill: rgba(14, 46, 66, 0.1);
275 | }
276 | .xchart .color9.comp .line {
277 | stroke: #2477ab;
278 | }
279 | .xchart .color9.comp rect {
280 | fill: #2477ab;
281 | }
282 | .xchart .color9.comp .fill {
283 | display: none;
284 | }
285 | .xchart .color9.comp circle,
286 | .xchart .color9.comp .pointer {
287 | fill: #2477ab;
288 | }
289 |
--------------------------------------------------------------------------------
/www/js/dashboard3.js:
--------------------------------------------------------------------------------
1 | var dashboard3 = (function () {
2 |
3 | "use strict";
4 |
5 | // Currently selected dashboard values
6 | var chart1,
7 | chart2,
8 | chart3,
9 | chart4,
10 | selectedYear = 2010,
11 | selectedCountry = "USA",
12 | selectedMedalType = "Gold";
13 |
14 | /* Functions to create the individual charts involved in the dashboard */
15 |
16 | function createSummaryChart(selector, dataset) {
17 |
18 | var data = {
19 | "xScale": "ordinal",
20 | "yScale": "linear",
21 | "main": dataset
22 | },
23 |
24 | options = {
25 | "axisPaddingLeft": 0,
26 | "paddingLeft": 20,
27 | "paddingRight": 0,
28 | "axisPaddingRight": 0,
29 | "axisPaddingTop": 5,
30 | "yMin": 9,
31 | "yMax": 40,
32 | "interpolation": "linear",
33 | "click": yearSelectionHandler
34 | },
35 |
36 | legend = d3.select(selector).append("svg")
37 | .attr("class", "legend")
38 | .selectAll("g")
39 | .data(dataset)
40 | .enter()
41 | .append("g")
42 | .attr("transform", function (d, i) {
43 | return "translate(" + (64 + (i * 84)) + ", 0)";
44 | });
45 |
46 | legend.append("rect")
47 | .attr("width", 18)
48 | .attr("height", 18)
49 | .attr("class", function (d, i) {
50 | return 'color' + i;
51 | });
52 |
53 | legend.append("text")
54 | .attr("x", 24)
55 | .attr("y", 9)
56 | .attr("dy", ".35em")
57 | .text(function (d, i) {
58 | return dataset[i].country;
59 | });
60 |
61 | return new xChart('line-dotted', data, selector + " .graph", options);
62 | }
63 |
64 | function createCountryBreakdownChart(selector, dataset) {
65 |
66 | var data = {
67 | "xScale": "ordinal",
68 | "yScale": "linear",
69 | "type": "bar",
70 | "main": dataset
71 | },
72 |
73 | options = {
74 | "axisPaddingLeft": 0,
75 | "axisPaddingTop": 5,
76 | "paddingLeft": 20,
77 | "yMin": 8,
78 | "yMax": 40,
79 | "click": countrySelectionHandler
80 | };
81 |
82 | return new xChart('bar', data, selector + " .graph", options);
83 |
84 | }
85 |
86 |
87 | function createMedalBreakdownChart(selector, dataset) {
88 | var width = 490,
89 | height = 260,
90 | radius = Math.min(width, height) / 2,
91 |
92 | color = d3.scale.category10(),
93 |
94 | pie = d3.layout.pie()
95 | .value(function (d) {
96 | return d.total;
97 | })
98 | .sort(null),
99 |
100 | arc = d3.svg.arc()
101 | .innerRadius(radius - 80)
102 | .outerRadius(radius - 20),
103 |
104 | svg = d3.select(selector + " .graph").append("svg")
105 | .attr("width", width)
106 | .attr("height", height)
107 | .append("g")
108 | .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"),
109 |
110 | path = svg.datum(dataset).selectAll("path")
111 | .data(pie)
112 | .enter().append("path")
113 | .attr("fill", function (d, i) {
114 | return color(i);
115 | })
116 | .attr("d", arc)
117 | .each(function (d) {
118 | this._selected = d;
119 | }) // store the initial angles
120 | .on("click", medalTypeSelectionHandler),
121 |
122 | legend = d3.select(selector).append("svg")
123 | .attr("class", "legend")
124 | .attr("width", radius * 2)
125 | .attr("height", radius * 2)
126 | .selectAll("g")
127 | .data(color.domain().slice().reverse())
128 | .enter().append("g")
129 | .attr("transform", function (d, i) {
130 | return "translate(" + (120 + i * 100) + ", 0)";
131 | });
132 |
133 | legend.append("rect")
134 | .attr("width", 18)
135 | .attr("height", 18)
136 | .style("fill", color);
137 |
138 | legend.append("text")
139 | .attr("x", 24)
140 | .attr("y", 9)
141 | .attr("dy", ".35em")
142 | .text(function (d) {
143 | return dataset[d].type + ' (' + dataset[d].total + ')';
144 | });
145 |
146 | function change(dataset) {
147 | svg.datum(dataset);
148 | path = path.data(pie); // compute the new angles
149 | path.transition().duration(500).attrTween("d", arcTween); // redraw the arcs
150 | legend.select('text').text(function (d) {
151 | return dataset[d].type + ' (' + dataset[d].total + ')';
152 | });
153 | }
154 |
155 | function arcTween(a) {
156 | var i = d3.interpolate(this._selected, a);
157 | this._selected = i(0);
158 | return function (t) {
159 | return arc(i(t));
160 | };
161 | }
162 |
163 | return {
164 | change: change
165 | };
166 |
167 | }
168 |
169 | function createCountryBreakdownForMedalTypeChart(selector, dataset) {
170 |
171 | var data = {
172 | "xScale": "ordinal",
173 | "yScale": "linear",
174 | "type": "bar",
175 | "main": dataset
176 | };
177 |
178 | var options = {
179 | "axisPaddingLeft": 0,
180 | "axisPaddingTop": 5,
181 | "paddingLeft": 20,
182 | "yMin": 0,
183 | "yMax": 20
184 | };
185 |
186 | return new xChart('bar', data, selector + " .graph", options);
187 |
188 | }
189 |
190 | /* Data selection handlers */
191 |
192 | function yearSelectionHandler(d, i) {
193 | selectedYear = d.x;
194 | var data = {
195 | "xScale": "ordinal",
196 | "yScale": "linear",
197 | "type": "bar",
198 | "main": getCountryBreakdownForYear(selectedYear)
199 | };
200 | $('#chart2>.title').html('Total Medals by Country in ' + selectedYear);
201 | chart2.setData(data);
202 | }
203 |
204 | function countrySelectionHandler(d, i) {
205 | selectedCountry = d.x;
206 | $('#chart3>.title').html(selectedCountry + ' Medals in ' + selectedYear);
207 | chart3.change(getMedalsForCountry(selectedCountry));
208 | }
209 |
210 | function medalTypeSelectionHandler(d) {
211 | selectedMedalType = d.data.type;
212 | var data = {
213 | "xScale": "ordinal",
214 | "yScale": "linear",
215 | "type": "bar",
216 | "main": getCountryBreakdownForMedalType(selectedMedalType, selectedYear)
217 | };
218 | $('#chart4>.title').html(selectedMedalType + ' Medals in ' + selectedYear);
219 | chart4.setData(data);
220 | }
221 |
222 | /* Functions to transform/format the data as required by specific charts */
223 |
224 | function getCountryBreakdownForYear(year) {
225 | var result = [];
226 | for (var i = 0; i < results[year].length; i++) {
227 | result.push({x: results[year][i].Country, y: results[year][i].Total});
228 | }
229 | return [
230 | {
231 | "className": ".medals",
232 | "data": result
233 | }
234 | ]
235 | }
236 |
237 | function getCountryBreakdownForMedalType(medalType, year) {
238 | var result = [];
239 | for (var i = 0; i < results[year].length; i++) {
240 | result.push({x: results[year][i].Country, y: results[year][i][medalType]});
241 | }
242 | return [
243 | {
244 | "className": ".medals",
245 | "data": result
246 | }
247 | ]
248 | }
249 |
250 | function getMedalsForCountry(country) {
251 | var countries = results[selectedYear];
252 | for (var i = 0; i < countries.length; i++) {
253 | if (countries[i].Country === country) {
254 | return [
255 | {"type": "Gold", "total": countries[i].Gold },
256 | {"type": "Silver", "total": countries[i].Silver},
257 | {"type": "Bronze", "total": countries[i].Bronze}
258 | ];
259 | }
260 | }
261 | }
262 |
263 | /* Render the dashboard */
264 |
265 | function render() {
266 |
267 | var html =
268 | '' +
269 | '
Top 5 Medal Countries
' +
270 | '
' +
271 | '
' +
272 |
273 | '' +
274 | '
Total Medals by Country in 2010
' +
275 | '
' +
276 | '
' +
277 |
278 | '' +
279 | '
USA Medals in 2010
' +
280 | '
' +
281 | '
' +
282 |
283 | '' +
284 | '
Gold Medals in 2010
' +
285 | '
' +
286 | '
';
287 |
288 | $("#content").html(html);
289 |
290 | chart1 = createSummaryChart('#chart1', summary);
291 | chart2 = createCountryBreakdownChart('#chart2', getCountryBreakdownForYear(selectedYear));
292 | chart3 = createMedalBreakdownChart('#chart3', getMedalsForCountry(selectedCountry));
293 | chart4 = createCountryBreakdownForMedalTypeChart('#chart4', getCountryBreakdownForMedalType(selectedMedalType, selectedYear));
294 | }
295 |
296 | return {
297 | render: render
298 | }
299 |
300 | }());
--------------------------------------------------------------------------------
/www/lib/fastclick.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
3 | *
4 | * @version 0.6.11
5 | * @codingstandard ftlabs-jsv2
6 | * @copyright The Financial Times Limited [All Rights Reserved]
7 | * @license MIT License (see LICENSE.txt)
8 | */
9 |
10 | /*jslint browser:true, node:true*/
11 | /*global define, Event, Node*/
12 |
13 |
14 | /**
15 | * Instantiate fast-clicking listeners on the specificed layer.
16 | *
17 | * @constructor
18 | * @param {Element} layer The layer to listen on
19 | */
20 | function FastClick(layer) {
21 | 'use strict';
22 | var oldOnClick, self = this;
23 |
24 |
25 | /**
26 | * Whether a click is currently being tracked.
27 | *
28 | * @type boolean
29 | */
30 | this.trackingClick = false;
31 |
32 |
33 | /**
34 | * Timestamp for when when click tracking started.
35 | *
36 | * @type number
37 | */
38 | this.trackingClickStart = 0;
39 |
40 |
41 | /**
42 | * The element being tracked for a click.
43 | *
44 | * @type EventTarget
45 | */
46 | this.targetElement = null;
47 |
48 |
49 | /**
50 | * X-coordinate of touch start event.
51 | *
52 | * @type number
53 | */
54 | this.touchStartX = 0;
55 |
56 |
57 | /**
58 | * Y-coordinate of touch start event.
59 | *
60 | * @type number
61 | */
62 | this.touchStartY = 0;
63 |
64 |
65 | /**
66 | * ID of the last touch, retrieved from Touch.identifier.
67 | *
68 | * @type number
69 | */
70 | this.lastTouchIdentifier = 0;
71 |
72 |
73 | /**
74 | * Touchmove boundary, beyond which a click will be cancelled.
75 | *
76 | * @type number
77 | */
78 | this.touchBoundary = 10;
79 |
80 |
81 | /**
82 | * The FastClick layer.
83 | *
84 | * @type Element
85 | */
86 | this.layer = layer;
87 |
88 | if (!layer || !layer.nodeType) {
89 | throw new TypeError('Layer must be a document node');
90 | }
91 |
92 | /** @type function() */
93 | this.onClick = function() { return FastClick.prototype.onClick.apply(self, arguments); };
94 |
95 | /** @type function() */
96 | this.onMouse = function() { return FastClick.prototype.onMouse.apply(self, arguments); };
97 |
98 | /** @type function() */
99 | this.onTouchStart = function() { return FastClick.prototype.onTouchStart.apply(self, arguments); };
100 |
101 | /** @type function() */
102 | this.onTouchMove = function() { return FastClick.prototype.onTouchMove.apply(self, arguments); };
103 |
104 | /** @type function() */
105 | this.onTouchEnd = function() { return FastClick.prototype.onTouchEnd.apply(self, arguments); };
106 |
107 | /** @type function() */
108 | this.onTouchCancel = function() { return FastClick.prototype.onTouchCancel.apply(self, arguments); };
109 |
110 | if (FastClick.notNeeded(layer)) {
111 | return;
112 | }
113 |
114 | // Set up event handlers as required
115 | if (this.deviceIsAndroid) {
116 | layer.addEventListener('mouseover', this.onMouse, true);
117 | layer.addEventListener('mousedown', this.onMouse, true);
118 | layer.addEventListener('mouseup', this.onMouse, true);
119 | }
120 |
121 | layer.addEventListener('click', this.onClick, true);
122 | layer.addEventListener('touchstart', this.onTouchStart, false);
123 | layer.addEventListener('touchmove', this.onTouchMove, false);
124 | layer.addEventListener('touchend', this.onTouchEnd, false);
125 | layer.addEventListener('touchcancel', this.onTouchCancel, false);
126 |
127 | // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
128 | // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
129 | // layer when they are cancelled.
130 | if (!Event.prototype.stopImmediatePropagation) {
131 | layer.removeEventListener = function(type, callback, capture) {
132 | var rmv = Node.prototype.removeEventListener;
133 | if (type === 'click') {
134 | rmv.call(layer, type, callback.hijacked || callback, capture);
135 | } else {
136 | rmv.call(layer, type, callback, capture);
137 | }
138 | };
139 |
140 | layer.addEventListener = function(type, callback, capture) {
141 | var adv = Node.prototype.addEventListener;
142 | if (type === 'click') {
143 | adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
144 | if (!event.propagationStopped) {
145 | callback(event);
146 | }
147 | }), capture);
148 | } else {
149 | adv.call(layer, type, callback, capture);
150 | }
151 | };
152 | }
153 |
154 | // If a handler is already declared in the element's onclick attribute, it will be fired before
155 | // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
156 | // adding it as listener.
157 | if (typeof layer.onclick === 'function') {
158 |
159 | // Android browser on at least 3.2 requires a new reference to the function in layer.onclick
160 | // - the old one won't work if passed to addEventListener directly.
161 | oldOnClick = layer.onclick;
162 | layer.addEventListener('click', function(event) {
163 | oldOnClick(event);
164 | }, false);
165 | layer.onclick = null;
166 | }
167 | }
168 |
169 |
170 | /**
171 | * Android requires exceptions.
172 | *
173 | * @type boolean
174 | */
175 | FastClick.prototype.deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0;
176 |
177 |
178 | /**
179 | * iOS requires exceptions.
180 | *
181 | * @type boolean
182 | */
183 | FastClick.prototype.deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent);
184 |
185 |
186 | /**
187 | * iOS 4 requires an exception for select elements.
188 | *
189 | * @type boolean
190 | */
191 | FastClick.prototype.deviceIsIOS4 = FastClick.prototype.deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
192 |
193 |
194 | /**
195 | * iOS 6.0(+?) requires the target element to be manually derived
196 | *
197 | * @type boolean
198 | */
199 | FastClick.prototype.deviceIsIOSWithBadTarget = FastClick.prototype.deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
200 |
201 |
202 | /**
203 | * Determine whether a given element requires a native click.
204 | *
205 | * @param {EventTarget|Element} target Target DOM element
206 | * @returns {boolean} Returns true if the element needs a native click
207 | */
208 | FastClick.prototype.needsClick = function(target) {
209 | 'use strict';
210 | switch (target.nodeName.toLowerCase()) {
211 |
212 | // Don't send a synthetic click to disabled inputs (issue #62)
213 | case 'button':
214 | case 'select':
215 | case 'textarea':
216 | if (target.disabled) {
217 | return true;
218 | }
219 |
220 | break;
221 | case 'input':
222 |
223 | // File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
224 | if ((this.deviceIsIOS && target.type === 'file') || target.disabled) {
225 | return true;
226 | }
227 |
228 | break;
229 | case 'label':
230 | case 'video':
231 | return true;
232 | }
233 |
234 | return (/\bneedsclick\b/).test(target.className);
235 | };
236 |
237 |
238 | /**
239 | * Determine whether a given element requires a call to focus to simulate click into element.
240 | *
241 | * @param {EventTarget|Element} target Target DOM element
242 | * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
243 | */
244 | FastClick.prototype.needsFocus = function(target) {
245 | 'use strict';
246 | switch (target.nodeName.toLowerCase()) {
247 | case 'textarea':
248 | return true;
249 | case 'select':
250 | return !this.deviceIsAndroid;
251 | case 'input':
252 | switch (target.type) {
253 | case 'button':
254 | case 'checkbox':
255 | case 'file':
256 | case 'image':
257 | case 'radio':
258 | case 'submit':
259 | return false;
260 | }
261 |
262 | // No point in attempting to focus disabled inputs
263 | return !target.disabled && !target.readOnly;
264 | default:
265 | return (/\bneedsfocus\b/).test(target.className);
266 | }
267 | };
268 |
269 |
270 | /**
271 | * Send a click event to the specified element.
272 | *
273 | * @param {EventTarget|Element} targetElement
274 | * @param {Event} event
275 | */
276 | FastClick.prototype.sendClick = function(targetElement, event) {
277 | 'use strict';
278 | var clickEvent, touch;
279 |
280 | // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
281 | if (document.activeElement && document.activeElement !== targetElement) {
282 | document.activeElement.blur();
283 | }
284 |
285 | touch = event.changedTouches[0];
286 |
287 | // Synthesise a click event, with an extra attribute so it can be tracked
288 | clickEvent = document.createEvent('MouseEvents');
289 | clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
290 | clickEvent.forwardedTouchEvent = true;
291 | targetElement.dispatchEvent(clickEvent);
292 | };
293 |
294 | FastClick.prototype.determineEventType = function(targetElement) {
295 | 'use strict';
296 |
297 | //Issue #159: Android Chrome Select Box does not open with a synthetic click event
298 | if (this.deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
299 | return 'mousedown';
300 | }
301 |
302 | return 'click';
303 | };
304 |
305 |
306 | /**
307 | * @param {EventTarget|Element} targetElement
308 | */
309 | FastClick.prototype.focus = function(targetElement) {
310 | 'use strict';
311 | var length;
312 |
313 | // Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
314 | if (this.deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') {
315 | length = targetElement.value.length;
316 | targetElement.setSelectionRange(length, length);
317 | } else {
318 | targetElement.focus();
319 | }
320 | };
321 |
322 |
323 | /**
324 | * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
325 | *
326 | * @param {EventTarget|Element} targetElement
327 | */
328 | FastClick.prototype.updateScrollParent = function(targetElement) {
329 | 'use strict';
330 | var scrollParent, parentElement;
331 |
332 | scrollParent = targetElement.fastClickScrollParent;
333 |
334 | // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
335 | // target element was moved to another parent.
336 | if (!scrollParent || !scrollParent.contains(targetElement)) {
337 | parentElement = targetElement;
338 | do {
339 | if (parentElement.scrollHeight > parentElement.offsetHeight) {
340 | scrollParent = parentElement;
341 | targetElement.fastClickScrollParent = parentElement;
342 | break;
343 | }
344 |
345 | parentElement = parentElement.parentElement;
346 | } while (parentElement);
347 | }
348 |
349 | // Always update the scroll top tracker if possible.
350 | if (scrollParent) {
351 | scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
352 | }
353 | };
354 |
355 |
356 | /**
357 | * @param {EventTarget} targetElement
358 | * @returns {Element|EventTarget}
359 | */
360 | FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {
361 | 'use strict';
362 |
363 | // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
364 | if (eventTarget.nodeType === Node.TEXT_NODE) {
365 | return eventTarget.parentNode;
366 | }
367 |
368 | return eventTarget;
369 | };
370 |
371 |
372 | /**
373 | * On touch start, record the position and scroll offset.
374 | *
375 | * @param {Event} event
376 | * @returns {boolean}
377 | */
378 | FastClick.prototype.onTouchStart = function(event) {
379 | 'use strict';
380 | var targetElement, touch, selection;
381 |
382 | // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
383 | if (event.targetTouches.length > 1) {
384 | return true;
385 | }
386 |
387 | targetElement = this.getTargetElementFromEventTarget(event.target);
388 | touch = event.targetTouches[0];
389 |
390 | if (this.deviceIsIOS) {
391 |
392 | // Only trusted events will deselect text on iOS (issue #49)
393 | selection = window.getSelection();
394 | if (selection.rangeCount && !selection.isCollapsed) {
395 | return true;
396 | }
397 |
398 | if (!this.deviceIsIOS4) {
399 |
400 | // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
401 | // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
402 | // with the same identifier as the touch event that previously triggered the click that triggered the alert.
403 | // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
404 | // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
405 | if (touch.identifier === this.lastTouchIdentifier) {
406 | event.preventDefault();
407 | return false;
408 | }
409 |
410 | this.lastTouchIdentifier = touch.identifier;
411 |
412 | // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
413 | // 1) the user does a fling scroll on the scrollable layer
414 | // 2) the user stops the fling scroll with another tap
415 | // then the event.target of the last 'touchend' event will be the element that was under the user's finger
416 | // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
417 | // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
418 | this.updateScrollParent(targetElement);
419 | }
420 | }
421 |
422 | this.trackingClick = true;
423 | this.trackingClickStart = event.timeStamp;
424 | this.targetElement = targetElement;
425 |
426 | this.touchStartX = touch.pageX;
427 | this.touchStartY = touch.pageY;
428 |
429 | // Prevent phantom clicks on fast double-tap (issue #36)
430 | if ((event.timeStamp - this.lastClickTime) < 200) {
431 | event.preventDefault();
432 | }
433 |
434 | return true;
435 | };
436 |
437 |
438 | /**
439 | * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
440 | *
441 | * @param {Event} event
442 | * @returns {boolean}
443 | */
444 | FastClick.prototype.touchHasMoved = function(event) {
445 | 'use strict';
446 | var touch = event.changedTouches[0], boundary = this.touchBoundary;
447 |
448 | if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
449 | return true;
450 | }
451 |
452 | return false;
453 | };
454 |
455 |
456 | /**
457 | * Update the last position.
458 | *
459 | * @param {Event} event
460 | * @returns {boolean}
461 | */
462 | FastClick.prototype.onTouchMove = function(event) {
463 | 'use strict';
464 | if (!this.trackingClick) {
465 | return true;
466 | }
467 |
468 | // If the touch has moved, cancel the click tracking
469 | if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
470 | this.trackingClick = false;
471 | this.targetElement = null;
472 | }
473 |
474 | return true;
475 | };
476 |
477 |
478 | /**
479 | * Attempt to find the labelled control for the given label element.
480 | *
481 | * @param {EventTarget|HTMLLabelElement} labelElement
482 | * @returns {Element|null}
483 | */
484 | FastClick.prototype.findControl = function(labelElement) {
485 | 'use strict';
486 |
487 | // Fast path for newer browsers supporting the HTML5 control attribute
488 | if (labelElement.control !== undefined) {
489 | return labelElement.control;
490 | }
491 |
492 | // All browsers under test that support touch events also support the HTML5 htmlFor attribute
493 | if (labelElement.htmlFor) {
494 | return document.getElementById(labelElement.htmlFor);
495 | }
496 |
497 | // If no for attribute exists, attempt to retrieve the first labellable descendant element
498 | // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
499 | return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
500 | };
501 |
502 |
503 | /**
504 | * On touch end, determine whether to send a click event at once.
505 | *
506 | * @param {Event} event
507 | * @returns {boolean}
508 | */
509 | FastClick.prototype.onTouchEnd = function(event) {
510 | 'use strict';
511 | var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
512 |
513 | if (!this.trackingClick) {
514 | return true;
515 | }
516 |
517 | // Prevent phantom clicks on fast double-tap (issue #36)
518 | if ((event.timeStamp - this.lastClickTime) < 200) {
519 | this.cancelNextClick = true;
520 | return true;
521 | }
522 |
523 | // Reset to prevent wrong click cancel on input (issue #156).
524 | this.cancelNextClick = false;
525 |
526 | this.lastClickTime = event.timeStamp;
527 |
528 | trackingClickStart = this.trackingClickStart;
529 | this.trackingClick = false;
530 | this.trackingClickStart = 0;
531 |
532 | // On some iOS devices, the targetElement supplied with the event is invalid if the layer
533 | // is performing a transition or scroll, and has to be re-detected manually. Note that
534 | // for this to function correctly, it must be called *after* the event target is checked!
535 | // See issue #57; also filed as rdar://13048589 .
536 | if (this.deviceIsIOSWithBadTarget) {
537 | touch = event.changedTouches[0];
538 |
539 | // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
540 | targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
541 | targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
542 | }
543 |
544 | targetTagName = targetElement.tagName.toLowerCase();
545 | if (targetTagName === 'label') {
546 | forElement = this.findControl(targetElement);
547 | if (forElement) {
548 | this.focus(targetElement);
549 | if (this.deviceIsAndroid) {
550 | return false;
551 | }
552 |
553 | targetElement = forElement;
554 | }
555 | } else if (this.needsFocus(targetElement)) {
556 |
557 | // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
558 | // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
559 | if ((event.timeStamp - trackingClickStart) > 100 || (this.deviceIsIOS && window.top !== window && targetTagName === 'input')) {
560 | this.targetElement = null;
561 | return false;
562 | }
563 |
564 | this.focus(targetElement);
565 |
566 | // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
567 | if (!this.deviceIsIOS4 || targetTagName !== 'select') {
568 | this.targetElement = null;
569 | event.preventDefault();
570 | }
571 |
572 | return false;
573 | }
574 |
575 | if (this.deviceIsIOS && !this.deviceIsIOS4) {
576 |
577 | // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
578 | // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
579 | scrollParent = targetElement.fastClickScrollParent;
580 | if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
581 | return true;
582 | }
583 | }
584 |
585 | // Prevent the actual click from going though - unless the target node is marked as requiring
586 | // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
587 | if (!this.needsClick(targetElement)) {
588 | event.preventDefault();
589 | this.sendClick(targetElement, event);
590 | }
591 |
592 | return false;
593 | };
594 |
595 |
596 | /**
597 | * On touch cancel, stop tracking the click.
598 | *
599 | * @returns {void}
600 | */
601 | FastClick.prototype.onTouchCancel = function() {
602 | 'use strict';
603 | this.trackingClick = false;
604 | this.targetElement = null;
605 | };
606 |
607 |
608 | /**
609 | * Determine mouse events which should be permitted.
610 | *
611 | * @param {Event} event
612 | * @returns {boolean}
613 | */
614 | FastClick.prototype.onMouse = function(event) {
615 | 'use strict';
616 |
617 | // If a target element was never set (because a touch event was never fired) allow the event
618 | if (!this.targetElement) {
619 | return true;
620 | }
621 |
622 | if (event.forwardedTouchEvent) {
623 | return true;
624 | }
625 |
626 | // Programmatically generated events targeting a specific element should be permitted
627 | if (!event.cancelable) {
628 | return true;
629 | }
630 |
631 | // Derive and check the target element to see whether the mouse event needs to be permitted;
632 | // unless explicitly enabled, prevent non-touch click events from triggering actions,
633 | // to prevent ghost/doubleclicks.
634 | if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
635 |
636 | // Prevent any user-added listeners declared on FastClick element from being fired.
637 | if (event.stopImmediatePropagation) {
638 | event.stopImmediatePropagation();
639 | } else {
640 |
641 | // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
642 | event.propagationStopped = true;
643 | }
644 |
645 | // Cancel the event
646 | event.stopPropagation();
647 | event.preventDefault();
648 |
649 | return false;
650 | }
651 |
652 | // If the mouse event is permitted, return true for the action to go through.
653 | return true;
654 | };
655 |
656 |
657 | /**
658 | * On actual clicks, determine whether this is a touch-generated click, a click action occurring
659 | * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
660 | * an actual click which should be permitted.
661 | *
662 | * @param {Event} event
663 | * @returns {boolean}
664 | */
665 | FastClick.prototype.onClick = function(event) {
666 | 'use strict';
667 | var permitted;
668 |
669 | // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
670 | if (this.trackingClick) {
671 | this.targetElement = null;
672 | this.trackingClick = false;
673 | return true;
674 | }
675 |
676 | // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
677 | if (event.target.type === 'submit' && event.detail === 0) {
678 | return true;
679 | }
680 |
681 | permitted = this.onMouse(event);
682 |
683 | // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
684 | if (!permitted) {
685 | this.targetElement = null;
686 | }
687 |
688 | // If clicks are permitted, return true for the action to go through.
689 | return permitted;
690 | };
691 |
692 |
693 | /**
694 | * Remove all FastClick's event listeners.
695 | *
696 | * @returns {void}
697 | */
698 | FastClick.prototype.destroy = function() {
699 | 'use strict';
700 | var layer = this.layer;
701 |
702 | if (this.deviceIsAndroid) {
703 | layer.removeEventListener('mouseover', this.onMouse, true);
704 | layer.removeEventListener('mousedown', this.onMouse, true);
705 | layer.removeEventListener('mouseup', this.onMouse, true);
706 | }
707 |
708 | layer.removeEventListener('click', this.onClick, true);
709 | layer.removeEventListener('touchstart', this.onTouchStart, false);
710 | layer.removeEventListener('touchmove', this.onTouchMove, false);
711 | layer.removeEventListener('touchend', this.onTouchEnd, false);
712 | layer.removeEventListener('touchcancel', this.onTouchCancel, false);
713 | };
714 |
715 |
716 | /**
717 | * Check whether FastClick is needed.
718 | *
719 | * @param {Element} layer The layer to listen on
720 | */
721 | FastClick.notNeeded = function(layer) {
722 | 'use strict';
723 | var metaViewport;
724 | var chromeVersion;
725 |
726 | // Devices that don't support touch don't need FastClick
727 | if (typeof window.ontouchstart === 'undefined') {
728 | return true;
729 | }
730 |
731 | // Chrome version - zero for other browsers
732 | chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
733 |
734 | if (chromeVersion) {
735 |
736 | if (FastClick.prototype.deviceIsAndroid) {
737 | metaViewport = document.querySelector('meta[name=viewport]');
738 |
739 | if (metaViewport) {
740 | // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
741 | if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
742 | return true;
743 | }
744 | // Chrome 32 and above with width=device-width or less don't need FastClick
745 | if (chromeVersion > 31 && window.innerWidth <= window.screen.width) {
746 | return true;
747 | }
748 | }
749 |
750 | // Chrome desktop doesn't need FastClick (issue #15)
751 | } else {
752 | return true;
753 | }
754 | }
755 |
756 | // IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97)
757 | if (layer.style.msTouchAction === 'none') {
758 | return true;
759 | }
760 |
761 | return false;
762 | };
763 |
764 |
765 | /**
766 | * Factory method for creating a FastClick object
767 | *
768 | * @param {Element} layer The layer to listen on
769 | */
770 | FastClick.attach = function(layer) {
771 | 'use strict';
772 | return new FastClick(layer);
773 | };
774 |
775 |
776 | if (typeof define !== 'undefined' && define.amd) {
777 |
778 | // AMD. Register as an anonymous module.
779 | define(function() {
780 | 'use strict';
781 | return FastClick;
782 | });
783 | } else if (typeof module !== 'undefined' && module.exports) {
784 | module.exports = FastClick.attach;
785 | module.exports.FastClick = FastClick;
786 | } else {
787 | window.FastClick = FastClick;
788 | }
789 |
--------------------------------------------------------------------------------
/www/lib/xcharts.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | xCharts v0.3.0 Copyright (c) 2012, tenXer, Inc. All Rights Reserved.
3 | @license MIT license. http://github.com/tenXer/xcharts for details
4 | */
5 | (function(){var xChart,_vis={},_scales={},_visutils={};(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0==t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){r=w.defaults({},r,w.templateSettings);var e=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(D,function(n){return"\\"+B[n]}),r&&(i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(i+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),a&&(i+="';\n"+a+"\n__p+='"),u=o+t.length,t}),i+="';\n",r.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=Function(r.variable||"obj","_",i)}catch(o){throw o.source=i,o}if(t)return a(t,w);var c=function(n){return a.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+i+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);function getInsertionPoint(zIndex){return _.chain(_.range(zIndex,10)).reverse().map(function(z){return'g[data-index="'+z+'"]'}).value().join(", ")}function colorClass(el,i){var c=el.getAttribute("class");return(c!==null?c.replace(/color\d+/g,""):"")+" color"+i}_visutils={getInsertionPoint:getInsertionPoint,colorClass:colorClass};var local=this,defaultSpacing=.25;function _getDomain(data,axis){return _.chain(data).pluck("data").flatten().pluck(axis).uniq().filter(function(d){return d!==undefined&&d!==null}).value().sort(d3.ascending)}_scales.ordinal=function(data,axis,bounds,extents){var domain=_getDomain(data,axis);return d3.scale.ordinal().domain(domain).rangeRoundBands(bounds,defaultSpacing)};_scales.linear=function(data,axis,bounds,extents){return d3.scale.linear().domain(extents).nice().rangeRound(bounds)};_scales.exponential=function(data,axis,bounds,extents){return d3.scale.pow().exponent(.65).domain(extents).nice().rangeRound(bounds)};_scales.time=function(data,axis,bounds,extents){return d3.time.scale().domain(_.map(extents,function(d){return new Date(d)})).range(bounds)};function _extendDomain(domain,axis){var min=domain[0],max=domain[1],diff,e;if(min===max){e=Math.max(Math.round(min/10),4);min-=e;max+=e}diff=max-min;min=min?min-diff/10:min;min=domain[0]>0?Math.max(min,0):min;max=max?max+diff/10:max;max=domain[1]<0?Math.min(max,0):max;return[min,max]}function _getExtents(options,data,xType,yType){var extents,nData=_.chain(data).pluck("data").flatten().value();extents={x:d3.extent(nData,function(d){return d.x}),y:d3.extent(nData,function(d){return d.y})};_.each([xType,yType],function(type,i){var axis=i?"y":"x",extended;extents[axis]=d3.extent(nData,function(d){return d[axis]});if(type==="ordinal"){return}_.each([axis+"Min",axis+"Max"],function(minMax,i){if(type!=="time"){extended=_extendDomain(extents[axis])}if(options.hasOwnProperty(minMax)&&options[minMax]!==null){extents[axis][i]=options[minMax]}else if(type!=="time"){extents[axis][i]=extended[i]}})});return extents}_scales.xy=function(self,data,xType,yType){var o=self._options,extents=_getExtents(o,data,xType,yType),scales={},horiz=[o.axisPaddingLeft,self._width],vert=[self._height,o.axisPaddingTop],xScale,yScale;_.each([xType,yType],function(type,i){var axis=i===0?"x":"y",bounds=i===0?horiz:vert,fn=xChart.getScale(type);scales[axis]=fn(data,axis,bounds,extents[axis])});return scales};(function(){var zIndex=2,selector="g.bar",insertBefore=_visutils.getInsertionPoint(zIndex);function postUpdateScale(self,scaleData,mainData,compData){self.xScale2=d3.scale.ordinal().domain(d3.range(0,mainData.length)).rangeRoundBands([0,self.xScale.rangeBand()],.08)}function enter(self,storage,className,data,callbacks){var barGroups,bars,yZero=self.yZero;barGroups=self._g.selectAll(selector+className).data(data,function(d){return d.className});barGroups.enter().insert("g",insertBefore).attr("data-index",zIndex).style("opacity",0).attr("class",function(d,i){var cl=_.uniq((className+d.className).split(".")).join(" ");return cl+" bar "+_visutils.colorClass(this,i)}).attr("transform",function(d,i){return"translate("+self.xScale2(i)+",0)"});bars=barGroups.selectAll("rect").data(function(d){return d.data},function(d){return d.x});bars.enter().append("rect").attr("width",0).attr("rx",3).attr("ry",3).attr("x",function(d){return self.xScale(d.x)+self.xScale2.rangeBand()/2}).attr("height",function(d){return Math.abs(yZero-self.yScale(d.y))}).attr("y",function(d){return d.y<0?yZero:self.yScale(d.y)}).on("mouseover",callbacks.mouseover).on("mouseout",callbacks.mouseout).on("click",callbacks.click);storage.barGroups=barGroups;storage.bars=bars}function update(self,storage,timing){var yZero=self.yZero;storage.barGroups.attr("class",function(d,i){return _visutils.colorClass(this,i)}).transition().duration(timing).style("opacity",1).attr("transform",function(d,i){return"translate("+self.xScale2(i)+",0)"});storage.bars.transition().duration(timing).attr("width",self.xScale2.rangeBand()).attr("x",function(d){return self.xScale(d.x)}).attr("height",function(d){return Math.abs(yZero-self.yScale(d.y))}).attr("y",function(d){return d.y<0?yZero:self.yScale(d.y)})}function exit(self,storage,timing){storage.bars.exit().transition().duration(timing).attr("width",0).remove();storage.barGroups.exit().transition().duration(timing).style("opacity",0).remove()}function destroy(self,storage,timing){var band=self.xScale2?self.xScale2.rangeBand()/2:0;delete self.xScale2;storage.bars.transition().duration(timing).attr("width",0).attr("x",function(d){return self.xScale(d.x)+band})}_vis.bar={postUpdateScale:postUpdateScale,enter:enter,update:update,exit:exit,destroy:destroy}})();(function(){var zIndex=3,selector="g.line",insertBefore=_visutils.getInsertionPoint(zIndex);function enter(self,storage,className,data,callbacks){var inter=self._options.interpolation,x=function(d,i){if(!self.xScale2&&!self.xScale.rangeBand){return self.xScale(d.x)}return self.xScale(d.x)+self.xScale.rangeBand()/2},y=function(d){return self.yScale(d.y)},line=d3.svg.line().x(x).interpolate(inter),area=d3.svg.area().x(x).y1(self.yZero).interpolate(inter),container,fills,paths;function datum(d){return[d.data]}container=self._g.selectAll(selector+className).data(data,function(d){return d.className});container.enter().insert("g",insertBefore).attr("data-index",zIndex).attr("class",function(d,i){var cl=_.uniq((className+d.className).split(".")).join(" ");return cl+" line "+_visutils.colorClass(this,i)});fills=container.selectAll("path.fill").data(datum);fills.enter().append("path").attr("class","fill").style("opacity",0).attr("d",area.y0(y));paths=container.selectAll("path.line").data(datum);paths.enter().append("path").attr("class","line").style("opacity",0).attr("d",line.y(y));storage.lineContainers=container;storage.lineFills=fills;storage.linePaths=paths;storage.lineX=x;storage.lineY=y;storage.lineA=area;storage.line=line}function update(self,storage,timing){storage.lineContainers.attr("class",function(d,i){return _visutils.colorClass(this,i)});storage.lineFills.transition().duration(timing).style("opacity",1).attr("d",storage.lineA.y0(storage.lineY));storage.linePaths.transition().duration(timing).style("opacity",1).attr("d",storage.line.y(storage.lineY))}function exit(self,storage){storage.linePaths.exit().style("opacity",0).remove();storage.lineFills.exit().style("opacity",0).remove();storage.lineContainers.exit().remove()}function destroy(self,storage,timing){storage.linePaths.transition().duration(timing).style("opacity",0);storage.lineFills.transition().duration(timing).style("opacity",0)}_vis.line={enter:enter,update:update,exit:exit,destroy:destroy}})();(function(){var line=_vis.line;function enter(self,storage,className,data,callbacks){var circles;line.enter(self,storage,className,data,callbacks);circles=storage.lineContainers.selectAll("circle").data(function(d){return d.data},function(d){return d.x});circles.enter().append("circle").style("opacity",0).attr("cx",storage.lineX).attr("cy",storage.lineY).attr("r",5).on("mouseover",callbacks.mouseover).on("mouseout",callbacks.mouseout).on("click",callbacks.click);storage.lineCircles=circles}function update(self,storage,timing){line.update.apply(null,_.toArray(arguments));storage.lineCircles.transition().duration(timing).style("opacity",1).attr("cx",storage.lineX).attr("cy",storage.lineY)}function exit(self,storage){storage.lineCircles.exit().remove();line.exit.apply(null,_.toArray(arguments))}function destroy(self,storage,timing){line.destroy.apply(null,_.toArray(arguments));if(!storage.lineCircles){return}storage.lineCircles.transition().duration(timing).style("opacity",0)}_vis["line-dotted"]={enter:enter,update:update,exit:exit,destroy:destroy}})();(function(){var line=_vis["line-dotted"];function enter(self,storage,className,data,callbacks){line.enter(self,storage,className,data,callbacks)}function _accumulate_data(data){function reduce(memo,num){return memo+num.y}var nData=_.map(data,function(set){var i=set.data.length,d=_.clone(set.data);set=_.clone(set);while(i){i-=1;d[i]=_.clone(set.data[i]);d[i].y0=set.data[i].y;d[i].y=_.reduce(_.first(set.data,i),reduce,set.data[i].y)}return _.extend(set,{data:d})});return nData}function _resetData(self){if(!self.hasOwnProperty("cumulativeOMainData")){return}self._mainData=self.cumulativeOMainData;delete self.cumulativeOMainData;self._compData=self.cumulativeOCompData;delete self.cumulativeOCompData}function preUpdateScale(self,data){_resetData(self);self.cumulativeOMainData=self._mainData;self._mainData=_accumulate_data(self._mainData);self.cumulativeOCompData=self._compData;self._compData=_accumulate_data(self._compData)}function destroy(self,storage,timing){_resetData(self);line.destroy.apply(null,_.toArray(arguments))}_vis.cumulative={preUpdateScale:preUpdateScale,enter:enter,update:line.update,exit:line.exit,destroy:destroy}})();var emptyData=[[]],defaults={mouseover:function(data,i){},mouseout:function(data,i){},click:function(data,i){},axisPaddingTop:0,axisPaddingRight:0,axisPaddingBottom:5,axisPaddingLeft:20,paddingTop:0,paddingRight:0,paddingBottom:20,paddingLeft:60,tickHintX:10,tickFormatX:function(x){return x},tickHintY:10,tickFormatY:function(y){return y},xMin:null,xMax:null,yMin:null,yMax:null,dataFormatX:function(x){return x},dataFormatY:function(y){return y},unsupported:function(selector){d3.select(selector).text("SVG is not supported on your browser")},empty:function(self,selector,d){},notempty:function(self,selector){},timing:750,interpolation:"monotone",sortX:function(a,b){return!a.x&&!b.x?0:a.xself._width/80){labels.sort(function(a,b){var r=/translate\(([^,)]+)/;a=a.getAttribute("transform").match(r);b=b.getAttribute("transform").match(r);return parseFloat(a[1],10)-parseFloat(b[1],10)});d3.selectAll(labels).filter(function(d,i){return i%(Math.ceil(labels.length/xTicks)+1)}).remove()}yRules=d3.svg.axis().scale(self.yScale).ticks(yTicks).tickSize(-self._width-o.axisPaddingRight-o.axisPaddingLeft).tickFormat(o.tickFormatY).orient("left");yAxis=self._gScale.selectAll("g.axisY").data(emptyData);yAxis.enter().append("g").attr("class","axis axisY").attr("transform","translate(0,0)");t.selectAll("g.axisY").call(yRules);zLine=self._gScale.selectAll("g.axisZero").data([[]]);zLine.enter().append("g").attr("class","axisZero");zLinePath=zLine.selectAll("line").data([[]]);zLinePath.enter().append("line").attr("x1",0).attr("x2",self._width+o.axisPaddingLeft+o.axisPaddingRight).attr("y1",self.yZero).attr("y2",self.yZero);zLinePath.transition().duration(o.timing).attr("y1",self.yZero).attr("y2",self.yZero)},_updateScale:function(){var self=this,_unionData=function(){return _.union(self._mainData,self._compData)},scaleData=_unionData(),vis=self._vis,scale,min;delete self.xScale;delete self.yScale;delete self.yZero;if(vis.hasOwnProperty("preUpdateScale")){vis.preUpdateScale(self,scaleData,self._mainData,self._compData)}scaleData=_unionData();scale=_scales.xy(self,scaleData,self._xScaleType,self._yScaleType);self.xScale=scale.x;self.yScale=scale.y;min=self.yScale.domain()[0];self.yZero=min>0?self.yScale(min):self.yScale(0);if(vis.hasOwnProperty("postUpdateScale")){vis.postUpdateScale(self,scaleData,self._mainData,self._compData)}},_enter:function(vis,storage,data,className){var self=this,callbacks={click:self._options.click,mouseover:self._options.mouseover,mouseout:self._options.mouseout};self._checkVisMethod(vis,"enter");vis.enter(self,storage,className,data,callbacks)},_update:function(vis,storage){var self=this;self._checkVisMethod(vis,"update");vis.update(self,storage,self._options.timing)},_exit:function(vis,storage){var self=this;self._checkVisMethod(vis,"exit");vis.exit(self,storage,self._options.timing)},_destroy:function(vis,storage){var self=this;self._checkVisMethod(vis,"destroy");try{vis.destroy(self,storage,self._options.timing)}catch(e){}},_draw:function(){var self=this,o=self._options,comp,compKeys;self._noData=_.flatten(_.pluck(self._mainData,"data").concat(_.pluck(self._compData,"data"))).length===0;self._updateScale();self._drawAxes();self._enter(self._vis,self._mainStorage,self._mainData,".main");self._exit(self._vis,self._mainStorage);self._update(self._vis,self._mainStorage);comp=_.chain(self._compData).groupBy(function(d){return d.type});compKeys=comp.keys();_.each(self._compStorage,function(d,key){if(-1===compKeys.indexOf(key).value()){var vis=_vis[key];self._enter(vis,d,[],".comp."+key.replace(/\W+/g,""));self._exit(vis,d)}});comp.each(function(d,key){var vis=_vis[key],storage;if(!self._compStorage.hasOwnProperty(key)){self._compStorage[key]={}}storage=self._compStorage[key];self._enter(vis,storage,d,".comp."+key.replace(/\W+/g,""));self._exit(vis,storage);self._update(vis,storage)});if(self._noData){o.empty(self,self._selector,self._mainData)}else{o.notempty(self,self._selector)}},_checkVisMethod:function(vis,method){var self=this;if(!vis[method]){throw'Required method "'+method+'" not found on vis type "'+self._type+'".'}}});if(typeof define==="function"&&define.amd&&typeof define.amd==="object"){define(function(){return xChart});return}window.xChart=xChart})();
--------------------------------------------------------------------------------
/www/lib/xcharts.js:
--------------------------------------------------------------------------------
1 | /*!
2 | xCharts v0.3.0 Copyright (c) 2012, tenXer, Inc. All Rights Reserved.
3 | @license MIT license. http://github.com/tenXer/xcharts for details
4 | */
5 |
6 | (function () {
7 |
8 | var xChart,
9 | _vis = {},
10 | _scales = {},
11 | _visutils = {};
12 | (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0==t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){r=w.defaults({},r,w.templateSettings);var e=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(D,function(n){return"\\"+B[n]}),r&&(i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(i+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),a&&(i+="';\n"+a+"\n__p+='"),u=o+t.length,t}),i+="';\n",r.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=Function(r.variable||"obj","_",i)}catch(o){throw o.source=i,o}if(t)return a(t,w);var c=function(n){return a.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+i+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);function getInsertionPoint(zIndex) {
13 | return _.chain(_.range(zIndex, 10)).reverse().map(function (z) {
14 | return 'g[data-index="' + z + '"]';
15 | }).value().join(', ');
16 | }
17 |
18 | function colorClass(el, i) {
19 | var c = el.getAttribute('class');
20 | return ((c !== null) ? c.replace(/color\d+/g, '') : '') + ' color' + i;
21 | }
22 |
23 | _visutils = {
24 | getInsertionPoint: getInsertionPoint,
25 | colorClass: colorClass
26 | };
27 | var local = this,
28 | defaultSpacing = 0.25;
29 |
30 | function _getDomain(data, axis) {
31 | return _.chain(data)
32 | .pluck('data')
33 | .flatten()
34 | .pluck(axis)
35 | .uniq()
36 | .filter(function (d) {
37 | return d !== undefined && d !== null;
38 | })
39 | .value()
40 | .sort(d3.ascending);
41 | }
42 |
43 | _scales.ordinal = function (data, axis, bounds, extents) {
44 | var domain = _getDomain(data, axis);
45 | return d3.scale.ordinal()
46 | .domain(domain)
47 | .rangeRoundBands(bounds, defaultSpacing);
48 | };
49 |
50 | _scales.linear = function (data, axis, bounds, extents) {
51 | return d3.scale.linear()
52 | .domain(extents)
53 | .nice()
54 | .rangeRound(bounds);
55 | };
56 |
57 | _scales.exponential = function (data, axis, bounds, extents) {
58 | return d3.scale.pow()
59 | .exponent(0.65)
60 | .domain(extents)
61 | .nice()
62 | .rangeRound(bounds);
63 | };
64 |
65 | _scales.time = function (data, axis, bounds, extents) {
66 | return d3.time.scale()
67 | .domain(_.map(extents, function (d) { return new Date(d); }))
68 | .range(bounds);
69 | };
70 |
71 | function _extendDomain(domain, axis) {
72 | var min = domain[0],
73 | max = domain[1],
74 | diff,
75 | e;
76 |
77 | if (min === max) {
78 | e = Math.max(Math.round(min / 10), 4);
79 | min -= e;
80 | max += e;
81 | }
82 |
83 | diff = max - min;
84 | min = (min) ? min - (diff / 10) : min;
85 | min = (domain[0] > 0) ? Math.max(min, 0) : min;
86 | max = (max) ? max + (diff / 10) : max;
87 | max = (domain[1] < 0) ? Math.min(max, 0) : max;
88 |
89 | return [min, max];
90 | }
91 |
92 | function _getExtents(options, data, xType, yType) {
93 | var extents,
94 | nData = _.chain(data)
95 | .pluck('data')
96 | .flatten()
97 | .value();
98 |
99 | extents = {
100 | x: d3.extent(nData, function (d) { return d.x; }),
101 | y: d3.extent(nData, function (d) { return d.y; })
102 | };
103 |
104 | _.each([xType, yType], function (type, i) {
105 | var axis = (i) ? 'y' : 'x',
106 | extended;
107 | extents[axis] = d3.extent(nData, function (d) { return d[axis]; });
108 | if (type === 'ordinal') {
109 | return;
110 | }
111 |
112 | _.each([axis + 'Min', axis + 'Max'], function (minMax, i) {
113 | if (type !== 'time') {
114 | extended = _extendDomain(extents[axis]);
115 | }
116 |
117 | if (options.hasOwnProperty(minMax) && options[minMax] !== null) {
118 | extents[axis][i] = options[minMax];
119 | } else if (type !== 'time') {
120 | extents[axis][i] = extended[i];
121 | }
122 | });
123 | });
124 |
125 | return extents;
126 | }
127 |
128 | _scales.xy = function (self, data, xType, yType) {
129 | var o = self._options,
130 | extents = _getExtents(o, data, xType, yType),
131 | scales = {},
132 | horiz = [o.axisPaddingLeft, self._width],
133 | vert = [self._height, o.axisPaddingTop],
134 | xScale,
135 | yScale;
136 |
137 | _.each([xType, yType], function (type, i) {
138 | var axis = (i === 0) ? 'x' : 'y',
139 | bounds = (i === 0) ? horiz : vert,
140 | fn = xChart.getScale(type);
141 | scales[axis] = fn(data, axis, bounds, extents[axis]);
142 | });
143 |
144 | return scales;
145 | };
146 | (function () {
147 | var zIndex = 2,
148 | selector = 'g.bar',
149 | insertBefore = _visutils.getInsertionPoint(zIndex);
150 |
151 | function postUpdateScale(self, scaleData, mainData, compData) {
152 | self.xScale2 = d3.scale.ordinal()
153 | .domain(d3.range(0, mainData.length))
154 | .rangeRoundBands([0, self.xScale.rangeBand()], 0.08);
155 | }
156 |
157 | function enter(self, storage, className, data, callbacks) {
158 | var barGroups, bars,
159 | yZero = self.yZero;
160 |
161 | barGroups = self._g.selectAll(selector + className)
162 | .data(data, function (d) {
163 | return d.className;
164 | });
165 |
166 | barGroups.enter().insert('g', insertBefore)
167 | .attr('data-index', zIndex)
168 | .style('opacity', 0)
169 | .attr('class', function (d, i) {
170 | var cl = _.uniq((className + d.className).split('.')).join(' ');
171 | return cl + ' bar ' + _visutils.colorClass(this, i);
172 | })
173 | .attr('transform', function (d, i) {
174 | return 'translate(' + self.xScale2(i) + ',0)';
175 | });
176 |
177 | bars = barGroups.selectAll('rect')
178 | .data(function (d) {
179 | return d.data;
180 | }, function (d) {
181 | return d.x;
182 | });
183 |
184 | bars.enter().append('rect')
185 | .attr('width', 0)
186 | .attr('rx', 3)
187 | .attr('ry', 3)
188 | .attr('x', function (d) {
189 | return self.xScale(d.x) + (self.xScale2.rangeBand() / 2);
190 | })
191 | .attr('height', function (d) {
192 | return Math.abs(yZero - self.yScale(d.y));
193 | })
194 | .attr('y', function (d) {
195 | return (d.y < 0) ? yZero : self.yScale(d.y);
196 | })
197 | .on('mouseover', callbacks.mouseover)
198 | .on('mouseout', callbacks.mouseout)
199 | .on('click', callbacks.click);
200 |
201 | storage.barGroups = barGroups;
202 | storage.bars = bars;
203 | }
204 |
205 | function update(self, storage, timing) {
206 | var yZero = self.yZero;
207 |
208 | storage.barGroups
209 | .attr('class', function (d, i) {
210 | return _visutils.colorClass(this, i);
211 | })
212 | .transition().duration(timing)
213 | .style('opacity', 1)
214 | .attr('transform', function (d, i) {
215 | return 'translate(' + self.xScale2(i) + ',0)';
216 | });
217 |
218 | storage.bars.transition().duration(timing)
219 | .attr('width', self.xScale2.rangeBand())
220 | .attr('x', function (d) {
221 | return self.xScale(d.x);
222 | })
223 | .attr('height', function (d) {
224 | return Math.abs(yZero - self.yScale(d.y));
225 | })
226 | .attr('y', function (d) {
227 | return (d.y < 0) ? yZero : self.yScale(d.y);
228 | });
229 | }
230 |
231 | function exit(self, storage, timing) {
232 | storage.bars.exit()
233 | .transition().duration(timing)
234 | .attr('width', 0)
235 | .remove();
236 | storage.barGroups.exit()
237 | .transition().duration(timing)
238 | .style('opacity', 0)
239 | .remove();
240 | }
241 |
242 | function destroy(self, storage, timing) {
243 | var band = (self.xScale2) ? self.xScale2.rangeBand() / 2 : 0;
244 | delete self.xScale2;
245 | storage.bars
246 | .transition().duration(timing)
247 | .attr('width', 0)
248 | .attr('x', function (d) {
249 | return self.xScale(d.x) + band;
250 | });
251 | }
252 |
253 | _vis.bar = {
254 | postUpdateScale: postUpdateScale,
255 | enter: enter,
256 | update: update,
257 | exit: exit,
258 | destroy: destroy
259 | };
260 | }());
261 | (function () {
262 |
263 | var zIndex = 3,
264 | selector = 'g.line',
265 | insertBefore = _visutils.getInsertionPoint(zIndex);
266 |
267 | function enter(self, storage, className, data, callbacks) {
268 | var inter = self._options.interpolation,
269 | x = function (d, i) {
270 | if (!self.xScale2 && !self.xScale.rangeBand) {
271 | return self.xScale(d.x);
272 | }
273 | return self.xScale(d.x) + (self.xScale.rangeBand() / 2);
274 | },
275 | y = function (d) { return self.yScale(d.y); },
276 | line = d3.svg.line()
277 | .x(x)
278 | .interpolate(inter),
279 | area = d3.svg.area()
280 | .x(x)
281 | .y1(self.yZero)
282 | .interpolate(inter),
283 | container,
284 | fills,
285 | paths;
286 |
287 | function datum(d) {
288 | return [d.data];
289 | }
290 |
291 | container = self._g.selectAll(selector + className)
292 | .data(data, function (d) {
293 | return d.className;
294 | });
295 |
296 | container.enter().insert('g', insertBefore)
297 | .attr('data-index', zIndex)
298 | .attr('class', function (d, i) {
299 | var cl = _.uniq((className + d.className).split('.')).join(' ');
300 | return cl + ' line ' + _visutils.colorClass(this, i);
301 | });
302 |
303 | fills = container.selectAll('path.fill')
304 | .data(datum);
305 |
306 | fills.enter().append('path')
307 | .attr('class', 'fill')
308 | .style('opacity', 0)
309 | .attr('d', area.y0(y));
310 |
311 | paths = container.selectAll('path.line')
312 | .data(datum);
313 |
314 | paths.enter().append('path')
315 | .attr('class', 'line')
316 | .style('opacity', 0)
317 | .attr('d', line.y(y));
318 |
319 | storage.lineContainers = container;
320 | storage.lineFills = fills;
321 | storage.linePaths = paths;
322 | storage.lineX = x;
323 | storage.lineY = y;
324 | storage.lineA = area;
325 | storage.line = line;
326 | }
327 |
328 | function update(self, storage, timing) {
329 | storage.lineContainers
330 | .attr('class', function (d, i) {
331 | return _visutils.colorClass(this, i);
332 | });
333 |
334 | storage.lineFills.transition().duration(timing)
335 | .style('opacity', 1)
336 | .attr('d', storage.lineA.y0(storage.lineY));
337 |
338 | storage.linePaths.transition().duration(timing)
339 | .style('opacity', 1)
340 | .attr('d', storage.line.y(storage.lineY));
341 | }
342 |
343 | function exit(self, storage) {
344 | storage.linePaths.exit()
345 | .style('opacity', 0)
346 | .remove();
347 | storage.lineFills.exit()
348 | .style('opacity', 0)
349 | .remove();
350 |
351 | storage.lineContainers.exit()
352 | .remove();
353 | }
354 |
355 | function destroy(self, storage, timing) {
356 | storage.linePaths.transition().duration(timing)
357 | .style('opacity', 0);
358 | storage.lineFills.transition().duration(timing)
359 | .style('opacity', 0);
360 | }
361 |
362 | _vis.line = {
363 | enter: enter,
364 | update: update,
365 | exit: exit,
366 | destroy: destroy
367 | };
368 | }());
369 | (function () {
370 | var line = _vis.line;
371 |
372 | function enter(self, storage, className, data, callbacks) {
373 | var circles;
374 |
375 | line.enter(self, storage, className, data, callbacks);
376 |
377 | circles = storage.lineContainers.selectAll('circle')
378 | .data(function (d) {
379 | return d.data;
380 | }, function (d) {
381 | return d.x;
382 | });
383 |
384 | circles.enter().append('circle')
385 | .style('opacity', 0)
386 | .attr('cx', storage.lineX)
387 | .attr('cy', storage.lineY)
388 | .attr('r', 5)
389 | .on('mouseover', callbacks.mouseover)
390 | .on('mouseout', callbacks.mouseout)
391 | .on('click', callbacks.click);
392 |
393 | storage.lineCircles = circles;
394 | }
395 |
396 | function update(self, storage, timing) {
397 | line.update.apply(null, _.toArray(arguments));
398 |
399 | storage.lineCircles.transition().duration(timing)
400 | .style('opacity', 1)
401 | .attr('cx', storage.lineX)
402 | .attr('cy', storage.lineY);
403 | }
404 |
405 | function exit(self, storage) {
406 | storage.lineCircles.exit()
407 | .remove();
408 | line.exit.apply(null, _.toArray(arguments));
409 | }
410 |
411 | function destroy(self, storage, timing) {
412 | line.destroy.apply(null, _.toArray(arguments));
413 | if (!storage.lineCircles) {
414 | return;
415 | }
416 | storage.lineCircles.transition().duration(timing)
417 | .style('opacity', 0);
418 | }
419 |
420 | _vis['line-dotted'] = {
421 | enter: enter,
422 | update: update,
423 | exit: exit,
424 | destroy: destroy
425 | };
426 | }());
427 | (function () {
428 | var line = _vis['line-dotted'];
429 |
430 | function enter(self, storage, className, data, callbacks) {
431 | line.enter(self, storage, className, data, callbacks);
432 | }
433 |
434 | function _accumulate_data(data) {
435 | function reduce(memo, num) {
436 | return memo + num.y;
437 | }
438 |
439 | var nData = _.map(data, function (set) {
440 | var i = set.data.length,
441 | d = _.clone(set.data);
442 | set = _.clone(set);
443 | while (i) {
444 | i -= 1;
445 | // Need to clone here, otherwise we are actually setting the same
446 | // data onto the original data set.
447 | d[i] = _.clone(set.data[i]);
448 | d[i].y0 = set.data[i].y;
449 | d[i].y = _.reduce(_.first(set.data, i), reduce, set.data[i].y);
450 | }
451 | return _.extend(set, { data: d });
452 | });
453 |
454 | return nData;
455 | }
456 |
457 | function _resetData(self) {
458 | if (!self.hasOwnProperty('cumulativeOMainData')) {
459 | return;
460 | }
461 | self._mainData = self.cumulativeOMainData;
462 | delete self.cumulativeOMainData;
463 | self._compData = self.cumulativeOCompData;
464 | delete self.cumulativeOCompData;
465 | }
466 |
467 | function preUpdateScale(self, data) {
468 | _resetData(self);
469 | self.cumulativeOMainData = self._mainData;
470 | self._mainData = _accumulate_data(self._mainData);
471 | self.cumulativeOCompData = self._compData;
472 | self._compData = _accumulate_data(self._compData);
473 | }
474 |
475 | function destroy(self, storage, timing) {
476 | _resetData(self);
477 | line.destroy.apply(null, _.toArray(arguments));
478 | }
479 |
480 | _vis.cumulative = {
481 | preUpdateScale: preUpdateScale,
482 | enter: enter,
483 | update: line.update,
484 | exit: line.exit,
485 | destroy: destroy
486 | };
487 | }());
488 | var emptyData = [[]],
489 | defaults = {
490 | // User interaction callbacks
491 | mouseover: function (data, i) {},
492 | mouseout: function (data, i) {},
493 | click: function (data, i) {},
494 |
495 | // Padding between the axes and the contents of the chart
496 | axisPaddingTop: 0,
497 | axisPaddingRight: 0,
498 | axisPaddingBottom: 5,
499 | axisPaddingLeft: 20,
500 |
501 | // Padding around the edge of the chart (space for axis labels, etc)
502 | paddingTop: 0,
503 | paddingRight: 0,
504 | paddingBottom: 20,
505 | paddingLeft: 60,
506 |
507 | // Axis tick formatting
508 | tickHintX: 10,
509 | tickFormatX: function (x) { return x; },
510 | tickHintY: 10,
511 | tickFormatY: function (y) { return y; },
512 |
513 | // Min/Max Axis Values
514 | xMin: null,
515 | xMax: null,
516 | yMin: null,
517 | yMax: null,
518 |
519 | // Pre-format input data
520 | dataFormatX: function (x) { return x; },
521 | dataFormatY: function (y) { return y; },
522 |
523 | unsupported: function (selector) {
524 | d3.select(selector).text('SVG is not supported on your browser');
525 | },
526 |
527 | // Callback functions if no data
528 | empty: function (self, selector, d) {},
529 | notempty: function (self, selector) {},
530 |
531 | timing: 750,
532 |
533 | // Line interpolation
534 | interpolation: 'monotone',
535 |
536 | // Data sorting
537 | sortX: function (a, b) {
538 | return (!a.x && !b.x) ? 0 : (a.x < b.x) ? -1 : 1;
539 | }
540 | };
541 |
542 | // What/how should the warning/error be presented?
543 | function svgEnabled() {
544 | var d = document;
545 | return (!!d.createElementNS &&
546 | !!d.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect);
547 | }
548 |
549 | /**
550 | * Creates a new chart
551 | *
552 | * @param string type The drawing type for the main data
553 | * @param array data Data to render in the chart
554 | * @param string selector CSS Selector for the parent element for the chart
555 | * @param object options Optional. See `defaults` for options
556 | *
557 | * Examples:
558 | * var data = {
559 | * "main": [
560 | * {
561 | * "data": [
562 | * {
563 | * "x": "2012-08-09T07:00:00.522Z",
564 | * "y": 68
565 | * },
566 | * {
567 | * "x": "2012-08-10T07:00:00.522Z",
568 | * "y": 295
569 | * },
570 | * {
571 | * "x": "2012-08-11T07:00:00.522Z",
572 | * "y": 339
573 | * },
574 | * ],
575 | * "className": ".foo"
576 | * }
577 | * ],
578 | * "xScale": "ordinal",
579 | * "yScale": "linear",
580 | * "comp": [
581 | * {
582 | * "data": [
583 | * {
584 | * "x": "2012-08-09T07:00:00.522Z",
585 | * "y": 288
586 | * },
587 | * {
588 | * "x": "2012-08-10T07:00:00.522Z",
589 | * "y": 407
590 | * },
591 | * {
592 | * "x": "2012-08-11T07:00:00.522Z",
593 | * "y": 459
594 | * }
595 | * ],
596 | * "className": ".comp.comp_foo",
597 | * "type": "line-arrowed"
598 | * }
599 | * ]
600 | * },
601 | * myChart = new Chart('bar', data, '#chart');
602 | *
603 | */
604 | function xChart(type, data, selector, options) {
605 | var self = this,
606 | resizeLock;
607 |
608 | self._options = options = _.defaults(options || {}, defaults);
609 |
610 | if (svgEnabled() === false) {
611 | return options.unsupported(selector);
612 | }
613 |
614 | self._selector = selector;
615 | self._container = d3.select(selector);
616 | self._drawSvg();
617 | self._mainStorage = {};
618 | self._compStorage = {};
619 |
620 | data = _.clone(data);
621 | if (type && !data.type) {
622 | data.type = type;
623 | }
624 |
625 | self.setData(data);
626 |
627 | d3.select(window).on('resize.for.' + selector, function () {
628 | if (resizeLock) {
629 | clearTimeout(resizeLock);
630 | }
631 | resizeLock = setTimeout(function () {
632 | resizeLock = null;
633 | self._resize();
634 | }, 500);
635 | });
636 | }
637 |
638 | /**
639 | * Add a visualization type
640 | *
641 | * @param string type Unique key/name used with setType
642 | * @param object vis object map of vis methods
643 | */
644 | xChart.setVis = function (type, vis) {
645 | if (_vis.hasOwnProperty(type)) {
646 | throw 'Cannot override vis type "' + type + '".';
647 | }
648 | _vis[type] = vis;
649 | };
650 |
651 | /**
652 | * Get a clone of a visualization
653 | * Useful for extending vis functionality
654 | *
655 | * @param string type Unique key/name of the vis
656 | */
657 | xChart.getVis = function (type) {
658 | if (!_vis.hasOwnProperty(type)) {
659 | throw 'Vis type "' + type + '" does not exist.';
660 | }
661 |
662 | return _.clone(_vis[type]);
663 | };
664 |
665 | xChart.setScale = function (name, fn) {
666 | if (_scales.hasOwnProperty(name)) {
667 | throw 'Scale type "' + name + '" already exists.';
668 | }
669 |
670 | _scales[name] = fn;
671 | };
672 |
673 | xChart.getScale = function (name) {
674 | if (!_scales.hasOwnProperty(name)) {
675 | throw 'Scale type "' + name + '" does not exist.';
676 | }
677 | return _scales[name];
678 | };
679 |
680 | xChart.visutils = _visutils;
681 |
682 | _.defaults(xChart.prototype, {
683 | /**
684 | * Set or change the drawing type for the main data.
685 | *
686 | * @param string type Must be an available drawing type
687 | *
688 | */
689 | setType: function (type, skipDraw) {
690 | var self = this;
691 |
692 | if (self._type && type === self._type) {
693 | return;
694 | }
695 |
696 | if (!_vis.hasOwnProperty(type)) {
697 | throw 'Vis type "' + type + '" is not defined.';
698 | }
699 |
700 | if (self._type) {
701 | self._destroy(self._vis, self._mainStorage);
702 | }
703 |
704 | self._type = type;
705 | self._vis = _vis[type];
706 | if (!skipDraw) {
707 | self._draw();
708 | }
709 | },
710 |
711 | /**
712 | * Set and update the data for the chart. Optionally skip drawing.
713 | *
714 | * @param object data New data. See new xChart example for format
715 | *
716 | */
717 | setData: function (data) {
718 | var self = this,
719 | o = self._options,
720 | nData = _.clone(data);
721 |
722 | if (!data.hasOwnProperty('main')) {
723 | throw 'No "main" key found in given chart data.';
724 | }
725 |
726 | switch (data.type) {
727 | case 'bar':
728 | // force the xScale to be ordinal
729 | data.xScale = 'ordinal';
730 | break;
731 | case undefined:
732 | data.type = self._type;
733 | break;
734 | }
735 |
736 | o.xMin = (isNaN(parseInt(data.xMin, 10))) ? o.xMin : data.xMin;
737 | o.xMax = (isNaN(parseInt(data.xMax, 10))) ? o.xMax : data.xMax;
738 | o.yMin = (isNaN(parseInt(data.yMin, 10))) ? o.yMin : data.yMin;
739 | o.yMax = (isNaN(parseInt(data.yMax, 10))) ? o.yMax : data.yMax;
740 |
741 | if (self._vis) {
742 | self._destroy(self._vis, self._mainStorage);
743 | }
744 |
745 | self.setType(data.type, true);
746 |
747 | function _mapData(set) {
748 | var d = _.map(_.clone(set.data), function (p) {
749 | var np = _.clone(p);
750 | if (p.hasOwnProperty('x')) {
751 | np.x = o.dataFormatX(p.x);
752 | }
753 | if (p.hasOwnProperty('y')) {
754 | np.y = o.dataFormatY(p.y);
755 | }
756 | return np;
757 | }).sort(o.sortX);
758 | return _.extend(_.clone(set), { data: d });
759 | }
760 |
761 | nData.main = _.map(nData.main, _mapData);
762 | self._mainData = nData.main;
763 | self._xScaleType = nData.xScale;
764 | self._yScaleType = nData.yScale;
765 |
766 | if (nData.hasOwnProperty('comp')) {
767 | nData.comp = _.map(nData.comp, _mapData);
768 | self._compData = nData.comp;
769 | } else {
770 | self._compData = [];
771 | }
772 |
773 | self._draw();
774 | },
775 |
776 | /**
777 | * Change the scale of an axis
778 | *
779 | * @param string axis Name of an axis. One of 'x' or 'y'
780 | * @param string type Name of the scale type
781 | *
782 | */
783 | setScale: function (axis, type) {
784 | var self = this;
785 |
786 | switch (axis) {
787 | case 'x':
788 | self._xScaleType = type;
789 | break;
790 | case 'y':
791 | self._yScaleType = type;
792 | break;
793 | default:
794 | throw 'Cannot change scale of unknown axis "' + axis + '".';
795 | }
796 |
797 | self._draw();
798 | },
799 |
800 | /**
801 | * Create the SVG element and g container. Resize if necessary.
802 | */
803 | _drawSvg: function () {
804 | var self = this,
805 | c = self._container,
806 | options = self._options,
807 | width = parseInt(c.style('width').replace('px', ''), 10),
808 | height = parseInt(c.style('height').replace('px', ''), 10),
809 | svg,
810 | g,
811 | gScale;
812 |
813 | svg = c.selectAll('svg')
814 | .data(emptyData);
815 |
816 | svg.enter().append('svg')
817 | // Inherit the height and width from the parent element
818 | .attr('height', height)
819 | .attr('width', width)
820 | .attr('class', 'xchart');
821 |
822 | svg.transition()
823 | .attr('width', width)
824 | .attr('height', height);
825 |
826 | g = svg.selectAll('g')
827 | .data(emptyData);
828 |
829 | g.enter().append('g')
830 | .attr(
831 | 'transform',
832 | 'translate(' + options.paddingLeft + ',' + options.paddingTop + ')'
833 | );
834 |
835 | gScale = g.selectAll('g.scale')
836 | .data(emptyData);
837 |
838 | gScale.enter().append('g')
839 | .attr('class', 'scale');
840 |
841 | self._svg = svg;
842 | self._g = g;
843 | self._gScale = gScale;
844 |
845 | self._height = height - options.paddingTop - options.paddingBottom -
846 | options.axisPaddingTop - options.axisPaddingBottom;
847 | self._width = width - options.paddingLeft - options.paddingRight -
848 | options.axisPaddingLeft - options.axisPaddingRight;
849 | },
850 |
851 | /**
852 | * Resize the visualization
853 | */
854 | _resize: function (event) {
855 | var self = this;
856 |
857 | self._drawSvg();
858 | self._draw();
859 | },
860 |
861 | /**
862 | * Draw the x and y axes
863 | */
864 | _drawAxes: function () {
865 | if (this._noData) {
866 | return;
867 | }
868 | var self = this,
869 | o = self._options,
870 | t = self._gScale.transition().duration(o.timing),
871 | xTicks = o.tickHintX,
872 | yTicks = o.tickHintY,
873 | bottom = self._height + o.axisPaddingTop + o.axisPaddingBottom,
874 | zeroLine = d3.svg.line().x(function (d) { return d; }),
875 | zLine,
876 | zLinePath,
877 | xAxis,
878 | xRules,
879 | yAxis,
880 | yRules,
881 | labels;
882 |
883 | xRules = d3.svg.axis()
884 | .scale(self.xScale)
885 | .ticks(xTicks)
886 | .tickSize(-self._height)
887 | .tickFormat(o.tickFormatX)
888 | .orient('bottom');
889 |
890 | xAxis = self._gScale.selectAll('g.axisX')
891 | .data(emptyData);
892 |
893 | xAxis.enter().append('g')
894 | .attr('class', 'axis axisX')
895 | .attr('transform', 'translate(0,' + bottom + ')');
896 |
897 | xAxis.call(xRules);
898 |
899 | labels = self._gScale.selectAll('.axisX g')[0];
900 | if (labels.length > (self._width / 80)) {
901 | labels.sort(function (a, b) {
902 | var r = /translate\(([^,)]+)/;
903 | a = a.getAttribute('transform').match(r);
904 | b = b.getAttribute('transform').match(r);
905 | return parseFloat(a[1], 10) - parseFloat(b[1], 10);
906 | });
907 |
908 | d3.selectAll(labels)
909 | .filter(function (d, i) {
910 | return i % (Math.ceil(labels.length / xTicks) + 1);
911 | })
912 | .remove();
913 | }
914 |
915 | yRules = d3.svg.axis()
916 | .scale(self.yScale)
917 | .ticks(yTicks)
918 | .tickSize(-self._width - o.axisPaddingRight - o.axisPaddingLeft)
919 | .tickFormat(o.tickFormatY)
920 | .orient('left');
921 |
922 | yAxis = self._gScale.selectAll('g.axisY')
923 | .data(emptyData);
924 |
925 | yAxis.enter().append('g')
926 | .attr('class', 'axis axisY')
927 | .attr('transform', 'translate(0,0)');
928 |
929 | t.selectAll('g.axisY')
930 | .call(yRules);
931 |
932 | // zero line
933 | zLine = self._gScale.selectAll('g.axisZero')
934 | .data([[]]);
935 |
936 | zLine.enter().append('g')
937 | .attr('class', 'axisZero');
938 |
939 | zLinePath = zLine.selectAll('line')
940 | .data([[]]);
941 |
942 | zLinePath.enter().append('line')
943 | .attr('x1', 0)
944 | .attr('x2', self._width + o.axisPaddingLeft + o.axisPaddingRight)
945 | .attr('y1', self.yZero)
946 | .attr('y2', self.yZero);
947 |
948 | zLinePath.transition().duration(o.timing)
949 | .attr('y1', self.yZero)
950 | .attr('y2', self.yZero);
951 | },
952 |
953 | /**
954 | * Update the x and y scales (used when drawing)
955 | *
956 | * Optional methods in drawing types:
957 | * preUpdateScale
958 | * postUpdateScale
959 | *
960 | * Example implementation in vis type:
961 | *
962 | * function postUpdateScale(self, scaleData, mainData, compData) {
963 | * self.xScale2 = d3.scale.ordinal()
964 | * .domain(d3.range(0, mainData.length))
965 | * .rangeRoundBands([0, self.xScale.rangeBand()], 0.08);
966 | * }
967 | *
968 | */
969 | _updateScale: function () {
970 | var self = this,
971 | _unionData = function () {
972 | return _.union(self._mainData, self._compData);
973 | },
974 | scaleData = _unionData(),
975 | vis = self._vis,
976 | scale,
977 | min;
978 |
979 | delete self.xScale;
980 | delete self.yScale;
981 | delete self.yZero;
982 |
983 | if (vis.hasOwnProperty('preUpdateScale')) {
984 | vis.preUpdateScale(self, scaleData, self._mainData, self._compData);
985 | }
986 |
987 | // Just in case preUpdateScale modified
988 | scaleData = _unionData();
989 | scale = _scales.xy(self, scaleData, self._xScaleType, self._yScaleType);
990 |
991 | self.xScale = scale.x;
992 | self.yScale = scale.y;
993 |
994 | min = self.yScale.domain()[0];
995 | self.yZero = (min > 0) ? self.yScale(min) : self.yScale(0);
996 |
997 | if (vis.hasOwnProperty('postUpdateScale')) {
998 | vis.postUpdateScale(self, scaleData, self._mainData, self._compData);
999 | }
1000 | },
1001 |
1002 | /**
1003 | * Create (Enter) the elements for the vis
1004 | *
1005 | * Required method
1006 | *
1007 | * Example implementation in vis type:
1008 | *
1009 | * function enter(self, data, callbacks) {
1010 | * var foo = self._g.selectAll('g.foobar')
1011 | * .data(data);
1012 | * foo.enter().append('g')
1013 | * .attr('class', 'foobar');
1014 | * self.foo = foo;
1015 | * }
1016 | */
1017 | _enter: function (vis, storage, data, className) {
1018 | var self = this,
1019 | callbacks = {
1020 | click: self._options.click,
1021 | mouseover: self._options.mouseover,
1022 | mouseout: self._options.mouseout
1023 | };
1024 | self._checkVisMethod(vis, 'enter');
1025 | vis.enter(self, storage, className, data, callbacks);
1026 | },
1027 |
1028 | /**
1029 | * Update the elements opened by the select method
1030 | *
1031 | * Required method
1032 | *
1033 | * Example implementation in vis type:
1034 | *
1035 | * function update(self, timing) {
1036 | * self.bars.transition().duration(timing)
1037 | * .attr('width', self.xScale2.rangeBand())
1038 | * .attr('height', function (d) {
1039 | * return self.yScale(d.y);
1040 | * });
1041 | * }
1042 | */
1043 | _update: function (vis, storage) {
1044 | var self = this;
1045 | self._checkVisMethod(vis, 'update');
1046 | vis.update(self, storage, self._options.timing);
1047 | },
1048 |
1049 | /**
1050 | * Remove or transition out the elements that no longer have data
1051 | *
1052 | * Required method
1053 | *
1054 | * Example implementation in vis type:
1055 | *
1056 | * function exit(self) {
1057 | * self.bars.exit().remove();
1058 | * }
1059 | */
1060 | _exit: function (vis, storage) {
1061 | var self = this;
1062 | self._checkVisMethod(vis, 'exit');
1063 | vis.exit(self, storage, self._options.timing);
1064 | },
1065 |
1066 | /**
1067 | * Destroy the current vis type (transition to new type)
1068 | *
1069 | * Required method
1070 | *
1071 | * Example implementation in vis type:
1072 | *
1073 | * function destroy(self, timing) {
1074 | * self.bars.transition().duration(timing)
1075 | * attr('height', 0);
1076 | * delete self.bars;
1077 | * }
1078 | */
1079 | _destroy: function (vis, storage) {
1080 | var self = this;
1081 | self._checkVisMethod(vis, 'destroy');
1082 | try {
1083 | vis.destroy(self, storage, self._options.timing);
1084 | } catch (e) {}
1085 | },
1086 |
1087 | /**
1088 | * Draw the visualization
1089 | */
1090 | _draw: function () {
1091 | var self = this,
1092 | o = self._options,
1093 | comp,
1094 | compKeys;
1095 |
1096 | self._noData = _.flatten(_.pluck(self._mainData, 'data')
1097 | .concat(_.pluck(self._compData, 'data'))).length === 0;
1098 |
1099 | self._updateScale();
1100 | self._drawAxes();
1101 |
1102 | self._enter(self._vis, self._mainStorage, self._mainData, '.main');
1103 | self._exit(self._vis, self._mainStorage);
1104 | self._update(self._vis, self._mainStorage);
1105 |
1106 | comp = _.chain(self._compData).groupBy(function (d) {
1107 | return d.type;
1108 | });
1109 | compKeys = comp.keys();
1110 |
1111 | // Find old comp vis items and remove any that no longer exist
1112 | _.each(self._compStorage, function (d, key) {
1113 | if (-1 === compKeys.indexOf(key).value()) {
1114 | var vis = _vis[key];
1115 | self._enter(vis, d, [], '.comp.' + key.replace(/\W+/g, ''));
1116 | self._exit(vis, d);
1117 | }
1118 | });
1119 |
1120 | comp.each(function (d, key) {
1121 | var vis = _vis[key], storage;
1122 | if (!self._compStorage.hasOwnProperty(key)) {
1123 | self._compStorage[key] = {};
1124 | }
1125 | storage = self._compStorage[key];
1126 | self._enter(vis, storage, d, '.comp.' + key.replace(/\W+/g, ''));
1127 | self._exit(vis, storage);
1128 | self._update(vis, storage);
1129 | });
1130 |
1131 | if (self._noData) {
1132 | o.empty(self, self._selector, self._mainData);
1133 | } else {
1134 | o.notempty(self, self._selector);
1135 | }
1136 | },
1137 |
1138 | /**
1139 | * Ensure drawing method exists
1140 | */
1141 | _checkVisMethod: function (vis, method) {
1142 | var self = this;
1143 | if (!vis[method]) {
1144 | throw 'Required method "' + method + '" not found on vis type "' +
1145 | self._type + '".';
1146 | }
1147 | }
1148 | });
1149 | if (typeof define === 'function' && define.amd && typeof define.amd === 'object') {
1150 | define(function () {
1151 | return xChart;
1152 | });
1153 | return;
1154 | }
1155 |
1156 | window.xChart = xChart;
1157 |
1158 | }());
1159 |
--------------------------------------------------------------------------------
/www/lib/jquery.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
2 | !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};o.fn=o.prototype={jquery:n,constructor:o,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},o.extend=o.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||o.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(o.isPlainObject(d)||(e=o.isArray(d)))?(e?(e=!1,f=c&&o.isArray(c)?c:[]):f=c&&o.isPlainObject(c)?c:{},g[b]=o.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},o.extend({expando:"jQuery"+(n+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===o.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isPlainObject:function(a){if("object"!==o.type(a)||a.nodeType||o.isWindow(a))return!1;try{if(a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=o.trim(a),a&&(1===a.indexOf("use strict")?(b=m.createElement("script"),b.text=a,m.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":k.call(a)},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?o.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),o.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||o.guid++,f):void 0},now:Date.now,support:l}),o.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=o.type(a);return"function"===c||o.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);o.find=t,o.expr=t.selectors,o.expr[":"]=o.expr.pseudos,o.unique=t.uniqueSort,o.text=t.getText,o.isXMLDoc=t.isXML,o.contains=t.contains;var u=o.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(o.isFunction(b))return o.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return o.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return o.filter(b,a,c);b=o.filter(b,a)}return o.grep(a,function(a){return g.call(b,a)>=0!==c})}o.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?o.find.matchesSelector(d,a)?[d]:[]:o.find.matches(a,o.grep(b,function(a){return 1===a.nodeType}))},o.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(o(a).filter(function(){for(b=0;c>b;b++)if(o.contains(e[b],this))return!0}));for(b=0;c>b;b++)o.find(a,e[b],d);return d=this.pushStack(c>1?o.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?o(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=o.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof o?b[0]:b,o.merge(this,o.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:m,!0)),v.test(c[1])&&o.isPlainObject(b))for(c in b)o.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=m.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=m,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):o.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(o):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),o.makeArray(a,this))};A.prototype=o.fn,y=o(m);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};o.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&o(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),o.fn.extend({has:function(a){var b=o(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(o.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?o(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&o.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?o.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(o(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(o.unique(o.merge(this.get(),o(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}o.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return o.dir(a,"parentNode")},parentsUntil:function(a,b,c){return o.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return o.dir(a,"nextSibling")},prevAll:function(a){return o.dir(a,"previousSibling")},nextUntil:function(a,b,c){return o.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return o.dir(a,"previousSibling",c)},siblings:function(a){return o.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return o.sibling(a.firstChild)},contents:function(a){return a.contentDocument||o.merge([],a.childNodes)}},function(a,b){o.fn[a]=function(c,d){var e=o.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=o.filter(d,e)),this.length>1&&(C[a]||o.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return o.each(a.match(E)||[],function(a,c){b[c]=!0}),b}o.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):o.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){o.each(b,function(b,c){var d=o.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&o.each(arguments,function(a,b){var c;while((c=o.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?o.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},o.extend({Deferred:function(a){var b=[["resolve","done",o.Callbacks("once memory"),"resolved"],["reject","fail",o.Callbacks("once memory"),"rejected"],["notify","progress",o.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return o.Deferred(function(c){o.each(b,function(b,f){var g=o.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&o.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?o.extend(a,d):d}},e={};return d.pipe=d.then,o.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&o.isFunction(a.promise)?e:0,g=1===f?a:o.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&o.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;o.fn.ready=function(a){return o.ready.promise().done(a),this},o.extend({isReady:!1,readyWait:1,holdReady:function(a){a?o.readyWait++:o.ready(!0)},ready:function(a){(a===!0?--o.readyWait:o.isReady)||(o.isReady=!0,a!==!0&&--o.readyWait>0||(H.resolveWith(m,[o]),o.fn.trigger&&o(m).trigger("ready").off("ready")))}});function I(){m.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),o.ready()}o.ready.promise=function(b){return H||(H=o.Deferred(),"complete"===m.readyState?setTimeout(o.ready):(m.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},o.ready.promise();var J=o.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===o.type(c)){e=!0;for(h in c)o.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,o.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(o(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};o.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=o.expando+Math.random()}K.uid=1,K.accepts=o.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,o.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(o.isEmptyObject(f))o.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,o.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{o.isArray(b)?d=b.concat(b.map(o.camelCase)):(e=o.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!o.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?o.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}o.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),o.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;
3 | while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=o.camelCase(d.slice(5)),P(f,d,e[d]));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=o.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),o.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||o.isArray(c)?d=L.access(a,b,o.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=o.queue(a,b),d=c.length,e=c.shift(),f=o._queueHooks(a,b),g=function(){o.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:o.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),o.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";l.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return m.activeElement}catch(a){}}o.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=o.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof o!==U&&o.event.triggered!==b.type?o.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n&&(l=o.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=o.event.special[n]||{},k=o.extend({type:n,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&o.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(n,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),o.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n){l=o.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||o.removeEvent(a,n,r.handle),delete i[n])}else for(n in i)o.event.remove(a,n+b[j],c,d,!0);o.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,p=[d||m],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||m,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+o.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[o.expando]?b:new o.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:o.makeArray(c,[b]),n=o.event.special[q]||{},e||!n.trigger||n.trigger.apply(d,c)!==!1)){if(!e&&!n.noBubble&&!o.isWindow(d)){for(i=n.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||m)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:n.bindType||q,l=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),l&&l.apply(g,c),l=k&&g[k],l&&l.apply&&o.acceptData(g)&&(b.result=l.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||n._default&&n._default.apply(p.pop(),c)!==!1||!o.acceptData(d)||k&&o.isFunction(d[q])&&!o.isWindow(d)&&(h=d[k],h&&(d[k]=null),o.event.triggered=q,d[q](),o.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=o.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=o.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=o.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((o.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?o(e,this).index(i)>=0:o.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return o.nodeName(a,"table")&&o.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)o.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=o.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&o.nodeName(a,b)?o.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}o.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=o.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||o.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,n=a.length;n>m;m++)if(e=a[m],e||0===e)if("object"===o.type(e))o.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>$2>")+h[2],j=h[0];while(j--)f=f.lastChild;o.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===o.inArray(e,d))&&(i=o.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f,g,h=o.event.special,i=0;void 0!==(c=a[i]);i++){if(o.acceptData(c)&&(f=c[L.expando],f&&(b=L.cache[f]))){if(d=Object.keys(b.events||{}),d.length)for(g=0;void 0!==(e=d[g]);g++)h[e]?o.event.remove(c,e):o.removeEvent(c,e,b.handle);L.cache[f]&&delete L.cache[f]}delete M.cache[c[M.expando]]}}}),o.fn.extend({text:function(a){return J(this,function(a){return void 0===a?o.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?o.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||o.cleanData(ob(c)),c.parentNode&&(b&&o.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(o.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return o.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(o.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,o.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,n=k-1,p=a[0],q=o.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(c=o.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=o.map(ob(c,"script"),kb),g=f.length;k>j;j++)h=c,j!==n&&(h=o.clone(h,!0,!0),g&&o.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,o.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&o.contains(i,h)&&(h.src?o._evalUrl&&o._evalUrl(h.src):o.globalEval(h.textContent.replace(hb,"")))}return this}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){o.fn[a]=function(a){for(var c,d=[],e=o(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),o(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d=o(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:o.css(d[0],"display");return d.detach(),e}function tb(a){var b=m,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||o("")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||o.contains(a.ownerDocument,a)||(g=o.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",e=m.documentElement,f=m.createElement("div"),g=m.createElement("div");g.style.backgroundClip="content-box",g.cloneNode(!0).style.backgroundClip="",l.clearCloneStyle="content-box"===g.style.backgroundClip,f.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",f.appendChild(g);function h(){g.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",e.appendChild(f);var d=a.getComputedStyle(g,null);b="1%"!==d.top,c="4px"===d.width,e.removeChild(f)}a.getComputedStyle&&o.extend(l,{pixelPosition:function(){return h(),b},boxSizingReliable:function(){return null==c&&h(),c},reliableMarginRight:function(){var b,c=g.appendChild(m.createElement("div"));return c.style.cssText=g.style.cssText=d,c.style.marginRight=c.style.width="0",g.style.width="1px",e.appendChild(f),b=!parseFloat(a.getComputedStyle(c,null).marginRight),e.removeChild(f),g.innerHTML="",b}})}(),o.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:0,fontWeight:400},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=o.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=o.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=o.css(a,"border"+R[f]+"Width",!0,e))):(g+=o.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=o.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===o.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(l.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):f[g]||(e=S(d),(c&&"none"!==c||!e)&&L.set(d,"olddisplay",e?c:o.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}o.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=o.camelCase(b),i=a.style;return b=o.cssProps[h]||(o.cssProps[h]=Fb(i,h)),g=o.cssHooks[b]||o.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(o.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||o.cssNumber[h]||(c+="px"),l.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]="",i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=o.camelCase(b);return b=o.cssProps[h]||(o.cssProps[h]=Fb(a.style,h)),g=o.cssHooks[b]||o.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||o.isNumeric(f)?f||0:e):e}}),o.each(["height","width"],function(a,b){o.cssHooks[b]={get:function(a,c,d){return c?0===a.offsetWidth&&zb.test(o.css(a,"display"))?o.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===o.css(a,"boxSizing",!1,e),e):0)}}}),o.cssHooks.marginRight=yb(l.reliableMarginRight,function(a,b){return b?o.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),o.each({margin:"",padding:"",border:"Width"},function(a,b){o.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(o.cssHooks[a+b].set=Gb)}),o.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(o.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=o.css(a,b[g],!1,d);return f}return void 0!==c?o.style(a,b,c):o.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?o(this).show():o(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}o.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(o.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?o.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=o.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){o.fx.step[a.prop]?o.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[o.cssProps[a.prop]]||o.cssHooks[a.prop])?o.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},o.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},o.fx=Kb.prototype.init,o.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(o.cssNumber[a]?"":"px"),g=(o.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(o.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,o.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=o.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k=this,l={},m=a.style,n=a.nodeType&&S(a),p=L.get(a,"fxshow");c.queue||(h=o._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,k.always(function(){k.always(function(){h.unqueued--,o.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],j=o.css(a,"display"),"none"===j&&(j=tb(a.nodeName)),"inline"===j&&"none"===o.css(a,"float")&&(m.display="inline-block")),c.overflow&&(m.overflow="hidden",k.always(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(n?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;n=!0}l[d]=p&&p[d]||o.style(a,d)}if(!o.isEmptyObject(l)){p?"hidden"in p&&(n=p.hidden):p=L.access(a,"fxshow",{}),f&&(p.hidden=!n),n?o(a).show():k.done(function(){o(a).hide()}),k.done(function(){var b;L.remove(a,"fxshow");for(b in l)o.style(a,b,l[b])});for(d in l)g=Ub(n?p[d]:0,d,k),d in p||(p[d]=g.start,n&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=o.camelCase(c),e=b[d],f=a[c],o.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=o.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=o.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:o.extend({},b),opts:o.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=o.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return o.map(k,Ub,j),o.isFunction(j.opts.start)&&j.opts.start.call(a,j),o.fx.timer(o.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}o.Animation=o.extend(Xb,{tweener:function(a,b){o.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),o.speed=function(a,b,c){var d=a&&"object"==typeof a?o.extend({},a):{complete:c||!c&&b||o.isFunction(a)&&a,duration:a,easing:c&&b||b&&!o.isFunction(b)&&b};return d.duration=o.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in o.fx.speeds?o.fx.speeds[d.duration]:o.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){o.isFunction(d.old)&&d.old.call(this),d.queue&&o.dequeue(this,d.queue)},d},o.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=o.isEmptyObject(a),f=o.speed(b,c,d),g=function(){var b=Xb(this,o.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=o.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&o.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=o.timers,g=d?d.length:0;for(c.finish=!0,o.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),o.each(["toggle","show","hide"],function(a,b){var c=o.fn[b];o.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),o.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){o.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),o.timers=[],o.fx.tick=function(){var a,b=0,c=o.timers;for(Lb=o.now();b1)},removeAttr:function(a){return this.each(function(){o.removeAttr(this,a)})}}),o.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?o.prop(a,b,c):(1===f&&o.isXMLDoc(a)||(b=b.toLowerCase(),d=o.attrHooks[b]||(o.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=o.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void o.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=o.propFix[c]||c,o.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!l.radioValue&&"radio"===b&&o.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?o.removeAttr(a,c):a.setAttribute(c,c),c}},o.each(o.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||o.find.attr;$b[b]=function(a,b,d){var e,f;
4 | return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;o.fn.extend({prop:function(a,b){return J(this,o.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[o.propFix[a]||a]})}}),o.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!o.isXMLDoc(a),f&&(b=o.propFix[b]||b,e=o.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),l.optSelected||(o.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;o.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=o.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?o.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(o.isFunction(a)?function(c){o(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=o(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;o.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=o.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,o(this).val()):a,null==e?e="":"number"==typeof e?e+="":o.isArray(e)&&(e=o.map(e,function(a){return null==a?"":a+""})),b=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=o.valHooks[e.type]||o.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),o.extend({valHooks:{select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(l.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&o.nodeName(c.parentNode,"optgroup"))){if(b=o(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=o.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=o.inArray(o(d).val(),f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(a,b){return o.isArray(b)?a.checked=o.inArray(o(a).val(),b)>=0:void 0}},l.checkOn||(o.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),o.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){o.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),o.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=o.now(),dc=/\?/;o.parseJSON=function(a){return JSON.parse(a+"")},o.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&o.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=m.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(o.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,o.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=o.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&o.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":o.parseJSON,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,o.ajaxSettings),b):tc(o.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=o.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?o(l):o.event,n=o.Deferred(),p=o.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(n.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=o.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=o.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===o.active++&&o.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(o.lastModified[d]&&v.setRequestHeader("If-Modified-Since",o.lastModified[d]),o.etag[d]&&v.setRequestHeader("If-None-Match",o.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(o.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(o.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?n.resolveWith(l,[r,x,v]):n.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--o.active||o.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return o.get(a,b,c,"json")},getScript:function(a,b){return o.get(a,void 0,b,"script")}}),o.each(["get","post"],function(a,b){o[b]=function(a,c,d,e){return o.isFunction(c)&&(e=e||d,d=c,c=void 0),o.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){o.fn[b]=function(a){return this.on(b,a)}}),o._evalUrl=function(a){return o.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},o.fn.extend({wrapAll:function(a){var b;return o.isFunction(a)?this.each(function(b){o(this).wrapAll(a.call(this,b))}):(this[0]&&(b=o(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(o.isFunction(a)?function(b){o(this).wrapInner(a.call(this,b))}:function(){var b=o(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=o.isFunction(a);return this.each(function(c){o(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){o.nodeName(this,"body")||o(this).replaceWith(this.childNodes)}).end()}}),o.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},o.expr.filters.visible=function(a){return!o.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(o.isArray(b))o.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==o.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}o.param=function(a,b){var c,d=[],e=function(a,b){b=o.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=o.ajaxSettings&&o.ajaxSettings.traditional),o.isArray(a)||a.jquery&&!o.isPlainObject(a))o.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=o.prop(this,"elements");return a?o.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!o(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=o(this).val();return null==c?null:o.isArray(c)?o.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),o.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=o.ajaxSettings.xhr();a.ActiveXObject&&o(a).on("unload",function(){for(var a in Dc)Dc[a]()}),l.cors=!!Fc&&"withCredentials"in Fc,l.ajax=Fc=!!Fc,o.ajaxTransport(function(a){var b;return l.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort"),f.send(a.hasContent&&a.data||null)},abort:function(){b&&b()}}:void 0}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return o.globalEval(a),a}}}),o.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),o.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=o("