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