5 Roo.ux.TimePicker = function(config){
8 // these are required... error out if not avail..
10 if (typeof(Raphael) == 'undefined') {
13 if (deps && typeof(Raphael.prototype) == 'undefined') {
17 alert("Error - required components not found - Raphael and piechart");
21 Roo.ux.TimePicker.superclass.constructor.call(this, config);
24 Roo.extend(Roo.ux.TimePicker , Roo.form.DisplayField , {
26 // let's create a pie chart...
27 var ge = Roo.select('.pb-book-time',true).first();
28 var paper = Raphael(ge.dom);
29 var sz = ge.getSize();
30 paper.setSize(sz.width,sz.height);
35 // say we open for 7 - 19
43 var clr = [ '#003' , '#FCC' , '#Fee', '#FCC'];
47 for (var i = (open*4); i < (close*4);i++) {
51 times.push( 'midnight' )
55 var min = ( i % 4) * 15;
56 min = !min ? ':00' : (':' + min);
57 var hr = Math.floor(i/4);
58 var tail = hr < 12 ? 'am' : 'pm';
60 times.push(hr + min + tail);
65 colors.push(clr[i % clr.length]);
67 data.push((24-close) * 4);
70 Roo.log(JSON.stringify(data));
71 Roo.log(JSON.stringify(colors));
72 Roo.log(colors.length);
74 var pie = paper.piechart(
77 (paper.height / 2) - 70,
86 paper.circle(pie.cx,pie.cy, (paper.height / 2) - 100).attr({fill: "#fff"})
88 var atime = "Pick\nTime";
91 var tdisplay = paper.text(pie.cx,pie.cy,atime).attr({ font: "32px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif", weight: 'bold', fill: '#000' });
96 if (!this.j || this.j == data.length -1) {
100 if (this.sector != asector) {
101 this.sector.scale(1.1, 1.1, this.cx, this.cy);
103 tdisplay.attr( { text : times[this.j]} );
105 this.label[0].stop();
106 this.label[0].attr({ r: 7.5 });
107 this.label[1].attr({ "font-weight": 800 });
112 if (!this.j || this.j == data.length) {
115 if (this.sector != asector) {
116 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
120 this.label[0].animate({ r: 5 }, 500, "bounce");
121 this.label[1].attr({ "font-weight": 400 });
123 tdisplay.attr( { text : atime } );
126 pie.click(function() {
127 if (!this.j || this.j == data.length -1) {
130 atime = times[this.j];
131 tdisplay.attr( { text : atime } );
133 asector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
136 this.sector.scale(1.1, 1.1, this.cx, this.cy);
137 asector = this.sector;
145 for (var i = 0; i < (24/3); i++) {
146 var angle = ( (360/24) * i * -3 ) -90;
147 var p = pie.sector(pie.cx, pie.cy, 120, angle, angle, false);
148 Roo.log([p[4],p[5], (i*3)+':00']);
152 var txt = (hr < 12 ? hr : (hr-12)) + (hr < 12 ? 'am' : 'pm');
153 if (!hr) { txt = ""; }
154 if (hr == 12) { txt= '12 noon'}
155 paper.text(p[4],p[5], txt);
158 //pie.each(function() { Roo.log(this)});