yeqs_jquery 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/Gemfile +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +107 -0
  4. data/Rakefile +40 -0
  5. data/VERSION +1 -0
  6. data/app/helpers/highcharts_helper.rb +41 -0
  7. data/app/helpers/include_helper.rb +23 -0
  8. data/lib/generators/yeqs/jquery/USAGE +8 -0
  9. data/lib/generators/yeqs/jquery/jquery_generator.rb +17 -0
  10. data/lib/yeqs_jquery.rb +7 -0
  11. data/lib/yeqs_jquery/engine.rb +13 -0
  12. data/lib/yeqs_jquery/highchart.rb +110 -0
  13. data/public/components/jquery/jquery-1.4.2.min.js +154 -0
  14. data/public/components/jqueryhighcharts/graphics/skies.jpg +0 -0
  15. data/public/components/jqueryhighcharts/graphics/snow.png +0 -0
  16. data/public/components/jqueryhighcharts/graphics/sun.png +0 -0
  17. data/public/components/jqueryhighcharts/js/highcharts.js +132 -0
  18. data/public/components/jqueryhighcharts/js/highcharts.src.js +8585 -0
  19. data/public/components/jqueryhighcharts/js/modules/exporting.js +20 -0
  20. data/public/components/jqueryhighcharts/js/modules/exporting.src.js +609 -0
  21. data/public/components/jqueryrails/rails.js +127 -0
  22. data/public/components/jquerytools/jquery.tools.min.js +114 -0
  23. data/public/components/jqueryui/css/smoothness/images/ui-anim_basic_16x16.gif +0 -0
  24. data/public/components/jqueryui/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  25. data/public/components/jqueryui/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  26. data/public/components/jqueryui/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  27. data/public/components/jqueryui/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  28. data/public/components/jqueryui/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  29. data/public/components/jqueryui/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  30. data/public/components/jqueryui/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  31. data/public/components/jqueryui/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  32. data/public/components/jqueryui/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  33. data/public/components/jqueryui/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  34. data/public/components/jqueryui/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  35. data/public/components/jqueryui/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  36. data/public/components/jqueryui/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  37. data/public/components/jqueryui/css/smoothness/jquery-ui-1.8.2.custom.css +489 -0
  38. data/public/components/jqueryui/js/jquery-ui-1.8.2.custom.min.js +1012 -0
  39. data/yeqs_jquery.gemspec +22 -0
  40. metadata +123 -0
