1 /* |
1 /** |
2 * :organization: Logilab |
2 * :organization: Logilab |
3 * :copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
3 * :copyright: 2008-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4 * :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
4 * :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 * |
5 * |
6 */ |
6 */ |
7 |
7 |
8 |
8 /** |
9 /* provide our own custom date parser since the default |
9 * provide our own custom date parser since the default |
10 * one only understands iso8601 and gregorian dates |
10 * one only understands iso8601 and gregorian dates |
11 */ |
11 */ |
12 SimileAjax.NativeDateUnit.getParser = Timeline.NativeDateUnit.getParser = function(format) { |
12 SimileAjax.NativeDateUnit.getParser = Timeline.NativeDateUnit.getParser = function(format) { |
13 if (typeof format == "string") { |
13 if (typeof format == "string") { |
14 if (format.indexOf('%') != -1) { |
14 if (format.indexOf('%') != - 1) { |
15 return function(datestring) { |
15 return function(datestring) { |
16 if (datestring) { |
16 if (datestring) { |
17 return strptime(datestring, format); |
17 return strptime(datestring, format); |
18 } |
18 } |
19 return null; |
19 return null; |
20 }; |
20 }; |
21 } |
21 } |
22 format = format.toLowerCase(); |
22 format = format.toLowerCase(); |
23 } |
23 } |
24 if (format == "iso8601" || format == "iso 8601") { |
24 if (format == "iso8601" || format == "iso 8601") { |
25 return Timeline.DateTime.parseIso8601DateTime; |
25 return Timeline.DateTime.parseIso8601DateTime; |
26 } |
26 } |
27 return Timeline.DateTime.parseGregorianDateTime; |
27 return Timeline.DateTime.parseGregorianDateTime; |
28 }; |
28 }; |
29 |
29 |
30 /*** CUBICWEB EVENT PAINTER *****************************************************/ |
30 /*** CUBICWEB EVENT PAINTER *****************************************************/ |
31 Timeline.CubicWebEventPainter = function(params) { |
31 Timeline.CubicWebEventPainter = function(params) { |
32 // Timeline.OriginalEventPainter.apply(this, arguments); |
32 // Timeline.OriginalEventPainter.apply(this, arguments); |
33 this._params = params; |
33 this._params = params; |
34 this._onSelectListeners = []; |
34 this._onSelectListeners = []; |
35 |
35 |
36 this._filterMatcher = null; |
36 this._filterMatcher = null; |
37 this._highlightMatcher = null; |
37 this._highlightMatcher = null; |
38 this._frc = null; |
38 this._frc = null; |
39 |
39 |
40 this._eventIdToElmt = {}; |
40 this._eventIdToElmt = {}; |
41 }; |
41 }; |
42 |
42 |
43 Timeline.CubicWebEventPainter.prototype = new Timeline.OriginalEventPainter(); |
43 Timeline.CubicWebEventPainter.prototype = new Timeline.OriginalEventPainter(); |
44 |
44 |
45 Timeline.CubicWebEventPainter.prototype._paintEventLabel = function( |
45 Timeline.CubicWebEventPainter.prototype._paintEventLabel = function( |
46 evt, text, left, top, width, height, theme) { |
46 evt, text, left, top, width, height, theme) { |
47 var doc = this._timeline.getDocument(); |
47 var doc = this._timeline.getDocument(); |
48 |
48 |
49 var labelDiv = doc.createElement("div"); |
49 var labelDiv = doc.createElement("div"); |
50 labelDiv.className = 'timeline-event-label'; |
50 labelDiv.className = 'timeline-event-label'; |
51 |
51 |
52 labelDiv.style.left = left + "px"; |
52 labelDiv.style.left = left + "px"; |
53 labelDiv.style.width = width + "px"; |
53 labelDiv.style.width = width + "px"; |
54 labelDiv.style.top = top + "px"; |
54 labelDiv.style.top = top + "px"; |
55 |
55 |
56 if (evt._obj.onclick) { |
56 if (evt._obj.onclick) { |
57 labelDiv.appendChild(A({'href': evt._obj.onclick}, text)); |
57 labelDiv.appendChild(A({ |
|
58 'href': evt._obj.onclick |
|
59 }, |
|
60 text)); |
58 } else if (evt._obj.image) { |
61 } else if (evt._obj.image) { |
59 labelDiv.appendChild(IMG({src: evt._obj.image, width: '30px', height: '30px'})); |
62 labelDiv.appendChild(IMG({ |
|
63 src: evt._obj.image, |
|
64 width: '30px', |
|
65 height: '30px' |
|
66 })); |
60 } else { |
67 } else { |
61 labelDiv.innerHTML = text; |
68 labelDiv.innerHTML = text; |
62 } |
69 } |
63 |
70 |
64 if(evt._title != null) |
71 if (evt._title != null) labelDiv.title = evt._title; |
65 labelDiv.title = evt._title; |
|
66 |
72 |
67 var color = evt.getTextColor(); |
73 var color = evt.getTextColor(); |
68 if (color == null) { |
74 if (color == null) { |
69 color = evt.getColor(); |
75 color = evt.getColor(); |
70 } |
76 } |
71 if (color != null) { |
77 if (color != null) { |
72 labelDiv.style.color = color; |
78 labelDiv.style.color = color; |
73 } |
79 } |
74 var classname = evt.getClassName(); |
80 var classname = evt.getClassName(); |
75 if(classname) labelDiv.className +=' ' + classname; |
81 if (classname) labelDiv.className += ' ' + classname; |
76 |
82 |
77 this._eventLayer.appendChild(labelDiv); |
83 this._eventLayer.appendChild(labelDiv); |
78 |
84 |
79 return { |
85 return { |
80 left: left, |
86 left: left, |
81 top: top, |
87 top: top, |
82 width: width, |
88 width: width, |
83 height: height, |
89 height: height, |
84 elmt: labelDiv |
90 elmt: labelDiv |
85 }; |
91 }; |
86 }; |
92 }; |
87 |
93 |
|
94 Timeline.CubicWebEventPainter.prototype._showBubble = function(x, y, evt) { |
|
95 var div = DIV({ |
|
96 id: 'xxx' |
|
97 }); |
|
98 var width = this._params.theme.event.bubble.width; |
|
99 if (!evt._obj.bubbleUrl) { |
|
100 evt.fillInfoBubble(div, this._params.theme, this._band.getLabeller()); |
|
101 } |
|
102 SimileAjax.WindowManager.cancelPopups(); |
|
103 SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y, width); |
|
104 if (evt._obj.bubbleUrl) { |
|
105 jQuery('#xxx').loadxhtml(evt._obj.bubbleUrl, null, 'post', 'replace'); |
|
106 } |
|
107 }; |
88 |
108 |
89 Timeline.CubicWebEventPainter.prototype._showBubble = function(x, y, evt) { |
|
90 var div = DIV({id: 'xxx'}); |
|
91 var width = this._params.theme.event.bubble.width; |
|
92 if (!evt._obj.bubbleUrl) { |
|
93 evt.fillInfoBubble(div, this._params.theme, this._band.getLabeller()); |
|
94 } |
|
95 SimileAjax.WindowManager.cancelPopups(); |
|
96 SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y, width); |
|
97 if (evt._obj.bubbleUrl) { |
|
98 jQuery('#xxx').loadxhtml(evt._obj.bubbleUrl, null, 'post', 'replace'); |
|
99 } |
|
100 }; |
|