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