@@ -0,0 +1,20 @@
1
+ /*
2
+ Highcharts JS v2.0.1 (2010-07-18)
3
+ Exporting module
4
+
5
+ (c) 2010 Torstein H�nsi
6
+
7
+ License: www.highcharts.com/license
8
+ */
9
+ (function(){var i=Highcharts,F=i.Chart,z=i.addEvent,u=i.defaultOptions,n=i.createElement,G=i.discardElement,A=i.css,D=i.merge,o=i.each,p=i.extend;u=Math;var J=u.max,q=document,K=window,v="M",w="L",x="div",L="hidden",B="none",M="highcharts-",H="absolute",l="px";u=i.setOptions({lang:{downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",exportButtonTitle:"Export to raster or vector image",printButtonTitle:"Print the chart"}});
10
+ u.navigation={menuStyle:{border:"1px solid #A0A0A0",background:"#FFFFFF"},menuItemStyle:{padding:"0 5px",background:B,color:"#303030"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{align:"right",backgroundColor:{linearGradient:[0,0,0,20],stops:[[0.4,"#F7F7F7"],[0.6,"#E3E3E3"]]},borderColor:"#B0B0B0",borderRadius:3,borderWidth:1,height:20,hoverBorderColor:"#909090",hoverSymbolFill:"#81A7CF",hoverSymbolStroke:"#4572A5",symbolFill:"#E0E0E0",symbolStroke:"#A0A0A0",symbolX:11.5,
11
+ symbolY:10.5,verticalAlign:"top",width:24,y:10}};u.exporting={type:"image/png",url:"http://export.highcharts.com/",width:800,buttons:{exportButton:{symbol:"exportIcon",x:-10,symbolFill:"#A8BF77",hoverSymbolFill:"#768F3E",_titleKey:"exportButtonTitle",menuItems:[{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",
12
+ onclick:function(){this.exportChart({type:"image/svg+xml"})}}]},printButton:{symbol:"printIcon",x:-36,symbolFill:"#B5C9DF",hoverSymbolFill:"#779ABF",_titleKey:"printButtonTitle",onclick:function(){this.print()}}}};p(F.prototype,{getSVG:function(b){var c=this,a,f,d=D(c.options,b);if(!q.createElementNS)q.createElementNS=function(h,e){var g=q.createElement(e);g.getBBox=function(){return c.renderer.Element.prototype.getBBox.apply({element:g})};return g};a=n(x,null,{position:H,top:"-9999em",width:c.chartWidth+
13
+ l,height:c.chartHeight+l},q.body);p(d.chart,{renderTo:a,renderer:"SVG"});d.exporting.enabled=false;d.chart.plotBackgroundImage=null;o(d.series,function(h){h.animation=false;o(h.data,function(e){e&&e.marker&&/^url\(/.test(e.marker.symbol)&&delete e.marker.symbol})});b=new Highcharts.Chart(d);f=a.getElementsByTagName(x)[0].innerHTML;d=null;b.destroy();G(a);return f=f.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/isTracker="[^"]+"/g,
14
+ "").replace(/url\([^#]+#/g,"url(#").replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" ]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:path/g,"path").replace(/style="([^"]+)"/g,function(h){return h.toLowerCase()})},exportChart:function(b,c){var a,f=this,d=f.getSVG(c);b=D(f.options.exporting,b);a=n("form",{method:"post",action:b.url},{display:B},q.body);o(["filename","type","width","svg"],function(h){n("input",{type:L,name:h,value:{filename:b.filename||"chart",type:b.type,width:b.width,
15
+ svg:d}[h]},null,a)});a.submit();G(a)},print:function(){var b=this,c=b.container,a,f=[],d=c.parentNode,h=q.body,e=h.childNodes;if(!b.isPrinting){b.isPrinting=true;o(e,function(g){if(g.nodeType==1){f[a]=g.style.display;g.style.display=B}});h.appendChild(c);K.print();setTimeout(function(){d.appendChild(c);o(e,function(g){if(g.nodeType==1)g.style.display=f[a]});b.isPrinting=false},1E3)}},contextMenu:function(b,c,a,f,d,h){var e=this,g=e.options.navigation,m=g.menuItemStyle,r=e.chartWidth,s=e.chartHeight,
16
+ t="cache-"+b,j=e[t],k=J(d,h),y="3px 3px 10px #888",I,E;if(!j){e[t]=j=n(x,{className:M+b},{position:H,zIndex:1E3,padding:k+l},e.container);I=n(x,null,p({MozBoxShadow:y,WebkitBoxShadow:y},g.menuStyle),j);E=function(){A(j,{display:B})};z(j,"mouseleave",E);o(c,function(C){if(C)n(x,{onclick:function(){E();C.onclick.apply(e,arguments)},onmouseover:function(){A(this,g.menuItemHoverStyle)},onmouseout:function(){A(this,m)},innerHTML:C.text||i.getOptions().lang[C.textKey]},p({cursor:"pointer"},m),I)});e.exportMenuWidth=
17
+ j.offsetWidth;e.exportMenuHeigh=j.offsetHeight}b={display:"block"};if(a+e.exportMenuWidth>r)b.right=r-a-d-k+l;else b.left=a-k+l;if(f+h+e.exportMenuWidth>s)b.bottom=s-f-k+l;else b.top=f+h-k+l;A(j,b)},addButton:function(b){function c(){j.attr(y);t.attr(k)}var a=this,f=a.renderer,d=D(a.options.navigation.buttonOptions,b),h=d.onclick,e=d.menuItems;b=a.getAlignment(d);var g=b.x,m=b.y,r=d.width,s=d.height,t,j;b=d.borderWidth;var k={stroke:d.borderColor},y={stroke:d.symbolStroke,fill:d.symbolFill};if(d.enabled!==
18
+ false){t=f.rect(0,0,r,s,d.borderRadius,b).translate(g,m).attr(p({fill:d.backgroundColor,"stroke-width":b,zIndex:19},k)).add();b=f.rect(g,m,r,s,0).attr({fill:"rgba(255, 255, 255, 0.001)",title:i.getOptions().lang[d._titleKey],zIndex:21}).css({cursor:"pointer"}).on("mouseover",function(){j.attr({stroke:d.hoverSymbolStroke,fill:d.hoverSymbolFill});t.attr({stroke:d.hoverBorderColor})}).on("mouseout",c).add();z(b.element,"click",c);if(e)h=function(){a.contextMenu("export-menu",e,g,m,r,s)};z(b.element,
19
+ "click",function(){h.apply(a,arguments)});j=f.symbol(d.symbol,g+d.symbolX,m+d.symbolY,(d.symbolSize||12)/2).attr(p(y,{"stroke-width":d.symbolStrokeWidth||1,zIndex:20})).add()}}});i.Renderer.prototype.symbols.exportIcon=function(b,c,a){return[v,b-a,c+a,w,b+a,c+a,b+a,c+a*0.5,b-a,c+a*0.5,"Z",v,b,c+a*0.5,w,b-a*0.5,c-a/3,b-a/6,c-a/3,b-a/6,c-a,b+a/6,c-a,b+a/6,c-a/3,b+a*0.5,c-a/3,"Z"]};i.Renderer.prototype.symbols.printIcon=function(b,c,a){return[v,b-a,c+a*0.5,w,b+a,c+a*0.5,b+a,c-a/3,b-a,c-a/3,"Z",v,b-a*
20
+ 0.5,c-a/3,w,b-a*0.5,c-a,b+a*0.5,c-a,b+a*0.5,c-a/3,"Z",v,b-a*0.5,c+a*0.5,w,b-a*0.75,c+a,b+a*0.75,c+a,b+a*0.5,c+a*0.5,"Z"]};z(F.prototype,"load",function(b){b=b.target;var c,a=b.options.exporting,f=a.buttons;if(a.enabled!==false)for(c in f)b.addButton(f[c])})})();
@@ -0,0 +1,609 @@
1
+ /**
2
+ * @license Highcharts JS v2.0.1 (2010-07-18)
3
+ * Exporting module
4
+ *
5
+ * (c) 2010 Torstein Hønsi
6
+ *
7
+ * License: www.highcharts.com/license
8
+ */
9
+
10
+ // JSLint options:
11
+ /*global Highcharts, document, window, Math, setTimeout */
12
+
13
+ (function() { // encapsulate
14
+
15
+ // create shortcuts
16
+ var HC = Highcharts,
17
+ Chart = HC.Chart,
18
+ addEvent = HC.addEvent,
19
+ defaultOptions = HC.defaultOptions,
20
+ createElement = HC.createElement,
21
+ discardElement = HC.discardElement,
22
+ css = HC.css,
23
+ merge = HC.merge,
24
+ each = HC.each,
25
+ extend = HC.extend,
26
+ math = Math,
27
+ mathMax = math.max,
28
+ doc = document,
29
+ win = window,
30
+ M = 'M',
31
+ L = 'L',
32
+ DIV = 'div',
33
+ HIDDEN = 'hidden',
34
+ NONE = 'none',
35
+ PREFIX = 'highcharts-',
36
+ ABSOLUTE = 'absolute',
37
+ PX = 'px',
38
+
39
+
40
+
41
+ // Add language and get the defaultOptions
42
+ defaultOptions = HC.setOptions({
43
+ lang: {
44
+ downloadPNG: 'Download PNG image',
45
+ downloadJPEG: 'Download JPEG image',
46
+ downloadPDF: 'Download PDF document',
47
+ downloadSVG: 'Download SVG vector image',
48
+ exportButtonTitle: 'Export to raster or vector image',
49
+ printButtonTitle: 'Print the chart'
50
+ }
51
+ });
52
+
53
+ // Buttons and menus are collected in a separate config option set called 'navigation'.
54
+ // This can be extended later to add control buttons like zoom and pan right click menus.
55
+ defaultOptions.navigation = {
56
+ menuStyle: {
57
+ border: '1px solid #A0A0A0',
58
+ background: '#FFFFFF'
59
+ },
60
+ menuItemStyle: {
61
+ padding: '0 5px',
62
+ background: NONE,
63
+ color: '#303030'
64
+ },
65
+ menuItemHoverStyle: {
66
+ background: '#4572A5',
67
+ color: '#FFFFFF'
68
+ },
69
+
70
+ buttonOptions: {
71
+ align: 'right',
72
+ backgroundColor: {
73
+ linearGradient: [0, 0, 0, 20],
74
+ stops: [
75
+ [0.4, '#F7F7F7'],
76
+ [0.6, '#E3E3E3']
77
+ ]
78
+ },
79
+ borderColor: '#B0B0B0',
80
+ borderRadius: 3,
81
+ borderWidth: 1,
82
+ //enabled: true,
83
+ height: 20,
84
+ hoverBorderColor: '#909090',
85
+ hoverSymbolFill: '#81A7CF',
86
+ hoverSymbolStroke: '#4572A5',
87
+ symbolFill: '#E0E0E0',
88
+ //symbolSize: 12,
89
+ symbolStroke: '#A0A0A0',
90
+ //symbolStrokeWidth: 1,
91
+ symbolX: 11.5,
92
+ symbolY: 10.5,
93
+ verticalAlign: 'top',
94
+ width: 24,
95
+ y: 10
96
+ }
97
+ };
98
+
99
+
100
+
101
+ // Add the export related options
102
+ defaultOptions.exporting = {
103
+ //enabled: true,
104
+ //filename: 'chart',
105
+ type: 'image/png',
106
+ url: 'http://export.highcharts.com/',
107
+ width: 800,
108
+ buttons: {
109
+ exportButton: {
110
+ //enabled: true,
111
+ symbol: 'exportIcon',
112
+ x: -10,
113
+ symbolFill: '#A8BF77',
114
+ hoverSymbolFill: '#768F3E',
115
+ _titleKey: 'exportButtonTitle',
116
+ menuItems: [{
117
+ textKey: 'downloadPNG',
118
+ onclick: function() {
119
+ this.exportChart();
120
+ }
121
+ }, {
122
+ textKey: 'downloadJPEG',
123
+ onclick: function() {
124
+ this.exportChart({
125
+ type: 'image/jpeg'
126
+ });
127
+ }
128
+ }, {
129
+ textKey: 'downloadPDF',
130
+ onclick: function() {
131
+ this.exportChart({
132
+ type: 'application/pdf'
133
+ });
134
+ }
135
+ }, {
136
+ textKey: 'downloadSVG',
137
+ onclick: function() {
138
+ this.exportChart({
139
+ type: 'image/svg+xml'
140
+ });
141
+ }
142
+ }/*, {
143
+ text: 'View SVG',
144
+ onclick: function() {
145
+ var svg = this.getSVG()
146
+ .replace(/</g, '\n&lt;')
147
+ .replace(/>/g, '&gt;');
148
+
149
+ doc.body.innerHTML = '<pre>'+ svg +'</pre>';
150
+ }
151
+ }*/]
152
+
153
+ },
154
+ printButton: {
155
+ //enabled: true,
156
+ symbol: 'printIcon',
157
+ x: -36,
158
+ symbolFill: '#B5C9DF',
159
+ hoverSymbolFill: '#779ABF',
160
+ _titleKey: 'printButtonTitle',
161
+ onclick: function() {
162
+ this.print();
163
+ }
164
+ }
165
+ }
166
+ };
167
+
168
+
169
+
170
+ extend (Chart.prototype, {
171
+ /**
172
+ * Return an SVG representation of the chart
173
+ *
174
+ * @param additionalOptions {Object} Additional chart options for the generated SVG representation
175
+ */
176
+ getSVG: function(additionalOptions) {
177
+ var chart = this,
178
+ chartCopy,
179
+ sandbox,
180
+ svg,
181
+ options = merge(chart.options, additionalOptions); // copy the options and add extra options
182
+
183
+ // IE compatibility hack for generating SVG content that it doesn't really understand
184
+ if (!doc.createElementNS) {
185
+ doc.createElementNS = function(ns, tagName) {
186
+ var elem = doc.createElement(tagName);
187
+ elem.getBBox = function() {
188
+ return chart.renderer.Element.prototype.getBBox.apply({ element: elem });
189
+ };
190
+ return elem;
191
+ };
192
+ }
193
+
194
+ // create a sandbox where a new chart will be generated
195
+ sandbox = createElement(DIV, null, {
196
+ position: ABSOLUTE,
197
+ top: '-9999em',
198
+ width: chart.chartWidth + PX,
199
+ height: chart.chartHeight + PX
200
+ }, doc.body);
201
+
202
+ // override some options
203
+ extend(options.chart, {
204
+ renderTo: sandbox,
205
+ renderer: 'SVG'
206
+ });
207
+ options.exporting.enabled = false; // hide buttons in print
208
+ options.chart.plotBackgroundImage = null; // the converter doesn't handle images
209
+ each (options.series, function(serie) {
210
+ serie.animation = false;// turn off animation
211
+
212
+ each (serie.data, function(point) { // turn off symbols
213
+ if (point && point.marker && /^url\(/.test(point.marker.symbol)) {
214
+ delete point.marker.symbol;
215
+ }
216
+ });
217
+ });
218
+
219
+
220
+ // generate the chart copy
221
+ chartCopy = new Highcharts.Chart(options);
222
+
223
+ // get the SVG from the container's innerHTML
224
+ svg = sandbox.getElementsByTagName(DIV)[0].innerHTML;
225
+
226
+ // free up memory
227
+ options = null;
228
+ chartCopy.destroy();
229
+ discardElement(sandbox);
230
+
231
+ // sanitize
232
+ svg = svg.
233
+ replace(/zIndex="[^"]+"/g, '').
234
+ replace(/isShadow="[^"]+"/g, '').
235
+ replace(/symbolName="[^"]+"/g, '').
236
+ replace(/jQuery[0-9]+="[^"]+"/g, '').
237
+ replace(/isTracker="[^"]+"/g, '').
238
+ replace(/url\([^#]+#/g, 'url(#').
239
+
240
+ // IE specific
241
+ replace(/id=([^" >]+)/g, 'id="$1"').
242
+ replace(/class=([^" ]+)/g, 'class="$1"').
243
+ replace(/ transform /g, ' ').
244
+ replace(/:path/g, 'path').
245
+ replace(/style="([^"]+)"/g, function(s) {
246
+ return s.toLowerCase();
247
+ });
248
+
249
+ return svg;
250
+ },
251
+
252
+ /**
253
+ * Submit the SVG representation of the chart to the server
254
+ * @param {Object} options Exporting options. Possible members are url, type and width.
255
+ * @param {Object} chartOptions Additional chart options for the SVG representation of the chart
256
+ */
257
+ exportChart: function(options, chartOptions) {
258
+ var form,
259
+ chart = this,
260
+ svg = chart.getSVG(chartOptions);
261
+
262
+ // merge the options
263
+ options = merge(chart.options.exporting, options);
264
+
265
+ // create the form
266
+ form = createElement('form', {
267
+ method: 'post',
268
+ action: options.url
269
+ }, {
270
+ display: NONE
271
+ }, doc.body);
272
+
273
+ // add the values
274
+ each(['filename', 'type', 'width', 'svg'], function(name) {
275
+ createElement('input', {
276
+ type: HIDDEN,
277
+ name: name,
278
+ value: {
279
+ filename: options.filename || 'chart',
280
+ type: options.type,
281
+ width: options.width,
282
+ svg: svg
283
+ }[name]
284
+ }, null, form);
285
+ });
286
+
287
+ // submit
288
+ form.submit();
289
+
290
+ // clean up
291
+ discardElement(form);
292
+ },
293
+
294
+ /**
295
+ * Print the chart
296
+ */
297
+ print: function() {
298
+
299
+ var chart = this,
300
+ container = chart.container,
301
+ i,
302
+ origDisplay = [],
303
+ origParent = container.parentNode,
304
+ body = doc.body,
305
+ childNodes = body.childNodes;
306
+
307
+ if (chart.isPrinting) { // block the button while in printing mode
308
+ return;
309
+ }
310
+
311
+ chart.isPrinting = true;
312
+
313
+ // hide all body content
314
+ each(childNodes, function(node) {
315
+ if (node.nodeType == 1) {
316
+ origDisplay[i] = node.style.display;
317
+ node.style.display = NONE;
318
+ }
319
+ });
320
+
321
+ // pull out the chart
322
+ body.appendChild(container);
323
+
324
+ // print
325
+ win.print();
326
+
327
+ // allow the browser to prepare before reverting
328
+ setTimeout(function() {
329
+
330
+ // put the chart back in
331
+ origParent.appendChild(container);
332
+
333
+ // restore all body content
334
+ each (childNodes, function(node) {
335
+ if (node.nodeType == 1) {
336
+ node.style.display = origDisplay[i];
337
+ }
338
+ });
339
+
340
+ chart.isPrinting = false;
341
+
342
+ }, 1000);
343
+
344
+ },
345
+
346
+ /**
347
+ * Display a popup menu for choosing the export type
348
+ *
349
+ * @param {String} name An identifier for the menu
350
+ * @param {Array} items A collection with text and onclicks for the items
351
+ * @param {Number} x The x position of the opener button
352
+ * @param {Number} y The y position of the opener button
353
+ * @param {Number} width The width of the opener button
354
+ * @param {Number} height The height of the opener button
355
+ */
356
+ contextMenu: function(name, items, x, y, width, height) {
357
+ var chart = this,
358
+ navOptions = chart.options.navigation,
359
+ menuItemStyle = navOptions.menuItemStyle,
360
+ chartWidth = chart.chartWidth,
361
+ chartHeight = chart.chartHeight,
362
+ cacheName = 'cache-'+ name,
363
+ menu = chart[cacheName],
364
+ menuPadding = mathMax(width, height), // for mouse leave detection
365
+ boxShadow = '3px 3px 10px #888',
366
+ innerMenu,
367
+ hide,
368
+ menuStyle;
369
+
370
+ // create the menu only the first time
371
+ if (!menu) {
372
+
373
+ // create a HTML element above the SVG
374
+ chart[cacheName] = menu = createElement(DIV, {
375
+ className: PREFIX + name
376
+ }, {
377
+ position: ABSOLUTE,
378
+ zIndex: 1000,
379
+ padding: menuPadding + PX
380
+ }, chart.container);
381
+
382
+ innerMenu = createElement(DIV, null,
383
+ extend({
384
+ MozBoxShadow: boxShadow,
385
+ WebkitBoxShadow: boxShadow
386
+ }, navOptions.menuStyle) , menu);
387
+
388
+ hide = function() {
389
+ css(menu, { display: NONE });
390
+ };
391
+ addEvent(menu, 'mouseleave', hide);
392
+
393
+ // create the items
394
+ each(items, function(item) {
395
+ if (item) {
396
+ createElement(DIV, {
397
+ onclick: function() {
398
+ hide();
399
+ item.onclick.apply(chart, arguments);
400
+ },
401
+ onmouseover: function() {
402
+ css(this, navOptions.menuItemHoverStyle);
403
+ },
404
+ onmouseout: function() {
405
+ css(this, menuItemStyle);
406
+ },
407
+ innerHTML: item.text || HC.getOptions().lang[item.textKey]
408
+ }, extend({
409
+ cursor: 'pointer'
410
+ }, menuItemStyle), innerMenu);
411
+ }
412
+ });
413
+
414
+ chart.exportMenuWidth = menu.offsetWidth;
415
+ chart.exportMenuHeigh = menu.offsetHeight;
416
+ }
417
+
418
+ menuStyle = { display: 'block' };
419
+
420
+ // if outside right, right align it
421
+ if (x + chart.exportMenuWidth > chartWidth) {
422
+ menuStyle.right = (chartWidth - x - width - menuPadding) + PX;
423
+ } else {
424
+ menuStyle.left = (x - menuPadding) + PX;
425
+ }
426
+ // if outside bottom, bottom align it
427
+ if (y + height + chart.exportMenuWidth > chartHeight) {
428
+ menuStyle.bottom = (chartHeight - y - menuPadding) + PX;
429
+ } else {
430
+ menuStyle.top = (y + height - menuPadding) + PX;
431
+ }
432
+
433
+ css(menu, menuStyle);
434
+ },
435
+
436
+ /**
437
+ * Add the export button to the chart
438
+ */
439
+ addButton: function(options) {
440
+ var chart = this,
441
+ renderer = chart.renderer,
442
+ btnOptions = merge(chart.options.navigation.buttonOptions, options),
443
+ onclick = btnOptions.onclick,
444
+ menuItems = btnOptions.menuItems,
445
+ position = chart.getAlignment(btnOptions),
446
+ buttonLeft = position.x,
447
+ buttonTop = position.y,
448
+ buttonWidth = btnOptions.width,
449
+ buttonHeight = btnOptions.height,
450
+ box,
451
+ symbol,
452
+ button,
453
+ borderWidth = btnOptions.borderWidth,
454
+ boxAttr = {
455
+ stroke: btnOptions.borderColor
456
+
457
+ },
458
+ symbolAttr = {
459
+ stroke: btnOptions.symbolStroke,
460
+ fill: btnOptions.symbolFill
461
+ };
462
+
463
+ if (btnOptions.enabled === false) {
464
+ return;
465
+ }
466
+
467
+ // element to capture the click
468
+ function revert() {
469
+ symbol.attr(symbolAttr);
470
+ box.attr(boxAttr);
471
+ }
472
+
473
+ // the box border
474
+ box = renderer.rect(
475
+ 0,
476
+ 0,
477
+ buttonWidth,
478
+ buttonHeight,
479
+ btnOptions.borderRadius,
480
+ borderWidth
481
+ )
482
+ .translate(buttonLeft, buttonTop) // to allow gradients
483
+ .attr(extend({
484
+ fill: btnOptions.backgroundColor,
485
+ 'stroke-width': borderWidth,
486
+ zIndex: 19
487
+ }, boxAttr)).add();
488
+
489
+ // the invisible element to track the clicks
490
+ button = renderer.rect(
491
+ buttonLeft,
492
+ buttonTop,
493
+ buttonWidth,
494
+ buttonHeight,
495
+ 0
496
+ ).attr({
497
+ fill: 'rgba(255, 255, 255, 0.001)',
498
+ title: HC.getOptions().lang[btnOptions._titleKey],
499
+ zIndex: 21
500
+ }).css({
501
+ cursor: 'pointer'
502
+ })
503
+ .on('mouseover', function() {
504
+ symbol.attr({
505
+ stroke: btnOptions.hoverSymbolStroke,
506
+ fill: btnOptions.hoverSymbolFill
507
+ });
508
+ box.attr({
509
+ stroke: btnOptions.hoverBorderColor
510
+ });
511
+ })
512
+ .on('mouseout', revert)
513
+ .add();
514
+
515
+ addEvent(button.element, 'click', revert);
516
+
517
+ // add the click event
518
+ if (menuItems) {
519
+ onclick = function(e) {
520
+ chart.contextMenu('export-menu', menuItems, buttonLeft, buttonTop, buttonWidth, buttonHeight);
521
+ };
522
+ }
523
+ addEvent(button.element, 'click', function() {
524
+ onclick.apply(chart, arguments);
525
+ });
526
+
527
+ // the icon
528
+ symbol = renderer.symbol(
529
+ btnOptions.symbol,
530
+ buttonLeft + btnOptions.symbolX,
531
+ buttonTop + btnOptions.symbolY,
532
+ (btnOptions.symbolSize || 12) / 2
533
+ )
534
+ .attr(extend(symbolAttr, {
535
+ 'stroke-width': btnOptions.symbolStrokeWidth || 1,
536
+ zIndex: 20
537
+ })).add();
538
+
539
+
540
+
541
+ }
542
+ });
543
+
544
+ // Create the export icon
545
+ HC.Renderer.prototype.symbols.exportIcon = function(x, y, radius) {
546
+ return [
547
+ M, // the disk
548
+ x - radius, y + radius,
549
+ L,
550
+ x + radius, y + radius,
551
+ x + radius, y + radius * 0.5,
552
+ x - radius, y + radius * 0.5,
553
+ 'Z',
554
+ M, // the arrow
555
+ x, y + radius * 0.5,
556
+ L,
557
+ x - radius * 0.5, y - radius / 3,
558
+ x - radius / 6, y - radius / 3,
559
+ x - radius / 6, y - radius,
560
+ x + radius / 6, y - radius,
561
+ x + radius / 6, y - radius / 3,
562
+ x + radius * 0.5, y - radius / 3,
563
+ 'Z'
564
+ ];
565
+ };
566
+ // Create the print icon
567
+ HC.Renderer.prototype.symbols.printIcon = function(x, y, radius) {
568
+ return [
569
+ M, // the printer
570
+ x - radius, y + radius * 0.5,
571
+ L,
572
+ x + radius, y + radius * 0.5,
573
+ x + radius, y - radius / 3,
574
+ x - radius, y - radius / 3,
575
+ 'Z',
576
+ M, // the upper sheet
577
+ x - radius * 0.5, y - radius / 3,
578
+ L,
579
+ x - radius * 0.5, y - radius,
580
+ x + radius * 0.5, y - radius,
581
+ x + radius * 0.5, y - radius / 3,
582
+ 'Z',
583
+ M, // the lower sheet
584
+ x - radius * 0.5, y + radius * 0.5,
585
+ L,
586
+ x - radius * 0.75, y + radius,
587
+ x + radius * 0.75, y + radius,
588
+ x + radius * 0.5, y + radius * 0.5,
589
+ 'Z'
590
+ ];
591
+ };
592
+
593
+ // Add the buttons on chart load
594
+ addEvent(Chart.prototype, 'load', function(e) {
595
+ var chart = e.target,
596
+ n,
597
+ exportingOptions = chart.options.exporting,
598
+ buttons = exportingOptions.buttons;
599
+
600
+ if (exportingOptions.enabled !== false) {
601
+
602
+ for (n in buttons) {
603
+ chart.addButton(buttons[n]);
604
+ }
605
+ }
606
+
607
+ });
608
+
609
+ })();