web/data/cubicweb.timeline-bundle.js
author sylvain.thenault@logilab.fr
Thu, 14 May 2009 12:50:34 +0200
changeset 1813 4e4333bb56b3
parent 1156 4b920f836567
child 2097 400bdbcc5699
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     1
var SimileAjax_urlPrefix = baseuri() + 'data/';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     2
var Timeline_urlPrefix = baseuri() + 'data/';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     3
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     4
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     5
 *  Simile Ajax API
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     6
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     7
 *  Include this file in your HTML file as follows:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     8
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     9
 *    <script src="http://simile.mit.edu/ajax/api/simile-ajax-api.js" type="text/javascript"></script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    10
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    11
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    12
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    13
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    14
if (typeof SimileAjax == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    15
    var SimileAjax = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    16
        loaded:                 false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    17
        loadingScriptsCount:    0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    18
        error:                  null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    19
        params:                 { bundle:"true" }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    20
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    21
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    22
    SimileAjax.Platform = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    23
        /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    24
            HACK: We need these 2 things here because we cannot simply append
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    25
            a <script> element containing code that accesses SimileAjax.Platform
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    26
            to initialize it because IE executes that <script> code first
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    27
            before it loads ajax.js and platform.js.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    28
        */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    29
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    30
    var getHead = function(doc) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    31
        return doc.getElementsByTagName("head")[0];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    32
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    33
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    34
    SimileAjax.findScript = function(doc, substring) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    35
        var heads = doc.documentElement.getElementsByTagName("head");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    36
        for (var h = 0; h < heads.length; h++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    37
            var node = heads[h].firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    38
            while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    39
                if (node.nodeType == 1 && node.tagName.toLowerCase() == "script") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    40
                    var url = node.src;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    41
                    var i = url.indexOf(substring);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    42
                    if (i >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    43
                        return url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    44
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    45
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    46
                node = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    47
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    48
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    49
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    50
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    51
    SimileAjax.includeJavascriptFile = function(doc, url, onerror, charset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    52
        onerror = onerror || "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    53
        if (doc.body == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    54
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    55
                var q = "'" + onerror.replace( /'/g, '&apos' ) + "'"; // "
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    56
                doc.write("<script src='" + url + "' onerror="+ q +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    57
                          (charset ? " charset='"+ charset +"'" : "") +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    58
                          " type='text/javascript'>"+ onerror + "</script>");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    59
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    60
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    61
                // fall through
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    62
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    63
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    64
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    65
        var script = doc.createElement("script");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    66
        if (onerror) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    67
            try { script.innerHTML = onerror; } catch(e) {}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    68
            script.setAttribute("onerror", onerror);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    69
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    70
        if (charset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    71
            script.setAttribute("charset", charset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    72
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    73
        script.type = "text/javascript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    74
        script.language = "JavaScript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    75
        script.src = url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    76
        return getHead(doc).appendChild(script);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    77
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    78
    SimileAjax.includeJavascriptFiles = function(doc, urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    79
        for (var i = 0; i < filenames.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    80
            SimileAjax.includeJavascriptFile(doc, urlPrefix + filenames[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    81
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    82
        SimileAjax.loadingScriptsCount += filenames.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    83
        SimileAjax.includeJavascriptFile(doc, SimileAjax.urlPrefix + "scripts/signal.js?" + filenames.length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    84
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    85
    SimileAjax.includeCssFile = function(doc, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    86
        if (doc.body == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    87
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    88
                doc.write("<link rel='stylesheet' href='" + url + "' type='text/css'/>");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    89
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    90
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    91
                // fall through
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    92
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    93
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    94
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    95
        var link = doc.createElement("link");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    96
        link.setAttribute("rel", "stylesheet");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    97
        link.setAttribute("type", "text/css");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    98
        link.setAttribute("href", url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    99
        getHead(doc).appendChild(link);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   100
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   101
    SimileAjax.includeCssFiles = function(doc, urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   102
        for (var i = 0; i < filenames.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   103
            SimileAjax.includeCssFile(doc, urlPrefix + filenames[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   104
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   105
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   106
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   107
    /**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   108
     * Append into urls each string in suffixes after prefixing it with urlPrefix.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   109
     * @param {Array} urls
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   110
     * @param {String} urlPrefix
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   111
     * @param {Array} suffixes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   112
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   113
    SimileAjax.prefixURLs = function(urls, urlPrefix, suffixes) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   114
        for (var i = 0; i < suffixes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   115
            urls.push(urlPrefix + suffixes[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   116
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   117
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   118
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   119
    /**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   120
     * Parse out the query parameters from a URL
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   121
     * @param {String} url    the url to parse, or location.href if undefined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   122
     * @param {Object} to     optional object to extend with the parameters
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   123
     * @param {Object} types  optional object mapping keys to value types
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   124
     *        (String, Number, Boolean or Array, String by default)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   125
     * @return a key/value Object whose keys are the query parameter names
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   126
     * @type Object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   127
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   128
    SimileAjax.parseURLParameters = function(url, to, types) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   129
        to = to || {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   130
        types = types || {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   131
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   132
        if (typeof url == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   133
            url = location.href;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   134
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   135
        var q = url.indexOf("?");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   136
        if (q < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   137
            return to;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   138
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   139
        url = (url+"#").slice(q+1, url.indexOf("#")); // toss the URL fragment
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   140
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   141
        var params = url.split("&"), param, parsed = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   142
        var decode = window.decodeURIComponent || unescape;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   143
        for (var i = 0; param = params[i]; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   144
            var eq = param.indexOf("=");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   145
            var name = decode(param.slice(0,eq));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   146
            var old = parsed[name];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   147
            if (typeof old == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   148
                old = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   149
            } else if (!(old instanceof Array)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   150
                old = [old];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   151
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   152
            parsed[name] = old.concat(decode(param.slice(eq+1)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   153
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   154
        for (var i in parsed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   155
            if (!parsed.hasOwnProperty(i)) continue;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   156
            var type = types[i] || String;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   157
            var data = parsed[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   158
            if (!(data instanceof Array)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   159
                data = [data];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   160
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   161
            if (type === Boolean && data[0] == "false") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   162
                to[i] = false; // because Boolean("false") === true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   163
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   164
                to[i] = type.apply(this, data);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   165
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   166
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   167
        return to;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   168
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   169
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   170
    (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   171
        var javascriptFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   172
            "jquery-1.2.6.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   173
            "platform.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   174
            "debug.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   175
            "xmlhttp.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   176
            "json.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   177
            "dom.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   178
            "graphics.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   179
            "date-time.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   180
            "string.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   181
            "html.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   182
            "data-structure.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   183
            "units.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   184
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   185
            "ajax.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   186
            "history.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   187
            "window-manager.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   188
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   189
        var cssFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   190
            "graphics.css"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   191
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   192
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   193
        if (typeof SimileAjax_urlPrefix == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   194
            SimileAjax.urlPrefix = SimileAjax_urlPrefix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   195
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   196
            var url = SimileAjax.findScript(document, "simile-ajax-api.js");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   197
            if (url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   198
                SimileAjax.error = new Error("Failed to derive URL prefix for Simile Ajax API code files");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   199
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   200
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   201
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   202
            SimileAjax.urlPrefix = url.substr(0, url.indexOf("simile-ajax-api.js"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   203
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   204
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   205
        SimileAjax.parseURLParameters(url, SimileAjax.params, {bundle:Boolean});
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   206
//         if (SimileAjax.params.bundle) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   207
//             SimileAjax.includeJavascriptFiles(document, SimileAjax.urlPrefix, [ "simile-ajax-bundle.js" ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   208
//         } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   209
//             SimileAjax.includeJavascriptFiles(document, SimileAjax.urlPrefix + "scripts/", javascriptFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   210
//         }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   211
        SimileAjax.includeCssFiles(document, SimileAjax.urlPrefix + "styles/", cssFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   212
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   213
        SimileAjax.loaded = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   214
    })();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   215
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   216
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   217
 *  Platform Utility Functions and Constants
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   218
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   219
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   220
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   221
/*  This must be called after our jQuery has been loaded
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   222
    but before control returns to user-code.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   223
*/
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   224
SimileAjax.jQuery = jQuery;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   225
// SimileAjax.jQuery = jQuery.noConflict(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   226
if (typeof window["$"] == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   227
    window.$ = SimileAjax.jQuery;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   228
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   229
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   230
SimileAjax.Platform.os = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   231
    isMac:   false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   232
    isWin:   false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   233
    isWin32: false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   234
    isUnix:  false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   235
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   236
SimileAjax.Platform.browser = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   237
    isIE:           false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   238
    isNetscape:     false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   239
    isMozilla:      false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   240
    isFirefox:      false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   241
    isOpera:        false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   242
    isSafari:       false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   243
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   244
    majorVersion:   0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   245
    minorVersion:   0
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   246
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   247
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   248
(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   249
    var an = navigator.appName.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   250
	var ua = navigator.userAgent.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   251
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   252
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   253
     *  Operating system
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   254
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   255
	SimileAjax.Platform.os.isMac = (ua.indexOf('mac') != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   256
	SimileAjax.Platform.os.isWin = (ua.indexOf('win') != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   257
	SimileAjax.Platform.os.isWin32 = SimileAjax.Platform.isWin && (
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   258
        ua.indexOf('95') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   259
        ua.indexOf('98') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   260
        ua.indexOf('nt') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   261
        ua.indexOf('win32') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   262
        ua.indexOf('32bit') != -1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   263
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   264
	SimileAjax.Platform.os.isUnix = (ua.indexOf('x11') != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   265
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   266
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   267
     *  Browser
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   268
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   269
    SimileAjax.Platform.browser.isIE = (an.indexOf("microsoft") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   270
    SimileAjax.Platform.browser.isNetscape = (an.indexOf("netscape") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   271
    SimileAjax.Platform.browser.isMozilla = (ua.indexOf("mozilla") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   272
    SimileAjax.Platform.browser.isFirefox = (ua.indexOf("firefox") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   273
    SimileAjax.Platform.browser.isOpera = (an.indexOf("opera") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   274
    SimileAjax.Platform.browser.isSafari = (an.indexOf("safari") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   275
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   276
    var parseVersionString = function(s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   277
        var a = s.split(".");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   278
        SimileAjax.Platform.browser.majorVersion = parseInt(a[0]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   279
        SimileAjax.Platform.browser.minorVersion = parseInt(a[1]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   280
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   281
    var indexOf = function(s, sub, start) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   282
        var i = s.indexOf(sub, start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   283
        return i >= 0 ? i : s.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   284
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   285
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   286
    if (SimileAjax.Platform.browser.isMozilla) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   287
        var offset = ua.indexOf("mozilla/");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   288
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   289
            parseVersionString(ua.substring(offset + 8, indexOf(ua, " ", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   290
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   291
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   292
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   293
        var offset = ua.indexOf("msie ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   294
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   295
            parseVersionString(ua.substring(offset + 5, indexOf(ua, ";", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   296
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   297
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   298
    if (SimileAjax.Platform.browser.isNetscape) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   299
        var offset = ua.indexOf("rv:");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   300
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   301
            parseVersionString(ua.substring(offset + 3, indexOf(ua, ")", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   302
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   303
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   304
    if (SimileAjax.Platform.browser.isFirefox) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   305
        var offset = ua.indexOf("firefox/");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   306
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   307
            parseVersionString(ua.substring(offset + 8, indexOf(ua, " ", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   308
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   309
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   310
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   311
    if (!("localeCompare" in String.prototype)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   312
        String.prototype.localeCompare = function (s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   313
            if (this < s) return -1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   314
            else if (this > s) return 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   315
            else return 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   316
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   317
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   318
})();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   319
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   320
SimileAjax.Platform.getDefaultLocale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   321
    return SimileAjax.Platform.clientLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   322
};/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   323
 *  Debug Utility Functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   324
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   325
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   326
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   327
SimileAjax.Debug = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   328
    silent: false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   329
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   330
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   331
SimileAjax.Debug.log = function(msg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   332
    var f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   333
    if ("console" in window && "log" in window.console) { // FireBug installed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   334
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   335
            console.log(msg2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   336
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   337
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   338
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   339
            if (!SimileAjax.Debug.silent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   340
                alert(msg2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   341
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   342
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   343
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   344
    SimileAjax.Debug.log = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   345
    f(msg);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   346
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   347
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   348
SimileAjax.Debug.warn = function(msg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   349
    var f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   350
    if ("console" in window && "warn" in window.console) { // FireBug installed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   351
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   352
            console.warn(msg2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   353
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   354
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   355
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   356
            if (!SimileAjax.Debug.silent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   357
                alert(msg2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   358
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   359
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   360
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   361
    SimileAjax.Debug.warn = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   362
    f(msg);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   363
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   364
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   365
SimileAjax.Debug.exception = function(e, msg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   366
    var f, params = SimileAjax.parseURLParameters();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   367
    if (params.errors == "throw" || SimileAjax.params.errors == "throw") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   368
        f = function(e2, msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   369
            throw(e2); // do not hide from browser's native debugging features
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   370
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   371
    } else if ("console" in window && "error" in window.console) { // FireBug installed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   372
        f = function(e2, msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   373
            if (msg2 != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   374
                console.error(msg2 + " %o", e2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   375
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   376
                console.error(e2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   377
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   378
            throw(e2); // do not hide from browser's native debugging features
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   379
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   380
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   381
        f = function(e2, msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   382
            if (!SimileAjax.Debug.silent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   383
                alert("Caught exception: " + msg2 + "\n\nDetails: " + ("description" in e2 ? e2.description : e2));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   384
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   385
            throw(e2); // do not hide from browser's native debugging features
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   386
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   387
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   388
    SimileAjax.Debug.exception = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   389
    f(e, msg);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   390
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   391
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   392
SimileAjax.Debug.objectToString = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   393
    return SimileAjax.Debug._objectToString(o, "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   394
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   395
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   396
SimileAjax.Debug._objectToString = function(o, indent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   397
    var indent2 = indent + " ";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   398
    if (typeof o == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   399
        var s = "{";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   400
        for (n in o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   401
            s += indent2 + n + ": " + SimileAjax.Debug._objectToString(o[n], indent2) + "\n";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   402
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   403
        s += indent + "}";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   404
        return s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   405
    } else if (typeof o == "array") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   406
        var s = "[";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   407
        for (var n = 0; n < o.length; n++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   408
            s += SimileAjax.Debug._objectToString(o[n], indent2) + "\n";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   409
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   410
        s += indent + "]";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   411
        return s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   412
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   413
        return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   414
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   415
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   416
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   417
 * @fileOverview XmlHttp utility functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   418
 * @name SimileAjax.XmlHttp
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   419
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   420
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   421
SimileAjax.XmlHttp = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   422
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   423
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   424
 *  Callback for XMLHttp onRequestStateChange.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   425
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   426
SimileAjax.XmlHttp._onReadyStateChange = function(xmlhttp, fError, fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   427
    switch (xmlhttp.readyState) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   428
    // 1: Request not yet made
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   429
    // 2: Contact established with server but nothing downloaded yet
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   430
    // 3: Called multiple while downloading in progress
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   431
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   432
    // Download complete
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   433
    case 4:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   434
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   435
            if (xmlhttp.status == 0     // file:// urls, works on Firefox
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   436
             || xmlhttp.status == 200   // http:// urls
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   437
            ) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   438
                if (fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   439
                    fDone(xmlhttp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   440
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   441
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   442
                if (fError) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   443
                    fError(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   444
                        xmlhttp.statusText,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   445
                        xmlhttp.status,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   446
                        xmlhttp
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   447
                    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   448
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   449
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   450
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   451
            SimileAjax.Debug.exception("XmlHttp: Error handling onReadyStateChange", e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   452
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   453
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   454
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   455
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   456
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   457
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   458
 *  Creates an XMLHttpRequest object. On the first run, this
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   459
 *  function creates a platform-specific function for
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   460
 *  instantiating an XMLHttpRequest object and then replaces
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   461
 *  itself with that function.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   462
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   463
SimileAjax.XmlHttp._createRequest = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   464
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   465
        var programIDs = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   466
        "Msxml2.XMLHTTP",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   467
        "Microsoft.XMLHTTP",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   468
        "Msxml2.XMLHTTP.4.0"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   469
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   470
        for (var i = 0; i < programIDs.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   471
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   472
                var programID = programIDs[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   473
                var f = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   474
                    return new ActiveXObject(programID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   475
                };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   476
                var o = f();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   477
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   478
                // We are replacing the SimileAjax._createXmlHttpRequest
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   479
                // function with this inner function as we've
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   480
                // found out that it works. This is so that we
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   481
                // don't have to do all the testing over again
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   482
                // on subsequent calls.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   483
                SimileAjax.XmlHttp._createRequest = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   484
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   485
                return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   486
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   487
                // silent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   488
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   489
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   490
        // fall through to try new XMLHttpRequest();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   491
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   492
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   493
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   494
        var f = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   495
            return new XMLHttpRequest();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   496
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   497
        var o = f();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   498
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   499
        // We are replacing the SimileAjax._createXmlHttpRequest
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   500
        // function with this inner function as we've
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   501
        // found out that it works. This is so that we
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   502
        // don't have to do all the testing over again
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   503
        // on subsequent calls.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   504
        SimileAjax.XmlHttp._createRequest = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   505
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   506
        return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   507
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   508
        throw new Error("Failed to create an XMLHttpRequest object");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   509
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   510
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   511
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   512
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   513
 * Performs an asynchronous HTTP GET.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   514
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   515
 * @param {Function} fError a function of the form
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   516
     function(statusText, statusCode, xmlhttp)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   517
 * @param {Function} fDone a function of the form function(xmlhttp)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   518
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   519
SimileAjax.XmlHttp.get = function(url, fError, fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   520
    var xmlhttp = SimileAjax.XmlHttp._createRequest();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   521
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   522
    xmlhttp.open("GET", url, true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   523
    xmlhttp.onreadystatechange = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   524
        SimileAjax.XmlHttp._onReadyStateChange(xmlhttp, fError, fDone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   525
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   526
    xmlhttp.send(null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   527
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   528
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   529
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   530
 * Performs an asynchronous HTTP POST.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   531
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   532
 * @param {Function} fError a function of the form
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   533
     function(statusText, statusCode, xmlhttp)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   534
 * @param {Function} fDone a function of the form function(xmlhttp)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   535
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   536
SimileAjax.XmlHttp.post = function(url, body, fError, fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   537
    var xmlhttp = SimileAjax.XmlHttp._createRequest();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   538
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   539
    xmlhttp.open("POST", url, true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   540
    xmlhttp.onreadystatechange = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   541
        SimileAjax.XmlHttp._onReadyStateChange(xmlhttp, fError, fDone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   542
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   543
    xmlhttp.send(body);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   544
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   545
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   546
SimileAjax.XmlHttp._forceXML = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   547
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   548
        xmlhttp.overrideMimeType("text/xml");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   549
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   550
        xmlhttp.setrequestheader("Content-Type", "text/xml");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   551
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   552
};/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   553
 *  Copied directly from http://www.json.org/json.js.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   554
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   555
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   556
/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   557
    json.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   558
    2006-04-28
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   559
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   560
    This file adds these methods to JavaScript:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   561
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   562
        object.toJSONString()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   563
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   564
            This method produces a JSON text from an object. The
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   565
            object must not contain any cyclical references.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   566
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   567
        array.toJSONString()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   568
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   569
            This method produces a JSON text from an array. The
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   570
            array must not contain any cyclical references.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   571
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   572
        string.parseJSON()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   573
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   574
            This method parses a JSON text to produce an object or
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   575
            array. It will return false if there is an error.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   576
*/
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   577
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   578
SimileAjax.JSON = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   579
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   580
(function () {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   581
    var m = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   582
        '\b': '\\b',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   583
        '\t': '\\t',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   584
        '\n': '\\n',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   585
        '\f': '\\f',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   586
        '\r': '\\r',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   587
        '"' : '\\"',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   588
        '\\': '\\\\'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   589
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   590
    var s = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   591
        array: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   592
            var a = ['['], b, f, i, l = x.length, v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   593
            for (i = 0; i < l; i += 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   594
                v = x[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   595
                f = s[typeof v];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   596
                if (f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   597
                    v = f(v);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   598
                    if (typeof v == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   599
                        if (b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   600
                            a[a.length] = ',';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   601
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   602
                        a[a.length] = v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   603
                        b = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   604
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   605
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   606
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   607
            a[a.length] = ']';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   608
            return a.join('');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   609
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   610
        'boolean': function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   611
            return String(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   612
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   613
        'null': function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   614
            return "null";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   615
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   616
        number: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   617
            return isFinite(x) ? String(x) : 'null';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   618
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   619
        object: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   620
            if (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   621
                if (x instanceof Array) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   622
                    return s.array(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   623
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   624
                var a = ['{'], b, f, i, v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   625
                for (i in x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   626
                    v = x[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   627
                    f = s[typeof v];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   628
                    if (f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   629
                        v = f(v);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   630
                        if (typeof v == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   631
                            if (b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   632
                                a[a.length] = ',';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   633
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   634
                            a.push(s.string(i), ':', v);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   635
                            b = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   636
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   637
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   638
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   639
                a[a.length] = '}';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   640
                return a.join('');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   641
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   642
            return 'null';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   643
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   644
        string: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   645
            if (/["\\\x00-\x1f]/.test(x)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   646
                x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   647
                    var c = m[b];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   648
                    if (c) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   649
                        return c;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   650
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   651
                    c = b.charCodeAt();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   652
                    return '\\u00' +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   653
                        Math.floor(c / 16).toString(16) +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   654
                        (c % 16).toString(16);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   655
                });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   656
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   657
            return '"' + x + '"';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   658
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   659
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   660
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   661
    SimileAjax.JSON.toJSONString = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   662
        if (o instanceof Object) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   663
            return s.object(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   664
        } else if (o instanceof Array) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   665
            return s.array(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   666
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   667
            return o.toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   668
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   669
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   670
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   671
    SimileAjax.JSON.parseJSON = function () {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   672
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   673
            return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   674
                    this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   675
                eval('(' + this + ')');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   676
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   677
            return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   678
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   679
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   680
})();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   681
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   682
 *  DOM Utility Functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   683
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   684
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   685
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   686
SimileAjax.DOM = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   687
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   688
SimileAjax.DOM.registerEventWithObject = function(elmt, eventName, obj, handlerName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   689
    SimileAjax.DOM.registerEvent(elmt, eventName, function(elmt2, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   690
        return obj[handlerName].call(obj, elmt2, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   691
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   692
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   693
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   694
SimileAjax.DOM.registerEvent = function(elmt, eventName, handler) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   695
    var handler2 = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   696
        evt = (evt) ? evt : ((event) ? event : null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   697
        if (evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   698
            var target = (evt.target) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   699
                evt.target : ((evt.srcElement) ? evt.srcElement : null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   700
            if (target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   701
                target = (target.nodeType == 1 || target.nodeType == 9) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   702
                    target : target.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   703
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   704
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   705
            return handler(elmt, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   706
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   707
        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   708
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   709
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   710
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   711
        elmt.attachEvent("on" + eventName, handler2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   712
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   713
        elmt.addEventListener(eventName, handler2, false);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   714
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   715
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   716
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   717
SimileAjax.DOM.getPageCoordinates = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   718
    var left = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   719
    var top = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   720
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   721
    if (elmt.nodeType != 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   722
        elmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   723
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   724
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   725
    var elmt2 = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   726
    while (elmt2 != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   727
        left += elmt2.offsetLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   728
        top += elmt2.offsetTop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   729
        elmt2 = elmt2.offsetParent;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   730
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   731
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   732
    var body = document.body;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   733
    while (elmt != null && elmt != body) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   734
        if ("scrollLeft" in elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   735
            left -= elmt.scrollLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   736
            top -= elmt.scrollTop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   737
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   738
        elmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   739
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   740
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   741
    return { left: left, top: top };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   742
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   743
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   744
SimileAjax.DOM.getSize = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   745
	var w = this.getStyle(elmt,"width");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   746
	var h = this.getStyle(elmt,"height");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   747
	if (w.indexOf("px") > -1) w = w.replace("px","");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   748
	if (h.indexOf("px") > -1) h = h.replace("px","");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   749
	return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   750
		w: w,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   751
		h: h
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   752
	}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   753
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   754
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   755
SimileAjax.DOM.getStyle = function(elmt, styleProp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   756
    if (elmt.currentStyle) { // IE
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   757
        var style = elmt.currentStyle[styleProp];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   758
    } else if (window.getComputedStyle) { // standard DOM
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   759
        var style = document.defaultView.getComputedStyle(elmt, null).getPropertyValue(styleProp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   760
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   761
    	var style = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   762
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   763
    return style;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   764
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   765
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   766
SimileAjax.DOM.getEventRelativeCoordinates = function(evt, elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   767
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   768
      if (evt.type == "mousewheel") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   769
        var coords = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   770
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   771
          x: evt.clientX - coords.left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   772
          y: evt.clientY - coords.top
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   773
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   774
      } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   775
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   776
          x: evt.offsetX,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   777
          y: evt.offsetY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   778
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   779
      }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   780
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   781
        var coords = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   782
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   783
        if ((evt.type == "DOMMouseScroll") &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   784
          SimileAjax.Platform.browser.isFirefox &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   785
          (SimileAjax.Platform.browser.majorVersion == 2)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   786
          // Due to: https://bugzilla.mozilla.org/show_bug.cgi?id=352179
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   787
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   788
          return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   789
            x: evt.screenX - coords.left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   790
            y: evt.screenY - coords.top
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   791
          };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   792
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   793
          return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   794
              x: evt.pageX - coords.left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   795
              y: evt.pageY - coords.top
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   796
          };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   797
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   798
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   799
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   800
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   801
SimileAjax.DOM.getEventPageCoordinates = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   802
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   803
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   804
            x: evt.clientX + document.body.scrollLeft,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   805
            y: evt.clientY + document.body.scrollTop
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   806
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   807
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   808
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   809
            x: evt.pageX,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   810
            y: evt.pageY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   811
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   812
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   813
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   814
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   815
SimileAjax.DOM.hittest = function(x, y, except) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   816
    return SimileAjax.DOM._hittest(document.body, x, y, except);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   817
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   818
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   819
SimileAjax.DOM._hittest = function(elmt, x, y, except) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   820
    var childNodes = elmt.childNodes;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   821
    outer: for (var i = 0; i < childNodes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   822
        var childNode = childNodes[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   823
        for (var j = 0; j < except.length; j++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   824
            if (childNode == except[j]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   825
                continue outer;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   826
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   827
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   828
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   829
        if (childNode.offsetWidth == 0 && childNode.offsetHeight == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   830
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   831
             *  Sometimes SPAN elements have zero width and height but
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   832
             *  they have children like DIVs that cover non-zero areas.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   833
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   834
            var hitNode = SimileAjax.DOM._hittest(childNode, x, y, except);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   835
            if (hitNode != childNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   836
                return hitNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   837
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   838
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   839
            var top = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   840
            var left = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   841
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   842
            var node = childNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   843
            while (node) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   844
                top += node.offsetTop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   845
                left += node.offsetLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   846
                node = node.offsetParent;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   847
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   848
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   849
            if (left <= x && top <= y && (x - left) < childNode.offsetWidth && (y - top) < childNode.offsetHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   850
                return SimileAjax.DOM._hittest(childNode, x, y, except);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   851
            } else if (childNode.nodeType == 1 && childNode.tagName == "TR") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   852
                /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   853
                 *  Table row might have cells that span several rows.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   854
                 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   855
                var childNode2 = SimileAjax.DOM._hittest(childNode, x, y, except);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   856
                if (childNode2 != childNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   857
                    return childNode2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   858
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   859
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   860
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   861
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   862
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   863
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   864
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   865
SimileAjax.DOM.cancelEvent = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   866
    evt.returnValue = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   867
    evt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   868
    if ("preventDefault" in evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   869
        evt.preventDefault();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   870
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   871
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   872
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   873
SimileAjax.DOM.appendClassName = function(elmt, className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   874
    var classes = elmt.className.split(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   875
    for (var i = 0; i < classes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   876
        if (classes[i] == className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   877
            return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   878
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   879
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   880
    classes.push(className);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   881
    elmt.className = classes.join(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   882
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   883
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   884
SimileAjax.DOM.createInputElement = function(type) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   885
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   886
    div.innerHTML = "<input type='" + type + "' />";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   887
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   888
    return div.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   889
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   890
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   891
SimileAjax.DOM.createDOMFromTemplate = function(template) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   892
    var result = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   893
    result.elmt = SimileAjax.DOM._createDOMFromTemplate(template, result, null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   894
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   895
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   896
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   897
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   898
SimileAjax.DOM._createDOMFromTemplate = function(templateNode, result, parentElmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   899
    if (templateNode == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   900
        /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   901
        var node = doc.createTextNode("--null--");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   902
        if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   903
            parentElmt.appendChild(node);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   904
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   905
        return node;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   906
        */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   907
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   908
    } else if (typeof templateNode != "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   909
        var node = document.createTextNode(templateNode);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   910
        if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   911
            parentElmt.appendChild(node);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   912
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   913
        return node;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   914
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   915
        var elmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   916
        if ("tag" in templateNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   917
            var tag = templateNode.tag;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   918
            if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   919
                if (tag == "tr") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   920
                    elmt = parentElmt.insertRow(parentElmt.rows.length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   921
                } else if (tag == "td") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   922
                    elmt = parentElmt.insertCell(parentElmt.cells.length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   923
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   924
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   925
            if (elmt == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   926
                elmt = tag == "input" ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   927
                    SimileAjax.DOM.createInputElement(templateNode.type) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   928
                    document.createElement(tag);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   929
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   930
                if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   931
                    parentElmt.appendChild(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   932
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   933
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   934
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   935
            elmt = templateNode.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   936
            if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   937
                parentElmt.appendChild(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   938
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   939
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   940
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   941
        for (var attribute in templateNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   942
            var value = templateNode[attribute];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   943
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   944
            if (attribute == "field") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   945
                result[value] = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   946
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   947
            } else if (attribute == "className") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   948
                elmt.className = value;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   949
            } else if (attribute == "id") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   950
                elmt.id = value;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   951
            } else if (attribute == "title") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   952
                elmt.title = value;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   953
            } else if (attribute == "type" && elmt.tagName == "input") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   954
                // do nothing
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   955
            } else if (attribute == "style") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   956
                for (n in value) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   957
                    var v = value[n];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   958
                    if (n == "float") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   959
                        n = SimileAjax.Platform.browser.isIE ? "styleFloat" : "cssFloat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   960
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   961
                    elmt.style[n] = v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   962
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   963
            } else if (attribute == "children") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   964
                for (var i = 0; i < value.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   965
                    SimileAjax.DOM._createDOMFromTemplate(value[i], result, elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   966
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   967
            } else if (attribute != "tag" && attribute != "elmt") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   968
                elmt.setAttribute(attribute, value);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   969
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   970
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   971
        return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   972
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   973
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   974
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   975
SimileAjax.DOM._cachedParent = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   976
SimileAjax.DOM.createElementFromString = function(s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   977
    if (SimileAjax.DOM._cachedParent == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   978
        SimileAjax.DOM._cachedParent = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   979
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   980
    SimileAjax.DOM._cachedParent.innerHTML = s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   981
    return SimileAjax.DOM._cachedParent.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   982
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   983
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   984
SimileAjax.DOM.createDOMFromString = function(root, s, fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   985
    var elmt = typeof root == "string" ? document.createElement(root) : root;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   986
    elmt.innerHTML = s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   988
    var dom = { elmt: elmt };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   989
    SimileAjax.DOM._processDOMChildrenConstructedFromString(dom, elmt, fieldElmts != null ? fieldElmts : {} );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   990
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   991
    return dom;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   992
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   993
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   994
SimileAjax.DOM._processDOMConstructedFromString = function(dom, elmt, fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   995
    var id = elmt.id;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   996
    if (id != null && id.length > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   997
        elmt.removeAttribute("id");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   998
        if (id in fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   999
            var parentElmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1000
            parentElmt.insertBefore(fieldElmts[id], elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1001
            parentElmt.removeChild(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1002
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1003
            dom[id] = fieldElmts[id];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1004
            return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1005
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1006
            dom[id] = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1007
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1008
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1009
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1010
    if (elmt.hasChildNodes()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1011
        SimileAjax.DOM._processDOMChildrenConstructedFromString(dom, elmt, fieldElmts);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1012
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1013
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1014
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1015
SimileAjax.DOM._processDOMChildrenConstructedFromString = function(dom, elmt, fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1016
    var node = elmt.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1017
    while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1018
        var node2 = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1019
        if (node.nodeType == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1020
            SimileAjax.DOM._processDOMConstructedFromString(dom, node, fieldElmts);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1021
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1022
        node = node2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1023
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1024
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1025
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1026
 * @fileOverview Graphics utility functions and constants
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1027
 * @name SimileAjax.Graphics
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1028
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1029
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1030
SimileAjax.Graphics = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1031
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1032
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1033
 * A boolean value indicating whether PNG translucency is supported on the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1034
 * user's browser or not.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1035
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1036
 * @type Boolean
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1037
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1038
SimileAjax.Graphics.pngIsTranslucent = (!SimileAjax.Platform.browser.isIE) || (SimileAjax.Platform.browser.majorVersion > 6);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1039
if (!SimileAjax.Graphics.pngIsTranslucent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1040
    SimileAjax.includeCssFile(document, SimileAjax.urlPrefix + "styles/graphics-ie6.css");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1041
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1042
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1043
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1044
 *  Opacity, translucency
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1045
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1046
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1047
SimileAjax.Graphics._createTranslucentImage1 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1048
    var elmt = document.createElement("img");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1049
    elmt.setAttribute("src", url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1050
    if (verticalAlign != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1051
        elmt.style.verticalAlign = verticalAlign;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1052
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1053
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1054
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1055
SimileAjax.Graphics._createTranslucentImage2 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1056
    var elmt = document.createElement("img");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1057
    elmt.style.width = "1px";  // just so that IE will calculate the size property
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1058
    elmt.style.height = "1px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1059
    elmt.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url +"', sizingMethod='image')";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1060
    elmt.style.verticalAlign = (verticalAlign != null) ? verticalAlign : "middle";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1061
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1062
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1063
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1064
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1065
 * Creates a DOM element for an <code>img</code> tag using the URL given. This
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1066
 * is a convenience method that automatically includes the necessary CSS to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1067
 * allow for translucency, even on IE.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1068
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1069
 * @function
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1070
 * @param {String} url the URL to the image
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1071
 * @param {String} verticalAlign the CSS value for the image's vertical-align
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1072
 * @return {Element} a DOM element containing the <code>img</code> tag
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1073
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1074
SimileAjax.Graphics.createTranslucentImage = SimileAjax.Graphics.pngIsTranslucent ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1075
    SimileAjax.Graphics._createTranslucentImage1 :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1076
    SimileAjax.Graphics._createTranslucentImage2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1078
SimileAjax.Graphics._createTranslucentImageHTML1 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1079
    return "<img src=\"" + url + "\"" +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1080
        (verticalAlign != null ? " style=\"vertical-align: " + verticalAlign + ";\"" : "") +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1081
        " />";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1082
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1083
SimileAjax.Graphics._createTranslucentImageHTML2 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1084
    var style =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1085
        "width: 1px; height: 1px; " +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1086
        "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url +"', sizingMethod='image');" +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1087
        (verticalAlign != null ? " vertical-align: " + verticalAlign + ";" : "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1088
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1089
    return "<img src='" + url + "' style=\"" + style + "\" />";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1090
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1091
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1092
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1093
 * Creates an HTML string for an <code>img</code> tag using the URL given.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1094
 * This is a convenience method that automatically includes the necessary CSS
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1095
 * to allow for translucency, even on IE.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1096
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1097
 * @function
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1098
 * @param {String} url the URL to the image
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1099
 * @param {String} verticalAlign the CSS value for the image's vertical-align
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1100
 * @return {String} a string containing the <code>img</code> tag
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1101
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1102
SimileAjax.Graphics.createTranslucentImageHTML = SimileAjax.Graphics.pngIsTranslucent ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1103
    SimileAjax.Graphics._createTranslucentImageHTML1 :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1104
    SimileAjax.Graphics._createTranslucentImageHTML2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1105
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1106
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1107
 * Sets the opacity on the given DOM element.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1108
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1109
 * @param {Element} elmt the DOM element to set the opacity on
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1110
 * @param {Number} opacity an integer from 0 to 100 specifying the opacity
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1111
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1112
SimileAjax.Graphics.setOpacity = function(elmt, opacity) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1113
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1114
        elmt.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Style=0,Opacity=" + opacity + ")";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1115
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1116
        var o = (opacity / 100).toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1117
        elmt.style.opacity = o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1118
        elmt.style.MozOpacity = o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1119
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1120
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1121
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1122
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1123
 *  Bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1124
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1125
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1126
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1127
SimileAjax.Graphics.bubbleConfig = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1128
    containerCSSClass:              "simileAjax-bubble-container",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1129
    innerContainerCSSClass:         "simileAjax-bubble-innerContainer",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1130
    contentContainerCSSClass:       "simileAjax-bubble-contentContainer",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1131
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1132
    borderGraphicSize:              50,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1133
    borderGraphicCSSClassPrefix:    "simileAjax-bubble-border-",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1134
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1135
    arrowGraphicTargetOffset:       33,  // from tip of arrow to the side of the graphic that touches the content of the bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1136
    arrowGraphicLength:             100, // dimension of arrow graphic along the direction that the arrow points
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1137
    arrowGraphicWidth:              49,  // dimension of arrow graphic perpendicular to the direction that the arrow points
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1138
    arrowGraphicCSSClassPrefix:     "simileAjax-bubble-arrow-",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1139
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1140
    closeGraphicCSSClass:           "simileAjax-bubble-close",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1141
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1142
    extraPadding:                   20
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1143
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1144
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1145
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1146
 * Creates a nice, rounded bubble popup with the given content in a div,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1147
 * page coordinates and a suggested width. The bubble will point to the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1148
 * location on the page as described by pageX and pageY.  All measurements
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1149
 * should be given in pixels.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1150
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1151
 * @param {Element} the content div
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1152
 * @param {Number} pageX the x coordinate of the point to point to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1153
 * @param {Number} pageY the y coordinate of the point to point to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1154
 * @param {Number} contentWidth a suggested width of the content
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1155
 * @param {String} orientation a string ("top", "bottom", "left", or "right")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1156
 *   that describes the orientation of the arrow on the bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1157
 * @param {Number} maxHeight. Add a scrollbar div if bubble would be too tall.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1158
 *   Default of 0 or null means no maximum
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1159
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1160
SimileAjax.Graphics.createBubbleForContentAndPoint = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1161
       div, pageX, pageY, contentWidth, orientation, maxHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1162
    if (typeof contentWidth != "number") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1163
        contentWidth = 300;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1164
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1165
    if (typeof maxHeight != "number") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1166
        maxHeight = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1167
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1168
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1169
    div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1170
    div.style.left = "-5000px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1171
    div.style.top = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1172
    div.style.width = contentWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1173
    document.body.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1174
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1175
    window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1176
        var width = div.scrollWidth + 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1177
        var height = div.scrollHeight + 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1178
        var scrollDivW = 0; // width of the possible inner container when we want vertical scrolling
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1179
        if (maxHeight > 0 && height > maxHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1180
          height = maxHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1181
          scrollDivW = width - 25;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1182
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1184
        var bubble = SimileAjax.Graphics.createBubbleForPoint(pageX, pageY, width, height, orientation);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1185
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1186
        document.body.removeChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1187
        div.style.position = "static";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1188
        div.style.left = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1189
        div.style.top = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1190
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1191
        // create a scroll div if needed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1192
        if (scrollDivW > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1193
          var scrollDiv = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1194
          div.style.width = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1195
          scrollDiv.style.width = scrollDivW + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1196
          scrollDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1197
          bubble.content.appendChild(scrollDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1198
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1199
          div.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1200
          bubble.content.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1201
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1202
    }, 200);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1203
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1204
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1205
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1206
 * Creates a nice, rounded bubble popup with the given page coordinates and
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1207
 * content dimensions.  The bubble will point to the location on the page
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1208
 * as described by pageX and pageY.  All measurements should be given in
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1209
 * pixels.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1210
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1211
 * @param {Number} pageX the x coordinate of the point to point to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1212
 * @param {Number} pageY the y coordinate of the point to point to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1213
 * @param {Number} contentWidth the width of the content box in the bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1214
 * @param {Number} contentHeight the height of the content box in the bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1215
 * @param {String} orientation a string ("top", "bottom", "left", or "right")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1216
 *   that describes the orientation of the arrow on the bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1217
 * @return {Element} a DOM element for the newly created bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1218
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1219
SimileAjax.Graphics.createBubbleForPoint = function(pageX, pageY, contentWidth, contentHeight, orientation) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1220
    contentWidth = parseInt(contentWidth, 10); // harden against bad input bugs
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1221
    contentHeight = parseInt(contentHeight, 10); // getting numbers-as-strings
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1222
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1223
    var bubbleConfig = SimileAjax.Graphics.bubbleConfig;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1224
    var pngTransparencyClassSuffix =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1225
        SimileAjax.Graphics.pngIsTranslucent ? "pngTranslucent" : "pngNotTranslucent";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1226
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1227
    var bubbleWidth = contentWidth + 2 * bubbleConfig.borderGraphicSize;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1228
    var bubbleHeight = contentHeight + 2 * bubbleConfig.borderGraphicSize;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1229
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1230
    var generatePngSensitiveClass = function(className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1231
        return className + " " + className + "-" + pngTransparencyClassSuffix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1232
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1233
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1234
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1235
     *  Render container divs
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1236
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1237
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1238
    div.className = generatePngSensitiveClass(bubbleConfig.containerCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1239
    div.style.width = contentWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1240
    div.style.height = contentHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1241
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1242
    var divInnerContainer = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1243
    divInnerContainer.className = generatePngSensitiveClass(bubbleConfig.innerContainerCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1244
    div.appendChild(divInnerContainer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1245
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1246
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1247
     *  Create layer for bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1248
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1249
    var close = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1250
        if (!bubble._closed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1251
            document.body.removeChild(bubble._div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1252
            bubble._doc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1253
            bubble._div = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1254
            bubble._content = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1255
            bubble._closed = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1256
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1257
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1258
    var bubble = { _closed: false };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1259
    var layer = SimileAjax.WindowManager.pushLayer(close, true, div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1260
    bubble._div = div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1261
    bubble.close = function() { SimileAjax.WindowManager.popLayer(layer); }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1262
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1263
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1264
     *  Render border graphics
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1265
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1266
    var createBorder = function(classNameSuffix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1267
        var divBorderGraphic = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1268
        divBorderGraphic.className = generatePngSensitiveClass(bubbleConfig.borderGraphicCSSClassPrefix + classNameSuffix);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1269
        divInnerContainer.appendChild(divBorderGraphic);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1270
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1271
    createBorder("top-left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1272
    createBorder("top-right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1273
    createBorder("bottom-left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1274
    createBorder("bottom-right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1275
    createBorder("left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1276
    createBorder("right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1277
    createBorder("top");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1278
    createBorder("bottom");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1279
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1280
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1281
     *  Render content
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1282
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1283
    var divContentContainer = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1284
    divContentContainer.className = generatePngSensitiveClass(bubbleConfig.contentContainerCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1285
    divInnerContainer.appendChild(divContentContainer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1286
    bubble.content = divContentContainer;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1287
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1288
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1289
     *  Render close button
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1290
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1291
    var divClose = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1292
    divClose.className = generatePngSensitiveClass(bubbleConfig.closeGraphicCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1293
    divInnerContainer.appendChild(divClose);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1294
    SimileAjax.WindowManager.registerEventWithObject(divClose, "click", bubble, "close");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1295
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1296
    (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1297
        var dims = SimileAjax.Graphics.getWindowDimensions();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1298
        var docWidth = dims.w;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1299
        var docHeight = dims.h;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1300
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1301
        var halfArrowGraphicWidth = Math.ceil(bubbleConfig.arrowGraphicWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1302
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1303
        var createArrow = function(classNameSuffix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1304
            var divArrowGraphic = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1305
            divArrowGraphic.className = generatePngSensitiveClass(bubbleConfig.arrowGraphicCSSClassPrefix + "point-" + classNameSuffix);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1306
            divInnerContainer.appendChild(divArrowGraphic);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1307
            return divArrowGraphic;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1308
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1309
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1310
        if (pageX - halfArrowGraphicWidth - bubbleConfig.borderGraphicSize - bubbleConfig.extraPadding > 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1311
            pageX + halfArrowGraphicWidth + bubbleConfig.borderGraphicSize + bubbleConfig.extraPadding < docWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1312
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1313
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1314
             *  Bubble can be positioned above or below the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1315
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1316
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1317
            var left = pageX - Math.round(contentWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1318
            left = pageX < (docWidth / 2) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1319
                Math.max(left, bubbleConfig.extraPadding + bubbleConfig.borderGraphicSize) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1320
                Math.min(left, docWidth - bubbleConfig.extraPadding - bubbleConfig.borderGraphicSize - contentWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1321
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1322
            if ((orientation && orientation == "top") ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1323
                (!orientation &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1324
                    (pageY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1325
                        - bubbleConfig.arrowGraphicTargetOffset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1326
                        - contentHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1327
                        - bubbleConfig.borderGraphicSize
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1328
                        - bubbleConfig.extraPadding > 0))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1329
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1330
                /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1331
                 *  Position bubble above the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1332
                 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1333
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1334
                var divArrow = createArrow("down");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1335
                divArrow.style.left = (pageX - halfArrowGraphicWidth - left) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1336
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1337
                div.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1338
                div.style.top = (pageY - bubbleConfig.arrowGraphicTargetOffset - contentHeight) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1339
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1340
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1341
            } else if ((orientation && orientation == "bottom") ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1342
                (!orientation &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1343
                    (pageY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1344
                        + bubbleConfig.arrowGraphicTargetOffset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1345
                        + contentHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1346
                        + bubbleConfig.borderGraphicSize
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1347
                        + bubbleConfig.extraPadding < docHeight))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1348
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1349
                /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1350
                 *  Position bubble below the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1351
                 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1352
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1353
                var divArrow = createArrow("up");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1354
                divArrow.style.left = (pageX - halfArrowGraphicWidth - left) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1355
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1356
                div.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1357
                div.style.top = (pageY + bubbleConfig.arrowGraphicTargetOffset) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1358
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1359
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1360
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1361
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1362
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1363
        var top = pageY - Math.round(contentHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1364
        top = pageY < (docHeight / 2) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1365
            Math.max(top, bubbleConfig.extraPadding + bubbleConfig.borderGraphicSize) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1366
            Math.min(top, docHeight - bubbleConfig.extraPadding - bubbleConfig.borderGraphicSize - contentHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1367
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1368
        if ((orientation && orientation == "left") ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1369
            (!orientation &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1370
                (pageX
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1371
                    - bubbleConfig.arrowGraphicTargetOffset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1372
                    - contentWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1373
                    - bubbleConfig.borderGraphicSize
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1374
                    - bubbleConfig.extraPadding > 0))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1375
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1376
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1377
             *  Position bubble left of the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1378
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1379
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1380
            var divArrow = createArrow("right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1381
            divArrow.style.top = (pageY - halfArrowGraphicWidth - top) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1382
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1383
            div.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1384
            div.style.left = (pageX - bubbleConfig.arrowGraphicTargetOffset - contentWidth) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1385
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1386
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1387
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1388
             *  Position bubble right of the target point, as the last resort.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1389
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1390
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1391
            var divArrow = createArrow("left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1392
            divArrow.style.top = (pageY - halfArrowGraphicWidth - top) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1393
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1394
            div.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1395
            div.style.left = (pageX + bubbleConfig.arrowGraphicTargetOffset) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1396
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1397
    })();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1398
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1399
    document.body.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1400
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1401
    return bubble;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1402
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1403
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1404
SimileAjax.Graphics.getWindowDimensions = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1405
    if (typeof window.innerHeight == 'number') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1406
        return { w:window.innerWidth, h:window.innerHeight }; // Non-IE
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1407
    } else if (document.documentElement && document.documentElement.clientHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1408
        return { // IE6+, in "standards compliant mode"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1409
            w:document.documentElement.clientWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1410
            h:document.documentElement.clientHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1411
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1412
    } else if (document.body && document.body.clientHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1413
        return { // IE 4 compatible
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1414
            w:document.body.clientWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1415
            h:document.body.clientHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1416
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1417
    }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1418
};
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1419
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1420
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1421
/**
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1422
 * Creates a floating, rounded message bubble in the center of the window for
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1423
 * displaying modal information, e.g. "Loading..."
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1424
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1425
 * @param {Document} doc the root document for the page to render on
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1426
 * @param {Object} an object with two properties, contentDiv and containerDiv,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1427
 *   consisting of the newly created DOM elements
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1428
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1429
SimileAjax.Graphics.createMessageBubble = function(doc) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1430
    var containerDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1431
    if (SimileAjax.Graphics.pngIsTranslucent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1432
        var topDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1433
        topDiv.style.height = "33px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1434
        topDiv.style.background = "url(" + SimileAjax.urlPrefix + "images/message-top-left.png) top left no-repeat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1435
        topDiv.style.paddingLeft = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1436
        containerDiv.appendChild(topDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1437
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1438
        var topRightDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1439
        topRightDiv.style.height = "33px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1440
        topRightDiv.style.background = "url(" + SimileAjax.urlPrefix + "images/message-top-right.png) top right no-repeat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1441
        topDiv.appendChild(topRightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1442
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1443
        var middleDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1444
        middleDiv.style.background = "url(" + SimileAjax.urlPrefix + "images/message-left.png) top left repeat-y";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1445
        middleDiv.style.paddingLeft = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1446
        containerDiv.appendChild(middleDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1447
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1448
        var middleRightDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1449
        middleRightDiv.style.background = "url(" + SimileAjax.urlPrefix + "images/message-right.png) top right repeat-y";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1450
        middleRightDiv.style.paddingRight = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1451
        middleDiv.appendChild(middleRightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1452
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1453
        var contentDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1454
        middleRightDiv.appendChild(contentDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1455
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1456
        var bottomDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1457
        bottomDiv.style.height = "55px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1458
        bottomDiv.style.background = "url(" + SimileAjax.urlPrefix + "images/message-bottom-left.png) bottom left no-repeat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1459
        bottomDiv.style.paddingLeft = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1460
        containerDiv.appendChild(bottomDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1461
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1462
        var bottomRightDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1463
        bottomRightDiv.style.height = "55px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1464
        bottomRightDiv.style.background = "url(" + SimileAjax.urlPrefix + "images/message-bottom-right.png) bottom right no-repeat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1465
        bottomDiv.appendChild(bottomRightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1466
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1467
        containerDiv.style.border = "2px solid #7777AA";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1468
        containerDiv.style.padding = "20px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1469
        containerDiv.style.background = "white";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1470
        SimileAjax.Graphics.setOpacity(containerDiv, 90);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1471
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1472
        var contentDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1473
        containerDiv.appendChild(contentDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1474
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1475
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1476
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1477
        containerDiv:   containerDiv,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1478
        contentDiv:     contentDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1479
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1480
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1481
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1482
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1483
 *  Animation
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1484
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1485
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1486
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1487
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1488
 * Creates an animation for a function, and an interval of values.  The word
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1489
 * "animation" here is used in the sense of repeatedly calling a function with
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1490
 * a current value from within an interval, and a delta value.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1491
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1492
 * @param {Function} f a function to be called every 50 milliseconds throughout
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1493
 *   the animation duration, of the form f(current, delta), where current is
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1494
 *   the current value within the range and delta is the current change.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1495
 * @param {Number} from a starting value
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1496
 * @param {Number} to an ending value
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1497
 * @param {Number} duration the duration of the animation in milliseconds
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1498
 * @param {Function} [cont] an optional function that is called at the end of
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1499
 *   the animation, i.e. a continuation.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1500
 * @return {SimileAjax.Graphics._Animation} a new animation object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1501
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1502
SimileAjax.Graphics.createAnimation = function(f, from, to, duration, cont) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1503
    return new SimileAjax.Graphics._Animation(f, from, to, duration, cont);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1504
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1505
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1506
SimileAjax.Graphics._Animation = function(f, from, to, duration, cont) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1507
    this.f = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1508
    this.cont = (typeof cont == "function") ? cont : function() {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1509
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1510
    this.from = from;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1511
    this.to = to;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1512
    this.current = from;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1513
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1514
    this.duration = duration;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1515
    this.start = new Date().getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1516
    this.timePassed = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1517
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1518
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1519
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1520
 * Runs this animation.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1521
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1522
SimileAjax.Graphics._Animation.prototype.run = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1523
    var a = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1524
    window.setTimeout(function() { a.step(); }, 50);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1525
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1526
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1527
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1528
 * Increments this animation by one step, and then continues the animation with
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1529
 * <code>run()</code>.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1530
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1531
SimileAjax.Graphics._Animation.prototype.step = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1532
    this.timePassed += 50;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1533
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1534
    var timePassedFraction = this.timePassed / this.duration;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1535
    var parameterFraction = -Math.cos(timePassedFraction * Math.PI) / 2 + 0.5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1536
    var current = parameterFraction * (this.to - this.from) + this.from;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1537
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1538
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1539
        this.f(current, current - this.current);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1540
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1541
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1542
    this.current = current;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1543
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1544
    if (this.timePassed < this.duration) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1545
        this.run();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1546
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1547
        this.f(this.to, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1548
        this["cont"]();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1549
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1550
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1551
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1552
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1553
 *  CopyPasteButton
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1554
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1555
 *  Adapted from http://spaces.live.com/editorial/rayozzie/demo/liveclip/liveclipsample/techPreview.html.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1556
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1557
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1558
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1559
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1560
 * Creates a button and textarea for displaying structured data and copying it
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1561
 * to the clipboard.  The data is dynamically generated by the given
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1562
 * createDataFunction parameter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1563
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1564
 * @param {String} image an image URL to use as the background for the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1565
 *   generated box
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1566
 * @param {Number} width the width in pixels of the generated box
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1567
 * @param {Number} height the height in pixels of the generated box
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1568
 * @param {Function} createDataFunction a function that is called with no
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1569
 *   arguments to generate the structured data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1570
 * @return a new DOM element
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1571
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1572
SimileAjax.Graphics.createStructuredDataCopyButton = function(image, width, height, createDataFunction) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1573
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1574
    div.style.position = "relative";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1575
    div.style.display = "inline";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1576
    div.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1577
    div.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1578
    div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1579
    div.style.margin = "2px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1580
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1581
    if (SimileAjax.Graphics.pngIsTranslucent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1582
        div.style.background = "url(" + image + ") no-repeat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1583
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1584
        div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image +"', sizingMethod='image')";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1585
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1586
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1587
    var style;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1588
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1589
        style = "filter:alpha(opacity=0)";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1590
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1591
        style = "opacity: 0";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1592
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1593
    div.innerHTML = "<textarea rows='1' autocomplete='off' value='none' style='" + style + "' />";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1594
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1595
    var textarea = div.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1596
    textarea.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1597
    textarea.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1598
    textarea.onmousedown = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1599
        evt = (evt) ? evt : ((event) ? event : null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1600
        if (evt.button == 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1601
            textarea.value = createDataFunction();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1602
            textarea.select();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1603
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1604
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1605
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1606
    return div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1607
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1608
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1609
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1610
 *  getWidthHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1611
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1612
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1613
SimileAjax.Graphics.getWidthHeight = function(el) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1614
    // RETURNS hash {width:  w, height: h} in pixels
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1615
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1616
    var w, h;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1617
    // offsetWidth rounds on FF, so doesn't work for us.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1618
    // See https://bugzilla.mozilla.org/show_bug.cgi?id=458617
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1619
    if (el.getBoundingClientRect == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1620
    	// use offsetWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1621
      w = el.offsetWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1622
      h = el.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1623
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1624
    	// use getBoundingClientRect
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1625
      var rect = el.getBoundingClientRect();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1626
      w = Math.ceil(rect.right - rect.left);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1627
    	h = Math.ceil(rect.bottom - rect.top);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1628
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1629
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1630
        width:  w,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1631
        height: h
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1632
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1633
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1634
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1635
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1636
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1637
 *  FontRenderingContext
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1638
 *==================================================
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1639
 */
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1640
SimileAjax.Graphics.getFontRenderingContext = function(elmt, width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1641
    return new SimileAjax.Graphics._FontRenderingContext(elmt, width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1642
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1643
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1644
SimileAjax.Graphics._FontRenderingContext = function(elmt, width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1645
    this._elmt = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1646
    this._elmt.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1647
    if (typeof width == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1648
        this._elmt.style.width = width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1649
    } else if (typeof width == "number") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1650
        this._elmt.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1651
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1652
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1653
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1654
SimileAjax.Graphics._FontRenderingContext.prototype.dispose = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1655
    this._elmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1656
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1657
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1658
SimileAjax.Graphics._FontRenderingContext.prototype.update = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1659
    this._elmt.innerHTML = "A";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1660
    this._lineHeight = this._elmt.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1661
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1662
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1663
SimileAjax.Graphics._FontRenderingContext.prototype.computeSize = function(text, className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1664
    // className arg is optional
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1665
    var el = this._elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1666
    el.innerHTML = text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1667
    el.className = className === undefined ? '' : className;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1668
    var wh = SimileAjax.Graphics.getWidthHeight(el);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1669
    el.className = ''; // reset for the next guy
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1670
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1671
    return wh;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1672
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1673
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1674
SimileAjax.Graphics._FontRenderingContext.prototype.getLineHeight = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1675
    return this._lineHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1676
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1677
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1678
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1679
 * @fileOverview A collection of date/time utility functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1680
 * @name SimileAjax.DateTime
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1681
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1682
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1683
SimileAjax.DateTime = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1684
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1685
SimileAjax.DateTime.MILLISECOND    = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1686
SimileAjax.DateTime.SECOND         = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1687
SimileAjax.DateTime.MINUTE         = 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1688
SimileAjax.DateTime.HOUR           = 3;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1689
SimileAjax.DateTime.DAY            = 4;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1690
SimileAjax.DateTime.WEEK           = 5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1691
SimileAjax.DateTime.MONTH          = 6;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1692
SimileAjax.DateTime.YEAR           = 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1693
SimileAjax.DateTime.DECADE         = 8;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1694
SimileAjax.DateTime.CENTURY        = 9;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1695
SimileAjax.DateTime.MILLENNIUM     = 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1696
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1697
SimileAjax.DateTime.EPOCH          = -1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1698
SimileAjax.DateTime.ERA            = -2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1699
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1700
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1701
 * An array of unit lengths, expressed in milliseconds, of various lengths of
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1702
 * time.  The array indices are predefined and stored as properties of the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1703
 * SimileAjax.DateTime object, e.g. SimileAjax.DateTime.YEAR.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1704
 * @type Array
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1705
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1706
SimileAjax.DateTime.gregorianUnitLengths = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1707
    (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1708
        var d = SimileAjax.DateTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1709
        var a = d.gregorianUnitLengths;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1710
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1711
        a[d.MILLISECOND] = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1712
        a[d.SECOND]      = 1000;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1713
        a[d.MINUTE]      = a[d.SECOND] * 60;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1714
        a[d.HOUR]        = a[d.MINUTE] * 60;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1715
        a[d.DAY]         = a[d.HOUR] * 24;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1716
        a[d.WEEK]        = a[d.DAY] * 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1717
        a[d.MONTH]       = a[d.DAY] * 31;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1718
        a[d.YEAR]        = a[d.DAY] * 365;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1719
        a[d.DECADE]      = a[d.YEAR] * 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1720
        a[d.CENTURY]     = a[d.YEAR] * 100;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1721
        a[d.MILLENNIUM]  = a[d.YEAR] * 1000;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1722
    })();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1723
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1724
SimileAjax.DateTime._dateRegexp = new RegExp(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1725
    "^(-?)([0-9]{4})(" + [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1726
        "(-?([0-9]{2})(-?([0-9]{2}))?)", // -month-dayOfMonth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1727
        "(-?([0-9]{3}))",                // -dayOfYear
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1728
        "(-?W([0-9]{2})(-?([1-7]))?)"    // -Wweek-dayOfWeek
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1729
    ].join("|") + ")?$"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1730
);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1731
SimileAjax.DateTime._timezoneRegexp = new RegExp(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1732
    "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1733
);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1734
SimileAjax.DateTime._timeRegexp = new RegExp(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1735
    "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(\.([0-9]+))?)?)?$"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1736
);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1737
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1738
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1739
 * Takes a date object and a string containing an ISO 8601 date and sets the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1740
 * the date using information parsed from the string.  Note that this method
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1741
 * does not parse any time information.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1742
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1743
 * @param {Date} dateObject the date object to modify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1744
 * @param {String} string an ISO 8601 string to parse
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1745
 * @return {Date} the modified date object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1746
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1747
SimileAjax.DateTime.setIso8601Date = function(dateObject, string) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1748
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1749
     *  This function has been adapted from dojo.date, v.0.3.0
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1750
     *  http://dojotoolkit.org/.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1751
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1752
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1753
    var d = string.match(SimileAjax.DateTime._dateRegexp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1754
    if(!d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1755
        throw new Error("Invalid date string: " + string);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1756
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1757
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1758
    var sign = (d[1] == "-") ? -1 : 1; // BC or AD
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1759
    var year = sign * d[2];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1760
    var month = d[5];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1761
    var date = d[7];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1762
    var dayofyear = d[9];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1763
    var week = d[11];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1764
    var dayofweek = (d[13]) ? d[13] : 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1765
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1766
    dateObject.setUTCFullYear(year);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1767
    if (dayofyear) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1768
        dateObject.setUTCMonth(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1769
        dateObject.setUTCDate(Number(dayofyear));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1770
    } else if (week) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1771
        dateObject.setUTCMonth(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1772
        dateObject.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1773
        var gd = dateObject.getUTCDay();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1774
        var day =  (gd) ? gd : 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1775
        var offset = Number(dayofweek) + (7 * Number(week));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1776
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1777
        if (day <= 4) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1778
            dateObject.setUTCDate(offset + 1 - day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1779
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1780
            dateObject.setUTCDate(offset + 8 - day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1781
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1782
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1783
        if (month) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1784
            dateObject.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1785
            dateObject.setUTCMonth(month - 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1786
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1787
        if (date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1788
            dateObject.setUTCDate(date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1789
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1790
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1791
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1792
    return dateObject;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1793
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1794
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1795
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1796
 * Takes a date object and a string containing an ISO 8601 time and sets the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1797
 * the time using information parsed from the string.  Note that this method
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1798
 * does not parse any date information.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1799
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1800
 * @param {Date} dateObject the date object to modify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1801
 * @param {String} string an ISO 8601 string to parse
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1802
 * @return {Date} the modified date object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1803
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1804
SimileAjax.DateTime.setIso8601Time = function (dateObject, string) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1805
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1806
     *  This function has been adapted from dojo.date, v.0.3.0
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1807
     *  http://dojotoolkit.org/.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1808
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1809
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1810
    var d = string.match(SimileAjax.DateTime._timeRegexp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1811
    if(!d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1812
        SimileAjax.Debug.warn("Invalid time string: " + string);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1813
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1814
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1815
    var hours = d[1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1816
    var mins = Number((d[3]) ? d[3] : 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1817
    var secs = (d[5]) ? d[5] : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1818
    var ms = d[7] ? (Number("0." + d[7]) * 1000) : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1819
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1820
    dateObject.setUTCHours(hours);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1821
    dateObject.setUTCMinutes(mins);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1822
    dateObject.setUTCSeconds(secs);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1823
    dateObject.setUTCMilliseconds(ms);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1824
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1825
    return dateObject;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1826
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1827
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1828
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1829
 * The timezone offset in minutes in the user's browser.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1830
 * @type Number
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1831
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1832
SimileAjax.DateTime.timezoneOffset = new Date().getTimezoneOffset();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1833
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1834
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1835
 * Takes a date object and a string containing an ISO 8601 date and time and
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1836
 * sets the date object using information parsed from the string.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1837
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1838
 * @param {Date} dateObject the date object to modify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1839
 * @param {String} string an ISO 8601 string to parse
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1840
 * @return {Date} the modified date object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1841
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1842
SimileAjax.DateTime.setIso8601 = function (dateObject, string){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1843
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1844
     *  This function has been adapted from dojo.date, v.0.3.0
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1845
     *  http://dojotoolkit.org/.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1846
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1847
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1848
    var offset = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1849
    var comps = (string.indexOf("T") == -1) ? string.split(" ") : string.split("T");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1850
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1851
    SimileAjax.DateTime.setIso8601Date(dateObject, comps[0]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1852
    if (comps.length == 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1853
        // first strip timezone info from the end
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1854
        var d = comps[1].match(SimileAjax.DateTime._timezoneRegexp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1855
        if (d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1856
            if (d[0] == 'Z') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1857
                offset = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1858
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1859
                offset = (Number(d[3]) * 60) + Number(d[5]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1860
                offset *= ((d[2] == '-') ? 1 : -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1861
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1862
            comps[1] = comps[1].substr(0, comps[1].length - d[0].length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1863
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1864
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1865
        SimileAjax.DateTime.setIso8601Time(dateObject, comps[1]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1866
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1867
    if (offset == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1868
        offset = dateObject.getTimezoneOffset(); // local time zone if no tz info
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1869
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1870
    dateObject.setTime(dateObject.getTime() + offset * 60000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1871
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1872
    return dateObject;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1873
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1874
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1875
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1876
 * Takes a string containing an ISO 8601 date and returns a newly instantiated
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1877
 * date object with the parsed date and time information from the string.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1878
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1879
 * @param {String} string an ISO 8601 string to parse
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1880
 * @return {Date} a new date object created from the string
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1881
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1882
SimileAjax.DateTime.parseIso8601DateTime = function (string) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1883
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1884
        return SimileAjax.DateTime.setIso8601(new Date(0), string);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1885
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1886
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1887
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1888
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1889
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1890
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1891
 * Takes a string containing a Gregorian date and time and returns a newly
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1892
 * instantiated date object with the parsed date and time information from the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1893
 * string.  If the param is actually an instance of Date instead of a string,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1894
 * simply returns the given date instead.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1895
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1896
 * @param {Object} o an object, to either return or parse as a string
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1897
 * @return {Date} the date object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1898
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1899
SimileAjax.DateTime.parseGregorianDateTime = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1900
    if (o == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1901
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1902
    } else if (o instanceof Date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1903
        return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1904
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1905
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1906
    var s = o.toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1907
    if (s.length > 0 && s.length < 8) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1908
        var space = s.indexOf(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1909
        if (space > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1910
            var year = parseInt(s.substr(0, space));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1911
            var suffix = s.substr(space + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1912
            if (suffix.toLowerCase() == "bc") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1913
                year = 1 - year;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1914
            }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1915
        } else {
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1916
            var year = parseInt(s);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1917
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1918
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1919
        var d = new Date(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1920
        d.setUTCFullYear(year);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1921
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1922
        return d;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1923
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1924
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1925
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1926
        return new Date(Date.parse(s));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1927
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1928
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1929
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1930
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1931
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1932
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1933
 * Rounds date objects down to the nearest interval or multiple of an interval.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1934
 * This method modifies the given date object, converting it to the given
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1935
 * timezone if specified.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1936
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1937
 * @param {Date} date the date object to round
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1938
 * @param {Number} intervalUnit a constant, integer index specifying an
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1939
 *   interval, e.g. SimileAjax.DateTime.HOUR
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1940
 * @param {Number} timeZone a timezone shift, given in hours
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1941
 * @param {Number} multiple a multiple of the interval to round by
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1942
 * @param {Number} firstDayOfWeek an integer specifying the first day of the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1943
 *   week, 0 corresponds to Sunday, 1 to Monday, etc.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1944
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1945
SimileAjax.DateTime.roundDownToInterval = function(date, intervalUnit, timeZone, multiple, firstDayOfWeek) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1946
    var timeShift = timeZone *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1947
        SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1948
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1949
    var date2 = new Date(date.getTime() + timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1950
    var clearInDay = function(d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1951
        d.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1952
        d.setUTCSeconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1953
        d.setUTCMinutes(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1954
        d.setUTCHours(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1955
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1956
    var clearInYear = function(d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1957
        clearInDay(d);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1958
        d.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1959
        d.setUTCMonth(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1960
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1961
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1962
    switch(intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1963
    case SimileAjax.DateTime.MILLISECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1964
        var x = date2.getUTCMilliseconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1965
        date2.setUTCMilliseconds(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1966
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1967
    case SimileAjax.DateTime.SECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1968
        date2.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1969
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1970
        var x = date2.getUTCSeconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1971
        date2.setUTCSeconds(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1972
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1973
    case SimileAjax.DateTime.MINUTE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1974
        date2.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1975
        date2.setUTCSeconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1976
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1977
        var x = date2.getUTCMinutes();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1978
        date2.setTime(date2.getTime() -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1979
            (x % multiple) * SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.MINUTE]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1980
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1981
    case SimileAjax.DateTime.HOUR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1982
        date2.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1983
        date2.setUTCSeconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1984
        date2.setUTCMinutes(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1985
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1986
        var x = date2.getUTCHours();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1987
        date2.setUTCHours(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1988
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1989
    case SimileAjax.DateTime.DAY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1990
        clearInDay(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1991
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1992
    case SimileAjax.DateTime.WEEK:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1993
        clearInDay(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1994
        var d = (date2.getUTCDay() + 7 - firstDayOfWeek) % 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1995
        date2.setTime(date2.getTime() -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1996
            d * SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.DAY]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1997
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1998
    case SimileAjax.DateTime.MONTH:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1999
        clearInDay(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2000
        date2.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2001
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2002
        var x = date2.getUTCMonth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2003
        date2.setUTCMonth(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2004
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2005
    case SimileAjax.DateTime.YEAR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2006
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2007
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2008
        var x = date2.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2009
        date2.setUTCFullYear(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2010
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2011
    case SimileAjax.DateTime.DECADE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2012
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2013
        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 10) * 10);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2014
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2015
    case SimileAjax.DateTime.CENTURY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2016
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2017
        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 100) * 100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2018
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2019
    case SimileAjax.DateTime.MILLENNIUM:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2020
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2021
        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 1000) * 1000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2022
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2023
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2024
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2025
    date.setTime(date2.getTime() - timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2026
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2027
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2028
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2029
 * Rounds date objects up to the nearest interval or multiple of an interval.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2030
 * This method modifies the given date object, converting it to the given
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2031
 * timezone if specified.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2032
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2033
 * @param {Date} date the date object to round
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2034
 * @param {Number} intervalUnit a constant, integer index specifying an
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2035
 *   interval, e.g. SimileAjax.DateTime.HOUR
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2036
 * @param {Number} timeZone a timezone shift, given in hours
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2037
 * @param {Number} multiple a multiple of the interval to round by
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2038
 * @param {Number} firstDayOfWeek an integer specifying the first day of the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2039
 *   week, 0 corresponds to Sunday, 1 to Monday, etc.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2040
 * @see SimileAjax.DateTime.roundDownToInterval
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2041
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2042
SimileAjax.DateTime.roundUpToInterval = function(date, intervalUnit, timeZone, multiple, firstDayOfWeek) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2043
    var originalTime = date.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2044
    SimileAjax.DateTime.roundDownToInterval(date, intervalUnit, timeZone, multiple, firstDayOfWeek);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2045
    if (date.getTime() < originalTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2046
        date.setTime(date.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2047
            SimileAjax.DateTime.gregorianUnitLengths[intervalUnit] * multiple);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2048
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2049
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2050
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2051
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2052
 * Increments a date object by a specified interval, taking into
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2053
 * consideration the timezone.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2054
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2055
 * @param {Date} date the date object to increment
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2056
 * @param {Number} intervalUnit a constant, integer index specifying an
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2057
 *   interval, e.g. SimileAjax.DateTime.HOUR
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2058
 * @param {Number} timeZone the timezone offset in hours
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2059
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2060
SimileAjax.DateTime.incrementByInterval = function(date, intervalUnit, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2061
    timeZone = (typeof timeZone == 'undefined') ? 0 : timeZone;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2062
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2063
    var timeShift = timeZone *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2064
        SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2065
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2066
    var date2 = new Date(date.getTime() + timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2067
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2068
    switch(intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2069
    case SimileAjax.DateTime.MILLISECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2070
        date2.setTime(date2.getTime() + 1)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2071
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2072
    case SimileAjax.DateTime.SECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2073
        date2.setTime(date2.getTime() + 1000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2074
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2075
    case SimileAjax.DateTime.MINUTE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2076
        date2.setTime(date2.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2077
            SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.MINUTE]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2078
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2079
    case SimileAjax.DateTime.HOUR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2080
        date2.setTime(date2.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2081
            SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2082
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2083
    case SimileAjax.DateTime.DAY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2084
        date2.setUTCDate(date2.getUTCDate() + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2085
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2086
    case SimileAjax.DateTime.WEEK:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2087
        date2.setUTCDate(date2.getUTCDate() + 7);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2088
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2089
    case SimileAjax.DateTime.MONTH:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2090
        date2.setUTCMonth(date2.getUTCMonth() + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2091
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2092
    case SimileAjax.DateTime.YEAR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2093
        date2.setUTCFullYear(date2.getUTCFullYear() + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2094
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2095
    case SimileAjax.DateTime.DECADE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2096
        date2.setUTCFullYear(date2.getUTCFullYear() + 10);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2097
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2098
    case SimileAjax.DateTime.CENTURY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2099
        date2.setUTCFullYear(date2.getUTCFullYear() + 100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2100
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2101
    case SimileAjax.DateTime.MILLENNIUM:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2102
        date2.setUTCFullYear(date2.getUTCFullYear() + 1000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2103
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2104
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2105
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2106
    date.setTime(date2.getTime() - timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2107
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2108
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2109
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2110
 * Returns a new date object with the given time offset removed.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2111
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2112
 * @param {Date} date the starting date
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2113
 * @param {Number} timeZone a timezone specified in an hour offset to remove
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2114
 * @return {Date} a new date object with the offset removed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2115
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2116
SimileAjax.DateTime.removeTimeZoneOffset = function(date, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2117
    return new Date(date.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2118
        timeZone * SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2119
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2121
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2122
 * Returns the timezone of the user's browser.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2123
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2124
 * @return {Number} the timezone in the user's locale in hours
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2125
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2126
SimileAjax.DateTime.getTimezone = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2127
    var d = new Date().getTimezoneOffset();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2128
    return d / -60;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2129
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2130
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2131
 *  String Utility Functions and Constants
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2132
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2133
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2134
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2135
String.prototype.trim = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2136
    return this.replace(/^\s+|\s+$/g, '');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2137
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2138
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2139
String.prototype.startsWith = function(prefix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2140
    return this.length >= prefix.length && this.substr(0, prefix.length) == prefix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2141
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2142
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2143
String.prototype.endsWith = function(suffix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2144
    return this.length >= suffix.length && this.substr(this.length - suffix.length) == suffix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2145
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2146
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2147
String.substitute = function(s, objects) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2148
    var result = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2149
    var start = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2150
    while (start < s.length - 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2151
        var percent = s.indexOf("%", start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2152
        if (percent < 0 || percent == s.length - 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2153
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2154
        } else if (percent > start && s.charAt(percent - 1) == "\\") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2155
            result += s.substring(start, percent - 1) + "%";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2156
            start = percent + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2157
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2158
            var n = parseInt(s.charAt(percent + 1));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2159
            if (isNaN(n) || n >= objects.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2160
                result += s.substring(start, percent + 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2161
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2162
                result += s.substring(start, percent) + objects[n].toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2163
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2164
            start = percent + 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2165
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2166
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2167
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2168
    if (start < s.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2169
        result += s.substring(start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2170
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2171
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2172
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2173
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2174
 *  HTML Utility Functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2175
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2176
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2177
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2178
SimileAjax.HTML = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2179
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2180
SimileAjax.HTML._e2uHash = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2181
(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2182
    var e2uHash = SimileAjax.HTML._e2uHash;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2183
    e2uHash['nbsp']= '\u00A0[space]';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2184
    e2uHash['iexcl']= '\u00A1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2185
    e2uHash['cent']= '\u00A2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2186
    e2uHash['pound']= '\u00A3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2187
    e2uHash['curren']= '\u00A4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2188
    e2uHash['yen']= '\u00A5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2189
    e2uHash['brvbar']= '\u00A6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2190
    e2uHash['sect']= '\u00A7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2191
    e2uHash['uml']= '\u00A8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2192
    e2uHash['copy']= '\u00A9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2193
    e2uHash['ordf']= '\u00AA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2194
    e2uHash['laquo']= '\u00AB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2195
    e2uHash['not']= '\u00AC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2196
    e2uHash['shy']= '\u00AD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2197
    e2uHash['reg']= '\u00AE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2198
    e2uHash['macr']= '\u00AF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2199
    e2uHash['deg']= '\u00B0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2200
    e2uHash['plusmn']= '\u00B1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2201
    e2uHash['sup2']= '\u00B2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2202
    e2uHash['sup3']= '\u00B3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2203
    e2uHash['acute']= '\u00B4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2204
    e2uHash['micro']= '\u00B5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2205
    e2uHash['para']= '\u00B6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2206
    e2uHash['middot']= '\u00B7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2207
    e2uHash['cedil']= '\u00B8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2208
    e2uHash['sup1']= '\u00B9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2209
    e2uHash['ordm']= '\u00BA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2210
    e2uHash['raquo']= '\u00BB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2211
    e2uHash['frac14']= '\u00BC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2212
    e2uHash['frac12']= '\u00BD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2213
    e2uHash['frac34']= '\u00BE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2214
    e2uHash['iquest']= '\u00BF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2215
    e2uHash['Agrave']= '\u00C0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2216
    e2uHash['Aacute']= '\u00C1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2217
    e2uHash['Acirc']= '\u00C2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2218
    e2uHash['Atilde']= '\u00C3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2219
    e2uHash['Auml']= '\u00C4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2220
    e2uHash['Aring']= '\u00C5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2221
    e2uHash['AElig']= '\u00C6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2222
    e2uHash['Ccedil']= '\u00C7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2223
    e2uHash['Egrave']= '\u00C8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2224
    e2uHash['Eacute']= '\u00C9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2225
    e2uHash['Ecirc']= '\u00CA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2226
    e2uHash['Euml']= '\u00CB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2227
    e2uHash['Igrave']= '\u00CC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2228
    e2uHash['Iacute']= '\u00CD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2229
    e2uHash['Icirc']= '\u00CE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2230
    e2uHash['Iuml']= '\u00CF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2231
    e2uHash['ETH']= '\u00D0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2232
    e2uHash['Ntilde']= '\u00D1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2233
    e2uHash['Ograve']= '\u00D2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2234
    e2uHash['Oacute']= '\u00D3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2235
    e2uHash['Ocirc']= '\u00D4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2236
    e2uHash['Otilde']= '\u00D5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2237
    e2uHash['Ouml']= '\u00D6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2238
    e2uHash['times']= '\u00D7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2239
    e2uHash['Oslash']= '\u00D8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2240
    e2uHash['Ugrave']= '\u00D9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2241
    e2uHash['Uacute']= '\u00DA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2242
    e2uHash['Ucirc']= '\u00DB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2243
    e2uHash['Uuml']= '\u00DC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2244
    e2uHash['Yacute']= '\u00DD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2245
    e2uHash['THORN']= '\u00DE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2246
    e2uHash['szlig']= '\u00DF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2247
    e2uHash['agrave']= '\u00E0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2248
    e2uHash['aacute']= '\u00E1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2249
    e2uHash['acirc']= '\u00E2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2250
    e2uHash['atilde']= '\u00E3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2251
    e2uHash['auml']= '\u00E4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2252
    e2uHash['aring']= '\u00E5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2253
    e2uHash['aelig']= '\u00E6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2254
    e2uHash['ccedil']= '\u00E7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2255
    e2uHash['egrave']= '\u00E8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2256
    e2uHash['eacute']= '\u00E9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2257
    e2uHash['ecirc']= '\u00EA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2258
    e2uHash['euml']= '\u00EB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2259
    e2uHash['igrave']= '\u00EC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2260
    e2uHash['iacute']= '\u00ED';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2261
    e2uHash['icirc']= '\u00EE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2262
    e2uHash['iuml']= '\u00EF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2263
    e2uHash['eth']= '\u00F0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2264
    e2uHash['ntilde']= '\u00F1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2265
    e2uHash['ograve']= '\u00F2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2266
    e2uHash['oacute']= '\u00F3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2267
    e2uHash['ocirc']= '\u00F4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2268
    e2uHash['otilde']= '\u00F5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2269
    e2uHash['ouml']= '\u00F6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2270
    e2uHash['divide']= '\u00F7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2271
    e2uHash['oslash']= '\u00F8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2272
    e2uHash['ugrave']= '\u00F9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2273
    e2uHash['uacute']= '\u00FA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2274
    e2uHash['ucirc']= '\u00FB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2275
    e2uHash['uuml']= '\u00FC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2276
    e2uHash['yacute']= '\u00FD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2277
    e2uHash['thorn']= '\u00FE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2278
    e2uHash['yuml']= '\u00FF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2279
    e2uHash['quot']= '\u0022';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2280
    e2uHash['amp']= '\u0026';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2281
    e2uHash['lt']= '\u003C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2282
    e2uHash['gt']= '\u003E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2283
    e2uHash['OElig']= '';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2284
    e2uHash['oelig']= '\u0153';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2285
    e2uHash['Scaron']= '\u0160';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2286
    e2uHash['scaron']= '\u0161';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2287
    e2uHash['Yuml']= '\u0178';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2288
    e2uHash['circ']= '\u02C6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2289
    e2uHash['tilde']= '\u02DC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2290
    e2uHash['ensp']= '\u2002';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2291
    e2uHash['emsp']= '\u2003';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2292
    e2uHash['thinsp']= '\u2009';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2293
    e2uHash['zwnj']= '\u200C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2294
    e2uHash['zwj']= '\u200D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2295
    e2uHash['lrm']= '\u200E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2296
    e2uHash['rlm']= '\u200F';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2297
    e2uHash['ndash']= '\u2013';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2298
    e2uHash['mdash']= '\u2014';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2299
    e2uHash['lsquo']= '\u2018';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2300
    e2uHash['rsquo']= '\u2019';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2301
    e2uHash['sbquo']= '\u201A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2302
    e2uHash['ldquo']= '\u201C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2303
    e2uHash['rdquo']= '\u201D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2304
    e2uHash['bdquo']= '\u201E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2305
    e2uHash['dagger']= '\u2020';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2306
    e2uHash['Dagger']= '\u2021';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2307
    e2uHash['permil']= '\u2030';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2308
    e2uHash['lsaquo']= '\u2039';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2309
    e2uHash['rsaquo']= '\u203A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2310
    e2uHash['euro']= '\u20AC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2311
    e2uHash['fnof']= '\u0192';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2312
    e2uHash['Alpha']= '\u0391';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2313
    e2uHash['Beta']= '\u0392';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2314
    e2uHash['Gamma']= '\u0393';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2315
    e2uHash['Delta']= '\u0394';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2316
    e2uHash['Epsilon']= '\u0395';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2317
    e2uHash['Zeta']= '\u0396';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2318
    e2uHash['Eta']= '\u0397';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2319
    e2uHash['Theta']= '\u0398';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2320
    e2uHash['Iota']= '\u0399';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2321
    e2uHash['Kappa']= '\u039A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2322
    e2uHash['Lambda']= '\u039B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2323
    e2uHash['Mu']= '\u039C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2324
    e2uHash['Nu']= '\u039D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2325
    e2uHash['Xi']= '\u039E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2326
    e2uHash['Omicron']= '\u039F';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2327
    e2uHash['Pi']= '\u03A0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2328
    e2uHash['Rho']= '\u03A1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2329
    e2uHash['Sigma']= '\u03A3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2330
    e2uHash['Tau']= '\u03A4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2331
    e2uHash['Upsilon']= '\u03A5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2332
    e2uHash['Phi']= '\u03A6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2333
    e2uHash['Chi']= '\u03A7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2334
    e2uHash['Psi']= '\u03A8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2335
    e2uHash['Omega']= '\u03A9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2336
    e2uHash['alpha']= '\u03B1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2337
    e2uHash['beta']= '\u03B2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2338
    e2uHash['gamma']= '\u03B3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2339
    e2uHash['delta']= '\u03B4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2340
    e2uHash['epsilon']= '\u03B5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2341
    e2uHash['zeta']= '\u03B6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2342
    e2uHash['eta']= '\u03B7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2343
    e2uHash['theta']= '\u03B8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2344
    e2uHash['iota']= '\u03B9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2345
    e2uHash['kappa']= '\u03BA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2346
    e2uHash['lambda']= '\u03BB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2347
    e2uHash['mu']= '\u03BC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2348
    e2uHash['nu']= '\u03BD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2349
    e2uHash['xi']= '\u03BE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2350
    e2uHash['omicron']= '\u03BF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2351
    e2uHash['pi']= '\u03C0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2352
    e2uHash['rho']= '\u03C1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2353
    e2uHash['sigmaf']= '\u03C2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2354
    e2uHash['sigma']= '\u03C3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2355
    e2uHash['tau']= '\u03C4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2356
    e2uHash['upsilon']= '\u03C5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2357
    e2uHash['phi']= '\u03C6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2358
    e2uHash['chi']= '\u03C7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2359
    e2uHash['psi']= '\u03C8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2360
    e2uHash['omega']= '\u03C9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2361
    e2uHash['thetasym']= '\u03D1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2362
    e2uHash['upsih']= '\u03D2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2363
    e2uHash['piv']= '\u03D6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2364
    e2uHash['bull']= '\u2022';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2365
    e2uHash['hellip']= '\u2026';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2366
    e2uHash['prime']= '\u2032';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2367
    e2uHash['Prime']= '\u2033';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2368
    e2uHash['oline']= '\u203E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2369
    e2uHash['frasl']= '\u2044';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2370
    e2uHash['weierp']= '\u2118';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2371
    e2uHash['image']= '\u2111';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2372
    e2uHash['real']= '\u211C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2373
    e2uHash['trade']= '\u2122';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2374
    e2uHash['alefsym']= '\u2135';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2375
    e2uHash['larr']= '\u2190';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2376
    e2uHash['uarr']= '\u2191';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2377
    e2uHash['rarr']= '\u2192';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2378
    e2uHash['darr']= '\u2193';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2379
    e2uHash['harr']= '\u2194';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2380
    e2uHash['crarr']= '\u21B5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2381
    e2uHash['lArr']= '\u21D0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2382
    e2uHash['uArr']= '\u21D1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2383
    e2uHash['rArr']= '\u21D2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2384
    e2uHash['dArr']= '\u21D3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2385
    e2uHash['hArr']= '\u21D4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2386
    e2uHash['forall']= '\u2200';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2387
    e2uHash['part']= '\u2202';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2388
    e2uHash['exist']= '\u2203';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2389
    e2uHash['empty']= '\u2205';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2390
    e2uHash['nabla']= '\u2207';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2391
    e2uHash['isin']= '\u2208';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2392
    e2uHash['notin']= '\u2209';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2393
    e2uHash['ni']= '\u220B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2394
    e2uHash['prod']= '\u220F';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2395
    e2uHash['sum']= '\u2211';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2396
    e2uHash['minus']= '\u2212';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2397
    e2uHash['lowast']= '\u2217';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2398
    e2uHash['radic']= '\u221A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2399
    e2uHash['prop']= '\u221D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2400
    e2uHash['infin']= '\u221E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2401
    e2uHash['ang']= '\u2220';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2402
    e2uHash['and']= '\u2227';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2403
    e2uHash['or']= '\u2228';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2404
    e2uHash['cap']= '\u2229';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2405
    e2uHash['cup']= '\u222A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2406
    e2uHash['int']= '\u222B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2407
    e2uHash['there4']= '\u2234';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2408
    e2uHash['sim']= '\u223C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2409
    e2uHash['cong']= '\u2245';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2410
    e2uHash['asymp']= '\u2248';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2411
    e2uHash['ne']= '\u2260';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2412
    e2uHash['equiv']= '\u2261';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2413
    e2uHash['le']= '\u2264';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2414
    e2uHash['ge']= '\u2265';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2415
    e2uHash['sub']= '\u2282';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2416
    e2uHash['sup']= '\u2283';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2417
    e2uHash['nsub']= '\u2284';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2418
    e2uHash['sube']= '\u2286';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2419
    e2uHash['supe']= '\u2287';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2420
    e2uHash['oplus']= '\u2295';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2421
    e2uHash['otimes']= '\u2297';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2422
    e2uHash['perp']= '\u22A5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2423
    e2uHash['sdot']= '\u22C5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2424
    e2uHash['lceil']= '\u2308';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2425
    e2uHash['rceil']= '\u2309';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2426
    e2uHash['lfloor']= '\u230A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2427
    e2uHash['rfloor']= '\u230B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2428
    e2uHash['lang']= '\u2329';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2429
    e2uHash['rang']= '\u232A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2430
    e2uHash['loz']= '\u25CA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2431
    e2uHash['spades']= '\u2660';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2432
    e2uHash['clubs']= '\u2663';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2433
    e2uHash['hearts']= '\u2665';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2434
    e2uHash['diams']= '\u2666';
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  2435
})();
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2436
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2437
SimileAjax.HTML.deEntify = function(s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2438
    var e2uHash = SimileAjax.HTML._e2uHash;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2439
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2440
    var re = /&(\w+?);/;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2441
    while (re.test(s)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2442
        var m = s.match(re);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2443
        s = s.replace(re, e2uHash[m[1]]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2444
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2445
    return s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2446
};/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2447
 * A basic set (in the mathematical sense) data structure
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2448
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2449
 * @constructor
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2450
 * @param {Array or SimileAjax.Set} [a] an initial collection
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2451
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2452
SimileAjax.Set = function(a) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2453
    this._hash = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2454
    this._count = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2455
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2456
    if (a instanceof Array) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2457
        for (var i = 0; i < a.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2458
            this.add(a[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2459
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2460
    } else if (a instanceof SimileAjax.Set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2461
        this.addSet(a);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2462
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2463
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2464
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2465
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2466
 * Adds the given object to this set, assuming there it does not already exist
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2467
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2468
 * @param {Object} o the object to add
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2469
 * @return {Boolean} true if the object was added, false if not
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2470
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2471
SimileAjax.Set.prototype.add = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2472
    if (!(o in this._hash)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2473
        this._hash[o] = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2474
        this._count++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2475
        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2476
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2477
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2478
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2479
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2480
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2481
 * Adds each element in the given set to this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2482
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2483
 * @param {SimileAjax.Set} set the set of elements to add
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2484
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2485
SimileAjax.Set.prototype.addSet = function(set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2486
    for (var o in set._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2487
        this.add(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2488
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2489
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2490
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2491
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2492
 * Removes the given element from this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2493
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2494
 * @param {Object} o the object to remove
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2495
 * @return {Boolean} true if the object was successfully removed,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2496
 *   false otherwise
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2497
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2498
SimileAjax.Set.prototype.remove = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2499
    if (o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2500
        delete this._hash[o];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2501
        this._count--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2502
        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2503
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2504
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2505
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2506
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2507
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2508
 * Removes the elements in this set that correspond to the elements in the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2509
 * given set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2510
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2511
 * @param {SimileAjax.Set} set the set of elements to remove
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2512
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2513
SimileAjax.Set.prototype.removeSet = function(set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2514
    for (var o in set._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2515
        this.remove(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2516
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2517
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2518
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2519
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2520
 * Removes all elements in this set that are not present in the given set, i.e.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2521
 * modifies this set to the intersection of the two sets
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2522
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2523
 * @param {SimileAjax.Set} set the set to intersect
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2524
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2525
SimileAjax.Set.prototype.retainSet = function(set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2526
    for (var o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2527
        if (!set.contains(o)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2528
            delete this._hash[o];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2529
            this._count--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2530
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2531
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2532
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2533
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2534
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2535
 * Returns whether or not the given element exists in this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2536
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2537
 * @param {SimileAjax.Set} o the object to test for
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2538
 * @return {Boolean} true if the object is present, false otherwise
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2539
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2540
SimileAjax.Set.prototype.contains = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2541
    return (o in this._hash);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2542
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2543
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2544
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2545
 * Returns the number of elements in this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2546
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2547
 * @return {Number} the number of elements in this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2548
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2549
SimileAjax.Set.prototype.size = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2550
    return this._count;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2551
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2552
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2553
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2554
 * Returns the elements of this set as an array
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2555
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2556
 * @return {Array} a new array containing the elements of this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2557
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2558
SimileAjax.Set.prototype.toArray = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2559
    var a = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2560
    for (var o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2561
        a.push(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2562
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2563
    return a;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2564
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2565
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2566
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2567
 * Iterates through the elements of this set, order unspecified, executing the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2568
 * given function on each element until the function returns true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2569
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2570
 * @param {Function} f a function of form f(element)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2571
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2572
SimileAjax.Set.prototype.visit = function(f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2573
    for (var o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2574
        if (f(o) == true) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2575
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2576
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2577
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2578
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2579
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2580
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2581
 * A sorted array data structure
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2582
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2583
 * @constructor
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2584
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2585
SimileAjax.SortedArray = function(compare, initialArray) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2586
    this._a = (initialArray instanceof Array) ? initialArray : [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2587
    this._compare = compare;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2588
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2589
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2590
SimileAjax.SortedArray.prototype.add = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2591
    var sa = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2592
    var index = this.find(function(elmt2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2593
        return sa._compare(elmt2, elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2594
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2595
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2596
    if (index < this._a.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2597
        this._a.splice(index, 0, elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2598
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2599
        this._a.push(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2600
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2601
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2602
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2603
SimileAjax.SortedArray.prototype.remove = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2604
    var sa = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2605
    var index = this.find(function(elmt2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2606
        return sa._compare(elmt2, elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2607
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2608
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2609
    while (index < this._a.length && this._compare(this._a[index], elmt) == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2610
        if (this._a[index] == elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2611
            this._a.splice(index, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2612
            return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2613
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2614
            index++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2615
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2616
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2617
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2618
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2619
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2620
SimileAjax.SortedArray.prototype.removeAll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2621
    this._a = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2622
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2623
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2624
SimileAjax.SortedArray.prototype.elementAt = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2625
    return this._a[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2626
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2627
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2628
SimileAjax.SortedArray.prototype.length = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2629
    return this._a.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2630
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2631
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2632
SimileAjax.SortedArray.prototype.find = function(compare) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2633
    var a = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2634
    var b = this._a.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2635
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2636
    while (a < b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2637
        var mid = Math.floor((a + b) / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2638
        var c = compare(this._a[mid]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2639
        if (mid == a) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2640
            return c < 0 ? a+1 : a;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2641
        } else if (c < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2642
            a = mid;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2643
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2644
            b = mid;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2645
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2646
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2647
    return a;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2648
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2649
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2650
SimileAjax.SortedArray.prototype.getFirst = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2651
    return (this._a.length > 0) ? this._a[0] : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2652
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2653
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2654
SimileAjax.SortedArray.prototype.getLast = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2655
    return (this._a.length > 0) ? this._a[this._a.length - 1] : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2656
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2657
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2658
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2659
 *  Event Index
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2660
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2661
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2662
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2663
SimileAjax.EventIndex = function(unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2664
    var eventIndex = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2665
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2666
    this._unit = (unit != null) ? unit : SimileAjax.NativeDateUnit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2667
    this._events = new SimileAjax.SortedArray(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2668
        function(event1, event2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2669
            return eventIndex._unit.compare(event1.getStart(), event2.getStart());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2670
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2671
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2672
    this._idToEvent = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2673
    this._indexed = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2674
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2675
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2676
SimileAjax.EventIndex.prototype.getUnit = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2677
    return this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2678
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2679
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2680
SimileAjax.EventIndex.prototype.getEvent = function(id) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2681
    return this._idToEvent[id];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2682
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2683
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2684
SimileAjax.EventIndex.prototype.add = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2685
    this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2686
    this._idToEvent[evt.getID()] = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2687
    this._indexed = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2688
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2689
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2690
SimileAjax.EventIndex.prototype.removeAll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2691
    this._events.removeAll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2692
    this._idToEvent = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2693
    this._indexed = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2694
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2695
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2696
SimileAjax.EventIndex.prototype.getCount = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2697
    return this._events.length();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2698
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2699
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2700
SimileAjax.EventIndex.prototype.getIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2701
    if (!this._indexed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2702
        this._index();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2703
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2704
    return new SimileAjax.EventIndex._Iterator(this._events, startDate, endDate, this._unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2705
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2706
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2707
SimileAjax.EventIndex.prototype.getReverseIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2708
    if (!this._indexed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2709
        this._index();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2710
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2711
    return new SimileAjax.EventIndex._ReverseIterator(this._events, startDate, endDate, this._unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2712
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2713
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2714
SimileAjax.EventIndex.prototype.getAllIterator = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2715
    return new SimileAjax.EventIndex._AllIterator(this._events);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2716
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2717
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2718
SimileAjax.EventIndex.prototype.getEarliestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2719
    var evt = this._events.getFirst();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2720
    return (evt == null) ? null : evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2721
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2722
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2723
SimileAjax.EventIndex.prototype.getLatestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2724
    var evt = this._events.getLast();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2725
    if (evt == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2726
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2727
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2728
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2729
    if (!this._indexed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2730
        this._index();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2731
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2732
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2733
    var index = evt._earliestOverlapIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2734
    var date = this._events.elementAt(index).getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2735
    for (var i = index + 1; i < this._events.length(); i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2736
        date = this._unit.later(date, this._events.elementAt(i).getEnd());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2737
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2738
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2739
    return date;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2740
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2741
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2742
SimileAjax.EventIndex.prototype._index = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2743
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2744
     *  For each event, we want to find the earliest preceding
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2745
     *  event that overlaps with it, if any.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2746
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2747
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2748
    var l = this._events.length();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2749
    for (var i = 0; i < l; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2750
        var evt = this._events.elementAt(i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2751
        evt._earliestOverlapIndex = i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2752
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2753
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2754
    var toIndex = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2755
    for (var i = 0; i < l; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2756
        var evt = this._events.elementAt(i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2757
        var end = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2758
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2759
        toIndex = Math.max(toIndex, i + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2760
        while (toIndex < l) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2761
            var evt2 = this._events.elementAt(toIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2762
            var start2 = evt2.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2763
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2764
            if (this._unit.compare(start2, end) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2765
                evt2._earliestOverlapIndex = i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2766
                toIndex++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2767
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2768
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2769
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2770
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2771
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2772
    this._indexed = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2773
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2774
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2775
SimileAjax.EventIndex._Iterator = function(events, startDate, endDate, unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2776
    this._events = events;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2777
    this._startDate = startDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2778
    this._endDate = endDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2779
    this._unit = unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2780
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2781
    this._currentIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2782
        return unit.compare(evt.getStart(), startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2783
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2784
    if (this._currentIndex - 1 >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2785
        this._currentIndex = this._events.elementAt(this._currentIndex - 1)._earliestOverlapIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2786
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2787
    this._currentIndex--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2788
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2789
    this._maxIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2790
        return unit.compare(evt.getStart(), endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2791
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2792
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2793
    this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2794
    this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2795
    this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2796
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2797
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2798
SimileAjax.EventIndex._Iterator.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2799
    hasNext: function() { return this._hasNext; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2800
    next: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2801
        if (this._hasNext) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2802
            var next = this._next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2803
            this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2804
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2805
            return next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2806
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2807
            return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2808
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2809
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2810
    _findNext: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2811
        var unit = this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2812
        while ((++this._currentIndex) < this._maxIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2813
            var evt = this._events.elementAt(this._currentIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2814
            if (unit.compare(evt.getStart(), this._endDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2815
                unit.compare(evt.getEnd(), this._startDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2816
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2817
                this._next = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2818
                this._hasNext = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2819
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2820
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2821
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2822
        this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2823
        this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2824
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2825
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2826
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2827
SimileAjax.EventIndex._ReverseIterator = function(events, startDate, endDate, unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2828
    this._events = events;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2829
    this._startDate = startDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2830
    this._endDate = endDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2831
    this._unit = unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2832
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2833
    this._minIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2834
        return unit.compare(evt.getStart(), startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2835
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2836
    if (this._minIndex - 1 >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2837
        this._minIndex = this._events.elementAt(this._minIndex - 1)._earliestOverlapIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2838
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2839
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2840
    this._maxIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2841
        return unit.compare(evt.getStart(), endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2842
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2843
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2844
    this._currentIndex = this._maxIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2845
    this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2846
    this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2847
    this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2848
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2849
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2850
SimileAjax.EventIndex._ReverseIterator.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2851
    hasNext: function() { return this._hasNext; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2852
    next: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2853
        if (this._hasNext) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2854
            var next = this._next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2855
            this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2856
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2857
            return next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2858
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2859
            return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2860
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2861
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2862
    _findNext: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2863
        var unit = this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2864
        while ((--this._currentIndex) >= this._minIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2865
            var evt = this._events.elementAt(this._currentIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2866
            if (unit.compare(evt.getStart(), this._endDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2867
                unit.compare(evt.getEnd(), this._startDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2868
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2869
                this._next = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2870
                this._hasNext = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2871
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2872
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2873
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2874
        this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2875
        this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2876
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2877
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2878
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2879
SimileAjax.EventIndex._AllIterator = function(events) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2880
    this._events = events;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2881
    this._index = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2882
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2883
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2884
SimileAjax.EventIndex._AllIterator.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2885
    hasNext: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2886
        return this._index < this._events.length();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2887
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2888
    next: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2889
        return this._index < this._events.length() ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2890
            this._events.elementAt(this._index++) : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2891
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2892
};/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2893
 *  Default Unit
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2894
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2895
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2896
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2897
SimileAjax.NativeDateUnit = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2898
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2899
SimileAjax.NativeDateUnit.makeDefaultValue = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2900
    return new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2901
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2902
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2903
SimileAjax.NativeDateUnit.cloneValue = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2904
    return new Date(v.getTime());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2905
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2906
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2907
SimileAjax.NativeDateUnit.getParser = function(format) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2908
    if (typeof format == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2909
        format = format.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2910
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2911
    return (format == "iso8601" || format == "iso 8601") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2912
        SimileAjax.DateTime.parseIso8601DateTime : 
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2913
        SimileAjax.DateTime.parseGregorianDateTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2914
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2915
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2916
SimileAjax.NativeDateUnit.parseFromObject = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2917
    return SimileAjax.DateTime.parseGregorianDateTime(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2918
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2919
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2920
SimileAjax.NativeDateUnit.toNumber = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2921
    return v.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2922
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2923
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2924
SimileAjax.NativeDateUnit.fromNumber = function(n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2925
    return new Date(n);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2926
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2927
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2928
SimileAjax.NativeDateUnit.compare = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2929
    var n1, n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2930
    if (typeof v1 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2931
        n1 = v1.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2932
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2933
        n1 = Number(v1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2934
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2935
    if (typeof v2 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2936
        n2 = v2.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2937
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2938
        n2 = Number(v2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2939
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2940
    
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2941
    return n1 - n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2942
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2943
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2944
SimileAjax.NativeDateUnit.earlier = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2945
    return SimileAjax.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2946
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2947
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2948
SimileAjax.NativeDateUnit.later = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2949
    return SimileAjax.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2950
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2951
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2952
SimileAjax.NativeDateUnit.change = function(v, n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2953
    return new Date(v.getTime() + n);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2954
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2955
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2956
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2957
 *  General, miscellaneous SimileAjax stuff
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2958
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2959
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2960
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2961
SimileAjax.ListenerQueue = function(wildcardHandlerName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2962
    this._listeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2963
    this._wildcardHandlerName = wildcardHandlerName;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2964
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2965
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2966
SimileAjax.ListenerQueue.prototype.add = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2967
    this._listeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2968
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2969
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2970
SimileAjax.ListenerQueue.prototype.remove = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2971
    var listeners = this._listeners;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2972
    for (var i = 0; i < listeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2973
        if (listeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2974
            listeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2975
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2976
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2977
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2978
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2979
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2980
SimileAjax.ListenerQueue.prototype.fire = function(handlerName, args) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2981
    var listeners = [].concat(this._listeners);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2982
    for (var i = 0; i < listeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2983
        var listener = listeners[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2984
        if (handlerName in listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2985
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2986
                listener[handlerName].apply(listener, args);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2987
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2988
                SimileAjax.Debug.exception("Error firing event of name " + handlerName, e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2989
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2990
        } else if (this._wildcardHandlerName != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2991
            this._wildcardHandlerName in listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2992
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2993
                listener[this._wildcardHandlerName].apply(listener, [ handlerName ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2994
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2995
                SimileAjax.Debug.exception("Error firing event of name " + handlerName + " to wildcard handler", e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2996
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2997
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2998
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2999
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3000
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3001
/*======================================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3002
 *  History
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3003
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3004
 *  This is a singleton that keeps track of undoable user actions and
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3005
 *  performs undos and redos in response to the browser's Back and
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3006
 *  Forward buttons.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3007
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3008
 *  Call addAction(action) to register an undoable user action. action
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3009
 *  must have 4 fields:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3010
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3011
 *      perform: an argument-less function that carries out the action
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3012
 *      undo:    an argument-less function that undos the action
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3013
 *      label:   a short, user-friendly string describing the action
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3014
 *      uiLayer: the UI layer on which the action takes place
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3015
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3016
 *  By default, the history keeps track of upto 10 actions. You can
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3017
 *  configure this behavior by setting
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3018
 *      SimileAjax.History.maxHistoryLength
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3019
 *  to a different number.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3020
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3021
 *  An iframe is inserted into the document's body element to track
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3022
 *  onload events.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3023
 *======================================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3024
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3025
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3026
SimileAjax.History = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3027
    maxHistoryLength:       10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3028
    historyFile:            "__history__.html",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3029
    enabled:               true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3030
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3031
    _initialized:           false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3032
    _listeners:             new SimileAjax.ListenerQueue(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3033
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3034
    _actions:               [],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3035
    _baseIndex:             0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3036
    _currentIndex:          0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3037
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3038
    _plainDocumentTitle:    document.title
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3039
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3040
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3041
SimileAjax.History.formatHistoryEntryTitle = function(actionLabel) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3042
    return SimileAjax.History._plainDocumentTitle + " {" + actionLabel + "}";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3043
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3044
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3045
SimileAjax.History.initialize = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3046
    if (SimileAjax.History._initialized) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3047
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3048
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3049
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3050
    if (SimileAjax.History.enabled) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3051
        var iframe = document.createElement("iframe");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3052
        iframe.id = "simile-ajax-history";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3053
        iframe.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3054
        iframe.style.width = "10px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3055
        iframe.style.height = "10px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3056
        iframe.style.top = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3057
        iframe.style.left = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3058
        iframe.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3059
        iframe.src = SimileAjax.History.historyFile + "?0";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3060
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3061
        document.body.appendChild(iframe);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3062
        SimileAjax.DOM.registerEvent(iframe, "load", SimileAjax.History._handleIFrameOnLoad);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3063
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3064
        SimileAjax.History._iframe = iframe;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3065
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3066
    SimileAjax.History._initialized = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3067
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3068
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3069
SimileAjax.History.addListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3070
    SimileAjax.History.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3071
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3072
    SimileAjax.History._listeners.add(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3073
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3074
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3075
SimileAjax.History.removeListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3076
    SimileAjax.History.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3078
    SimileAjax.History._listeners.remove(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3079
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3080
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3081
SimileAjax.History.addAction = function(action) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3082
    SimileAjax.History.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3083
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3084
    SimileAjax.History._listeners.fire("onBeforePerform", [ action ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3085
    window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3086
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3087
            action.perform();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3088
            SimileAjax.History._listeners.fire("onAfterPerform", [ action ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3089
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3090
            if (SimileAjax.History.enabled) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3091
                SimileAjax.History._actions = SimileAjax.History._actions.slice(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3092
                    0, SimileAjax.History._currentIndex - SimileAjax.History._baseIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3093
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3094
                SimileAjax.History._actions.push(action);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3095
                SimileAjax.History._currentIndex++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3096
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3097
                var diff = SimileAjax.History._actions.length - SimileAjax.History.maxHistoryLength;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3098
                if (diff > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3099
                    SimileAjax.History._actions = SimileAjax.History._actions.slice(diff);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3100
                    SimileAjax.History._baseIndex += diff;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3101
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3102
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3103
                try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3104
                    SimileAjax.History._iframe.contentWindow.location.search =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3105
                        "?" + SimileAjax.History._currentIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3106
                } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3107
                    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3108
                     *  We can't modify location.search most probably because it's a file:// url.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3109
                     *  We'll just going to modify the document's title.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3110
                     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3111
                    var title = SimileAjax.History.formatHistoryEntryTitle(action.label);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3112
                    document.title = title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3113
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3114
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3115
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3116
            SimileAjax.Debug.exception(e, "Error adding action {" + action.label + "} to history");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3117
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3118
    }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3119
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3121
SimileAjax.History.addLengthyAction = function(perform, undo, label) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3122
    SimileAjax.History.addAction({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3123
        perform:    perform,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3124
        undo:       undo,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3125
        label:      label,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3126
        uiLayer:    SimileAjax.WindowManager.getBaseLayer(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3127
        lengthy:    true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3128
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3129
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3130
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3131
SimileAjax.History._handleIFrameOnLoad = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3132
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3133
     *  This function is invoked when the user herself
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3134
     *  navigates backward or forward. We need to adjust
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3135
     *  the application's state accordingly.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3136
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3137
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3138
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3139
        var q = SimileAjax.History._iframe.contentWindow.location.search;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3140
        var c = (q.length == 0) ? 0 : Math.max(0, parseInt(q.substr(1)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3141
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3142
        var finishUp = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3143
            var diff = c - SimileAjax.History._currentIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3144
            SimileAjax.History._currentIndex += diff;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3145
            SimileAjax.History._baseIndex += diff;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3146
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3147
            SimileAjax.History._iframe.contentWindow.location.search = "?" + c;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3148
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3149
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3150
        if (c < SimileAjax.History._currentIndex) { // need to undo
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3151
            SimileAjax.History._listeners.fire("onBeforeUndoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3152
            window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3153
                while (SimileAjax.History._currentIndex > c &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3154
                       SimileAjax.History._currentIndex > SimileAjax.History._baseIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3155
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3156
                    SimileAjax.History._currentIndex--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3157
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3158
                    var action = SimileAjax.History._actions[SimileAjax.History._currentIndex - SimileAjax.History._baseIndex];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3159
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3160
                    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3161
                        action.undo();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3162
                    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3163
                        SimileAjax.Debug.exception(e, "History: Failed to undo action {" + action.label + "}");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3164
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3165
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3166
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3167
                SimileAjax.History._listeners.fire("onAfterUndoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3168
                finishUp();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3169
            }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3170
        } else if (c > SimileAjax.History._currentIndex) { // need to redo
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3171
            SimileAjax.History._listeners.fire("onBeforeRedoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3172
            window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3173
                while (SimileAjax.History._currentIndex < c &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3174
                       SimileAjax.History._currentIndex - SimileAjax.History._baseIndex < SimileAjax.History._actions.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3175
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3176
                    var action = SimileAjax.History._actions[SimileAjax.History._currentIndex - SimileAjax.History._baseIndex];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3177
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3178
                    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3179
                        action.perform();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3180
                    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3181
                        SimileAjax.Debug.exception(e, "History: Failed to redo action {" + action.label + "}");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3182
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3184
                    SimileAjax.History._currentIndex++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3185
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3186
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3187
                SimileAjax.History._listeners.fire("onAfterRedoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3188
                finishUp();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3189
            }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3190
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3191
            var index = SimileAjax.History._currentIndex - SimileAjax.History._baseIndex - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3192
            var title = (index >= 0 && index < SimileAjax.History._actions.length) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3193
                SimileAjax.History.formatHistoryEntryTitle(SimileAjax.History._actions[index].label) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3194
                SimileAjax.History._plainDocumentTitle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3195
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3196
            SimileAjax.History._iframe.contentWindow.document.title = title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3197
            document.title = title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3198
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3199
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3200
        // silent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3201
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3202
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3203
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3204
SimileAjax.History.getNextUndoAction = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3205
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3206
        var index = SimileAjax.History._currentIndex - SimileAjax.History._baseIndex - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3207
        return SimileAjax.History._actions[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3208
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3209
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3210
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3211
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3212
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3213
SimileAjax.History.getNextRedoAction = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3214
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3215
        var index = SimileAjax.History._currentIndex - SimileAjax.History._baseIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3216
        return SimileAjax.History._actions[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3217
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3218
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3219
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3220
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3221
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3222
 * @fileOverview UI layers and window-wide dragging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3223
 * @name SimileAjax.WindowManager
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3224
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3225
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3226
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3227
 *  This is a singleton that keeps track of UI layers (modal and
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3228
 *  modeless) and enables/disables UI elements based on which layers
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3229
 *  they belong to. It also provides window-wide dragging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3230
 *  implementation.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3231
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3232
SimileAjax.WindowManager = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3233
    _initialized:       false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3234
    _listeners:         [],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3235
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3236
    _draggedElement:                null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3237
    _draggedElementCallback:        null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3238
    _dropTargetHighlightElement:    null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3239
    _lastCoords:                    null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3240
    _ghostCoords:                   null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3241
    _draggingMode:                  "",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3242
    _dragging:                      false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3243
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3244
    _layers:            []
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3245
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3246
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3247
SimileAjax.WindowManager.initialize = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3248
    if (SimileAjax.WindowManager._initialized) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3249
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3250
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3251
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3252
    SimileAjax.DOM.registerEvent(document.body, "mousedown", SimileAjax.WindowManager._onBodyMouseDown);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3253
    SimileAjax.DOM.registerEvent(document.body, "mousemove", SimileAjax.WindowManager._onBodyMouseMove);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3254
    SimileAjax.DOM.registerEvent(document.body, "mouseup",   SimileAjax.WindowManager._onBodyMouseUp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3255
    SimileAjax.DOM.registerEvent(document, "keydown",       SimileAjax.WindowManager._onBodyKeyDown);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3256
    SimileAjax.DOM.registerEvent(document, "keyup",         SimileAjax.WindowManager._onBodyKeyUp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3257
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3258
    SimileAjax.WindowManager._layers.push({index: 0});
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3259
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3260
    SimileAjax.WindowManager._historyListener = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3261
        onBeforeUndoSeveral:    function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3262
        onAfterUndoSeveral:     function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3263
        onBeforeUndo:           function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3264
        onAfterUndo:            function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3265
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3266
        onBeforeRedoSeveral:    function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3267
        onAfterRedoSeveral:     function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3268
        onBeforeRedo:           function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3269
        onAfterRedo:            function() {}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3270
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3271
    SimileAjax.History.addListener(SimileAjax.WindowManager._historyListener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3272
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3273
    SimileAjax.WindowManager._initialized = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3274
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3275
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3276
SimileAjax.WindowManager.getBaseLayer = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3277
    SimileAjax.WindowManager.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3278
    return SimileAjax.WindowManager._layers[0];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3279
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3280
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3281
SimileAjax.WindowManager.getHighestLayer = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3282
    SimileAjax.WindowManager.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3283
    return SimileAjax.WindowManager._layers[SimileAjax.WindowManager._layers.length - 1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3284
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3285
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3286
SimileAjax.WindowManager.registerEventWithObject = function(elmt, eventName, obj, handlerName, layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3287
    SimileAjax.WindowManager.registerEvent(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3288
        elmt,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3289
        eventName,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3290
        function(elmt2, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3291
            return obj[handlerName].call(obj, elmt2, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3292
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3293
        layer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3294
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3295
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3296
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3297
SimileAjax.WindowManager.registerEvent = function(elmt, eventName, handler, layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3298
    if (layer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3299
        layer = SimileAjax.WindowManager.getHighestLayer();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3300
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3301
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3302
    var handler2 = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3303
        if (SimileAjax.WindowManager._canProcessEventAtLayer(layer)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3304
            SimileAjax.WindowManager._popToLayer(layer.index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3305
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3306
                handler(elmt, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3307
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3308
                SimileAjax.Debug.exception(e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3309
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3310
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3311
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3312
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3313
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3314
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3315
    SimileAjax.DOM.registerEvent(elmt, eventName, handler2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3316
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3317
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3318
SimileAjax.WindowManager.pushLayer = function(f, ephemeral, elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3319
    var layer = { onPop: f, index: SimileAjax.WindowManager._layers.length, ephemeral: (ephemeral), elmt: elmt };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3320
    SimileAjax.WindowManager._layers.push(layer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3321
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3322
    return layer;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3323
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3324
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3325
SimileAjax.WindowManager.popLayer = function(layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3326
    for (var i = 1; i < SimileAjax.WindowManager._layers.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3327
        if (SimileAjax.WindowManager._layers[i] == layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3328
            SimileAjax.WindowManager._popToLayer(i - 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3329
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3330
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3331
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3332
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3333
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3334
SimileAjax.WindowManager.popAllLayers = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3335
    SimileAjax.WindowManager._popToLayer(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3336
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3337
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3338
SimileAjax.WindowManager.registerForDragging = function(elmt, callback, layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3339
    SimileAjax.WindowManager.registerEvent(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3340
        elmt,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3341
        "mousedown",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3342
        function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3343
            SimileAjax.WindowManager._handleMouseDown(elmt, evt, callback);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3344
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3345
        layer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3346
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3347
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3348
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3349
SimileAjax.WindowManager._popToLayer = function(level) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3350
    while (level+1 < SimileAjax.WindowManager._layers.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3351
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3352
            var layer = SimileAjax.WindowManager._layers.pop();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3353
            if (layer.onPop != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3354
                layer.onPop();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3355
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3356
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3357
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3358
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3359
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3360
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3361
SimileAjax.WindowManager._canProcessEventAtLayer = function(layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3362
    if (layer.index == (SimileAjax.WindowManager._layers.length - 1)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3363
        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3364
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3365
    for (var i = layer.index + 1; i < SimileAjax.WindowManager._layers.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3366
        if (!SimileAjax.WindowManager._layers[i].ephemeral) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3367
            return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3368
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3369
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3370
    return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3371
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3372
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3373
SimileAjax.WindowManager.cancelPopups = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3374
    var evtCoords = (evt) ? SimileAjax.DOM.getEventPageCoordinates(evt) : { x: -1, y: -1 };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3375
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3376
    var i = SimileAjax.WindowManager._layers.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3377
    while (i > 0 && SimileAjax.WindowManager._layers[i].ephemeral) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3378
        var layer = SimileAjax.WindowManager._layers[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3379
        if (layer.elmt != null) { // if event falls within main element of layer then don't cancel
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3380
            var elmt = layer.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3381
            var elmtCoords = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3382
            if (evtCoords.x >= elmtCoords.left && evtCoords.x < (elmtCoords.left + elmt.offsetWidth) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3383
                evtCoords.y >= elmtCoords.top && evtCoords.y < (elmtCoords.top + elmt.offsetHeight)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3384
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3385
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3386
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3387
        i--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3388
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3389
    SimileAjax.WindowManager._popToLayer(i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3390
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3391
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3392
SimileAjax.WindowManager._onBodyMouseDown = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3393
    if (!("eventPhase" in evt) || evt.eventPhase == evt.BUBBLING_PHASE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3394
        SimileAjax.WindowManager.cancelPopups(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3395
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3396
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3397
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3398
SimileAjax.WindowManager._handleMouseDown = function(elmt, evt, callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3399
    SimileAjax.WindowManager._draggedElement = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3400
    SimileAjax.WindowManager._draggedElementCallback = callback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3401
    SimileAjax.WindowManager._lastCoords = { x: evt.clientX, y: evt.clientY };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3402
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3403
    SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3404
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3405
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3406
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3407
SimileAjax.WindowManager._onBodyKeyDown = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3408
    if (SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3409
        if (evt.keyCode == 27) { // esc
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3410
            SimileAjax.WindowManager._cancelDragging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3411
        } else if ((evt.keyCode == 17 || evt.keyCode == 16) && SimileAjax.WindowManager._draggingMode != "copy") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3412
            SimileAjax.WindowManager._draggingMode = "copy";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3413
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3414
            var img = SimileAjax.Graphics.createTranslucentImage(SimileAjax.urlPrefix + "images/copy.png");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3415
            img.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3416
            img.style.left = (SimileAjax.WindowManager._ghostCoords.left - 16) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3417
            img.style.top = (SimileAjax.WindowManager._ghostCoords.top) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3418
            document.body.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3419
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3420
            SimileAjax.WindowManager._draggingModeIndicatorElmt = img;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3421
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3422
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3423
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3424
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3425
SimileAjax.WindowManager._onBodyKeyUp = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3426
    if (SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3427
        if (evt.keyCode == 17 || evt.keyCode == 16) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3428
            SimileAjax.WindowManager._draggingMode = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3429
            if (SimileAjax.WindowManager._draggingModeIndicatorElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3430
                document.body.removeChild(SimileAjax.WindowManager._draggingModeIndicatorElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3431
                SimileAjax.WindowManager._draggingModeIndicatorElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3432
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3433
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3434
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3435
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3436
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3437
SimileAjax.WindowManager._onBodyMouseMove = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3438
    if (SimileAjax.WindowManager._draggedElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3439
        var callback = SimileAjax.WindowManager._draggedElementCallback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3440
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3441
        var lastCoords = SimileAjax.WindowManager._lastCoords;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3442
        var diffX = evt.clientX - lastCoords.x;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3443
        var diffY = evt.clientY - lastCoords.y;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3444
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3445
        if (!SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3446
            if (Math.abs(diffX) > 5 || Math.abs(diffY) > 5) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3447
                try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3448
                    if ("onDragStart" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3449
                        callback.onDragStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3450
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3451
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3452
                    if ("ghost" in callback && callback.ghost) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3453
                        var draggedElmt = SimileAjax.WindowManager._draggedElement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3454
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3455
                        SimileAjax.WindowManager._ghostCoords = SimileAjax.DOM.getPageCoordinates(draggedElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3456
                        SimileAjax.WindowManager._ghostCoords.left += diffX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3457
                        SimileAjax.WindowManager._ghostCoords.top += diffY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3458
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3459
                        var ghostElmt = draggedElmt.cloneNode(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3460
                        ghostElmt.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3461
                        ghostElmt.style.left = SimileAjax.WindowManager._ghostCoords.left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3462
                        ghostElmt.style.top = SimileAjax.WindowManager._ghostCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3463
                        ghostElmt.style.zIndex = 1000;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3464
                        SimileAjax.Graphics.setOpacity(ghostElmt, 50);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3465
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3466
                        document.body.appendChild(ghostElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3467
                        callback._ghostElmt = ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3468
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3469
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3470
                    SimileAjax.WindowManager._dragging = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3471
                    SimileAjax.WindowManager._lastCoords = { x: evt.clientX, y: evt.clientY };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3472
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3473
                    document.body.focus();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3474
                } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3475
                    SimileAjax.Debug.exception("WindowManager: Error handling mouse down", e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3476
                    SimileAjax.WindowManager._cancelDragging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3477
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3478
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3479
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3480
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3481
                SimileAjax.WindowManager._lastCoords = { x: evt.clientX, y: evt.clientY };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3482
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3483
                if ("onDragBy" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3484
                    callback.onDragBy(diffX, diffY);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3485
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3486
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3487
                if ("_ghostElmt" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3488
                    var ghostElmt = callback._ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3489
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3490
                    SimileAjax.WindowManager._ghostCoords.left += diffX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3491
                    SimileAjax.WindowManager._ghostCoords.top += diffY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3492
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3493
                    ghostElmt.style.left = SimileAjax.WindowManager._ghostCoords.left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3494
                    ghostElmt.style.top = SimileAjax.WindowManager._ghostCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3495
                    if (SimileAjax.WindowManager._draggingModeIndicatorElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3496
                        var indicatorElmt = SimileAjax.WindowManager._draggingModeIndicatorElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3497
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3498
                        indicatorElmt.style.left = (SimileAjax.WindowManager._ghostCoords.left - 16) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3499
                        indicatorElmt.style.top = SimileAjax.WindowManager._ghostCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3500
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3501
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3502
                    if ("droppable" in callback && callback.droppable) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3503
                        var coords = SimileAjax.DOM.getEventPageCoordinates(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3504
                        var target = SimileAjax.DOM.hittest(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3505
                            coords.x, coords.y,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3506
                            [   SimileAjax.WindowManager._ghostElmt,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3507
                                SimileAjax.WindowManager._dropTargetHighlightElement
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3508
                            ]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3509
                        );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3510
                        target = SimileAjax.WindowManager._findDropTarget(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3511
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3512
                        if (target != SimileAjax.WindowManager._potentialDropTarget) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3513
                            if (SimileAjax.WindowManager._dropTargetHighlightElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3514
                                document.body.removeChild(SimileAjax.WindowManager._dropTargetHighlightElement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3515
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3516
                                SimileAjax.WindowManager._dropTargetHighlightElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3517
                                SimileAjax.WindowManager._potentialDropTarget = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3518
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3519
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3520
                            var droppable = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3521
                            if (target != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3522
                                if ((!("canDropOn" in callback) || callback.canDropOn(target)) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3523
                                    (!("canDrop" in target) || target.canDrop(SimileAjax.WindowManager._draggedElement))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3524
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3525
                                    droppable = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3526
                                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3527
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3528
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3529
                            if (droppable) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3530
                                var border = 4;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3531
                                var targetCoords = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3532
                                var highlight = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3533
                                highlight.style.border = border + "px solid yellow";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3534
                                highlight.style.backgroundColor = "yellow";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3535
                                highlight.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3536
                                highlight.style.left = targetCoords.left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3537
                                highlight.style.top = targetCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3538
                                highlight.style.width = (target.offsetWidth - border * 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3539
                                highlight.style.height = (target.offsetHeight - border * 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3540
                                SimileAjax.Graphics.setOpacity(highlight, 30);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3541
                                document.body.appendChild(highlight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3542
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3543
                                SimileAjax.WindowManager._potentialDropTarget = target;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3544
                                SimileAjax.WindowManager._dropTargetHighlightElement = highlight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3545
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3546
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3547
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3548
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3549
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3550
                SimileAjax.Debug.exception("WindowManager: Error handling mouse move", e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3551
                SimileAjax.WindowManager._cancelDragging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3552
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3553
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3554
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3555
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3556
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3557
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3558
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3559
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3560
SimileAjax.WindowManager._onBodyMouseUp = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3561
    if (SimileAjax.WindowManager._draggedElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3562
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3563
            if (SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3564
                var callback = SimileAjax.WindowManager._draggedElementCallback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3565
                if ("onDragEnd" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3566
                    callback.onDragEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3567
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3568
                if ("droppable" in callback && callback.droppable) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3569
                    var dropped = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3570
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3571
                    var target = SimileAjax.WindowManager._potentialDropTarget;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3572
                    if (target != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3573
                        if ((!("canDropOn" in callback) || callback.canDropOn(target)) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3574
                            (!("canDrop" in target) || target.canDrop(SimileAjax.WindowManager._draggedElement))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3575
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3576
                            if ("onDropOn" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3577
                                callback.onDropOn(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3578
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3579
                            target.ondrop(SimileAjax.WindowManager._draggedElement, SimileAjax.WindowManager._draggingMode);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3580
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3581
                            dropped = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3582
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3583
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3584
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3585
                    if (!dropped) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3586
                        // TODO: do holywood explosion here
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3587
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3588
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3589
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3590
        } finally {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3591
            SimileAjax.WindowManager._cancelDragging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3592
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3593
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3594
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3595
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3596
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3597
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3598
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3599
SimileAjax.WindowManager._cancelDragging = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3600
    var callback = SimileAjax.WindowManager._draggedElementCallback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3601
    if ("_ghostElmt" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3602
        var ghostElmt = callback._ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3603
        document.body.removeChild(ghostElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3604
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3605
        delete callback._ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3606
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3607
    if (SimileAjax.WindowManager._dropTargetHighlightElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3608
        document.body.removeChild(SimileAjax.WindowManager._dropTargetHighlightElement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3609
        SimileAjax.WindowManager._dropTargetHighlightElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3610
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3611
    if (SimileAjax.WindowManager._draggingModeIndicatorElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3612
        document.body.removeChild(SimileAjax.WindowManager._draggingModeIndicatorElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3613
        SimileAjax.WindowManager._draggingModeIndicatorElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3614
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3615
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3616
    SimileAjax.WindowManager._draggedElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3617
    SimileAjax.WindowManager._draggedElementCallback = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3618
    SimileAjax.WindowManager._potentialDropTarget = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3619
    SimileAjax.WindowManager._dropTargetHighlightElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3620
    SimileAjax.WindowManager._lastCoords = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3621
    SimileAjax.WindowManager._ghostCoords = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3622
    SimileAjax.WindowManager._draggingMode = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3623
    SimileAjax.WindowManager._dragging = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3624
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3625
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3626
SimileAjax.WindowManager._findDropTarget = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3627
    while (elmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3628
        if ("ondrop" in elmt && (typeof elmt.ondrop) == "function") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3629
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3630
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3631
        elmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3632
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3633
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3634
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3635
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3636
 *  Timeline API
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3637
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3638
 *  This file will load all the Javascript files
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3639
 *  necessary to make the standard timeline work.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3640
 *  It also detects the default locale.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3641
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3642
 *  To run from the MIT copy of Timeline:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3643
 *  Include this file in your HTML file as follows:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3644
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3645
 *    <script src="http://api.simile-widgets.org/timeline/2.3.1/timeline-api.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3646
 *     type="text/javascript"></script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3647
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3648
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3649
 * To host the Timeline files on your own server:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3650
 *   1) Install the Timeline and Simile-Ajax files onto your webserver using
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3651
 *      timeline_libraries.zip or timeline_source.zip
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3652
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3653
 *   2) Set global js variables used to send parameters to this script:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3654
 *        var Timeline_ajax_url -- url for simile-ajax-api.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3655
 *        var Timeline_urlPrefix -- url for the *directory* that contains timeline-api.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3656
 *            Include trailing slash
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3657
 *        var Timeline_parameters='bundle=true'; // you must set bundle to true if you are using
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3658
 *                                               // timeline_libraries.zip since only the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3659
 *                                               // bundled libraries are included
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3660
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3661
 * eg your html page would include
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3662
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3663
 *   <script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3664
 *     var Timeline_ajax_url="http://YOUR_SERVER/javascripts/timeline/timeline_ajax/simile-ajax-api.js";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3665
 *     var Timeline_urlPrefix='http://YOUR_SERVER/javascripts/timeline/timeline_js/';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3666
 *     var Timeline_parameters='bundle=true';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3667
 *   </script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3668
 *   <script src="http://YOUR_SERVER/javascripts/timeline/timeline_js/timeline-api.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3669
 *     type="text/javascript">
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3670
 *   </script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3671
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3672
 * SCRIPT PARAMETERS
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3673
 * This script auto-magically figures out locale and has defaults for other parameters
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3674
 * To set parameters explicity, set js global variable Timeline_parameters or include as
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3675
 * parameters on the url using GET style. Eg the two next lines pass the same parameters:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3676
 *     Timeline_parameters='bundle=true';                    // pass parameter via js variable
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3677
 *     <script src="http://....timeline-api.js?bundle=true"  // pass parameter via url
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3678
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3679
 * Parameters
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3680
 *   timeline-use-local-resources --
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3681
 *   bundle -- true: use the single js bundle file; false: load individual files (for debugging)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3682
 *   locales --
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3683
 *   defaultLocale --
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3684
 *   forceLocale -- force locale to be a particular value--used for debugging. Normally locale is determined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3685
 *                  by browser's and server's locale settings.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3686
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3687
 * DEBUGGING
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3688
 * If you have a problem with Timeline, the first step is to use the unbundled Javascript files. To do so:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3689
 * To use the unbundled Timeline and Ajax libraries
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3690
 * Change
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3691
 *   <script src="http://api.simile-widgets.org/timeline/2.3.1/api/timeline-api.js?bundle=true" type="text/javascript"></script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3692
 * To
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3693
 *   <script>var Timeline_ajax_url = "http://api.simile-widgets.org/ajax/2.2.1/simile-ajax-api.js?bundle=false"</script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3694
 *   <script src="http://api.simile-widgets.org/timeline/2.3.1/api/timeline-api.js?bundle=false" type="text/javascript"></script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3695
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3696
 * Note that the Ajax version is usually NOT the same as the Timeline version.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3697
 * See variable simile_ajax_ver below for the current version
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3698
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3699
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3700
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3701
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3702
(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3703
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3704
    var simile_ajax_ver = "2.2.1"; // ===========>>>  current Simile-Ajax version
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3705
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3706
    var useLocalResources = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3707
    if (document.location.search.length > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3708
        var params = document.location.search.substr(1).split("&");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3709
        for (var i = 0; i < params.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3710
            if (params[i] == "timeline-use-local-resources") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3711
                useLocalResources = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3712
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3713
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3714
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3715
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3716
    var loadMe = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3717
        if ("Timeline" in window) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3718
            return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3719
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3720
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3721
        window.Timeline = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3722
        window.Timeline.DateTime = window.SimileAjax.DateTime; // for backward compatibility
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3723
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3724
        var bundle = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3725
        var javascriptFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3726
            "timeline.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3727
            "band.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3728
            "themes.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3729
            "ethers.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3730
            "ether-painters.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3731
            "event-utils.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3732
            "labellers.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3733
            "sources.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3734
            "original-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3735
            "detailed-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3736
            "overview-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3737
            "compact-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3738
            "decorators.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3739
            "units.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3740
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3741
        var cssFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3742
            "timeline.css",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3743
            "ethers.css",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3744
            "events.css"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3745
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3746
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3747
        var localizedJavascriptFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3748
            "timeline.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3749
            "labellers.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3750
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3751
        var localizedCssFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3752
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3753
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3754
        // ISO-639 language codes, ISO-3166 country codes (2 characters)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3755
        var supportedLocales = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3756
            "cs",       // Czech
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3757
            "de",       // German
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3758
            "en",       // English
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3759
            "es",       // Spanish
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3760
            "fr",       // French
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3761
            "it",       // Italian
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3762
            "nl",       // Dutch (The Netherlands)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3763
            "ru",       // Russian
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3764
            "se",       // Swedish
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3765
            "tr",       // Turkish
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3766
            "vi",       // Vietnamese
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3767
            "zh"        // Chinese
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3768
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3769
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3770
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3771
            var desiredLocales = [ "en" ],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3772
                defaultServerLocale = "en",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3773
                forceLocale = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3774
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3775
            var parseURLParameters = function(parameters) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3776
                var params = parameters.split("&");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3777
                for (var p = 0; p < params.length; p++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3778
                    var pair = params[p].split("=");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3779
                    if (pair[0] == "locales") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3780
                        desiredLocales = desiredLocales.concat(pair[1].split(","));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3781
                    } else if (pair[0] == "defaultLocale") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3782
                        defaultServerLocale = pair[1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3783
                    } else if (pair[0] == "forceLocale") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3784
                        forceLocale = pair[1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3785
                        desiredLocales = desiredLocales.concat(pair[1].split(","));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3786
                    } else if (pair[0] == "bundle") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3787
                        bundle = pair[1] != "false";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3788
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3789
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3790
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3791
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3792
            (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3793
                if (typeof Timeline_urlPrefix == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3794
                    Timeline.urlPrefix = Timeline_urlPrefix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3795
                    if (typeof Timeline_parameters == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3796
                        parseURLParameters(Timeline_parameters);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3797
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3798
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3799
                    var heads = document.documentElement.getElementsByTagName("head");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3800
                    for (var h = 0; h < heads.length; h++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3801
                        var scripts = heads[h].getElementsByTagName("script");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3802
                        for (var s = 0; s < scripts.length; s++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3803
                            var url = scripts[s].src;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3804
                            var i = url.indexOf("timeline-api.js");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3805
                            if (i >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3806
                                Timeline.urlPrefix = url.substr(0, i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3807
                                var q = url.indexOf("?");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3808
                                if (q > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3809
                                    parseURLParameters(url.substr(q + 1));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3810
                                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3811
                                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3812
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3813
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3814
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3815
                    throw new Error("Failed to derive URL prefix for Timeline API code files");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3816
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3817
            })();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3818
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3819
            var includeJavascriptFiles = function(urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3820
                SimileAjax.includeJavascriptFiles(document, urlPrefix, filenames);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3821
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3822
            var includeCssFiles = function(urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3823
                SimileAjax.includeCssFiles(document, urlPrefix, filenames);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3824
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3825
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3826
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3827
             *  Include non-localized files
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3828
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3829
            if (bundle) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3830
                includeJavascriptFiles(Timeline.urlPrefix, [ "timeline-bundle.js" ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3831
                includeCssFiles(Timeline.urlPrefix, [ "timeline-bundle.css" ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3832
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3833
                includeJavascriptFiles(Timeline.urlPrefix + "scripts/", javascriptFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3834
                includeCssFiles(Timeline.urlPrefix + "styles/", cssFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3835
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3836
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3837
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3838
             *  Include localized files
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3839
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3840
            var loadLocale = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3841
            loadLocale[defaultServerLocale] = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3842
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3843
            var tryExactLocale = function(locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3844
                for (var l = 0; l < supportedLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3845
                    if (locale == supportedLocales[l]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3846
                        loadLocale[locale] = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3847
                        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3848
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3849
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3850
                return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3851
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3852
            var tryLocale = function(locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3853
                if (tryExactLocale(locale)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3854
                    return locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3855
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3856
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3857
                var dash = locale.indexOf("-");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3858
                if (dash > 0 && tryExactLocale(locale.substr(0, dash))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3859
                    return locale.substr(0, dash);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3860
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3861
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3862
                return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3863
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3864
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3865
            for (var l = 0; l < desiredLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3866
                tryLocale(desiredLocales[l]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3867
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3868
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3869
            var defaultClientLocale = defaultServerLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3870
            var defaultClientLocales = ("language" in navigator ? navigator.language : navigator.browserLanguage).split(";");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3871
            for (var l = 0; l < defaultClientLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3872
                var locale = tryLocale(defaultClientLocales[l]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3873
                if (locale != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3874
                    defaultClientLocale = locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3875
                    break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3876
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3877
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3878
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3879
            for (var l = 0; l < supportedLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3880
                var locale = supportedLocales[l];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3881
                if (loadLocale[locale]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3882
                    includeJavascriptFiles(Timeline.urlPrefix + "scripts/l10n/" + locale + "/", localizedJavascriptFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3883
                    includeCssFiles(Timeline.urlPrefix + "styles/l10n/" + locale + "/", localizedCssFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3884
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3885
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3886
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3887
            if (forceLocale == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3888
              Timeline.serverLocale = defaultServerLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3889
              Timeline.clientLocale = defaultClientLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3890
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3891
              Timeline.serverLocale = forceLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3892
              Timeline.clientLocale = forceLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3893
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3894
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3895
            alert(e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3896
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3897
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3898
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3899
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3900
     *  Load SimileAjax if it's not already loaded
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3901
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3902
    if (typeof SimileAjax == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3903
        window.SimileAjax_onLoad = loadMe;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3904
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3905
        var url = useLocalResources ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3906
            "http://127.0.0.1:9999/ajax/api/simile-ajax-api.js?bundle=false" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3907
            "http://api.simile-widgets.org/ajax/" + simile_ajax_ver + "/simile-ajax-api.js";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3908
        if (typeof Timeline_ajax_url == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3909
           url = Timeline_ajax_url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3910
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3911
        var createScriptElement = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3912
            var script = document.createElement("script");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3913
            script.type = "text/javascript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3914
            script.language = "JavaScript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3915
            script.src = url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3916
            document.getElementsByTagName("head")[0].appendChild(script);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3917
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3918
        if (document.body == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3919
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3920
                document.write("<script src='" + url + "' type='text/javascript'></script>");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3921
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3922
                createScriptElement();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3923
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3924
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3925
            createScriptElement();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3926
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3927
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3928
        loadMe();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3929
    }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  3930
})();
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3931
/*=================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3932
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3933
 * Coding standards:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3934
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3935
 * We aim towards Douglas Crockford's Javascript conventions.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3936
 * See:  http://javascript.crockford.com/code.html
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3937
 * See also: http://www.crockford.com/javascript/javascript.html
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3938
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3939
 * That said, this JS code was written before some recent JS
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3940
 * support libraries became widely used or available.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3941
 * In particular, the _ character is used to indicate a class function or
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3942
 * variable that should be considered private to the class.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3943
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3944
 * The code mostly uses accessor methods for getting/setting the private
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3945
 * class variables.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3946
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3947
 * Over time, we'd like to formalize the convention by using support libraries
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3948
 * which enforce privacy in objects.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3949
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3950
 * We also want to use jslint:  http://www.jslint.com/
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3951
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3952
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3953
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3954
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3955
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3956
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3957
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3958
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3959
 *  Timeline VERSION
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3960
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3961
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3962
// Note: version is also stored in the build.xml file
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3963
Timeline.version = 'pre 2.4.0';  // use format 'pre 1.2.3' for trunk versions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3964
Timeline.ajax_lib_version = SimileAjax.version;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3965
Timeline.display_version = Timeline.version + ' (with Ajax lib ' + Timeline.ajax_lib_version + ')';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3966
 // cf method Timeline.writeVersion
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3967
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3968
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3969
 *  Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3970
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3971
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3972
Timeline.strings = {}; // localization string tables
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3973
Timeline.HORIZONTAL = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3974
Timeline.VERTICAL = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3975
Timeline._defaultTheme = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3976
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3977
Timeline.getDefaultLocale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3978
    return Timeline.clientLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3979
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3980
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3981
Timeline.create = function(elmt, bandInfos, orientation, unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3982
    if (Timeline.timelines == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3983
        Timeline.timelines = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3984
        // Timeline.timelines array can have null members--Timelines that
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3985
        // once existed on the page, but were later disposed of.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3986
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3988
    var timelineID = Timeline.timelines.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3989
    Timeline.timelines[timelineID] = null; // placeholder until we have the object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3990
    var new_tl = new Timeline._Impl(elmt, bandInfos, orientation, unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3991
      timelineID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3992
    Timeline.timelines[timelineID] = new_tl;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3993
    return new_tl;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3994
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3995
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3996
Timeline.createBandInfo = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3997
    var theme = ("theme" in params) ? params.theme : Timeline.getDefaultTheme();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3998
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3999
    var eventSource = ("eventSource" in params) ? params.eventSource : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4000
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4001
    var etherParams = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4002
        interval:           SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4003
        pixelsPerInterval: params.intervalPixels,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4004
	theme: theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4005
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4006
    if ('startsOn' in params || 'endsOn' in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4007
	if ('startsOn' in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4008
	    etherParams.startsOn = params.startsOn;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4009
	}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4010
	if ('endsOn' in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4011
	    etherParams.endsOn = params.endsOn;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4012
	}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4013
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4014
	etherParams.centersOn = ("date" in params) ? params.date : new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4015
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4016
    var ether = new Timeline.LinearEther(etherParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4017
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4018
    var etherPainter = new Timeline.GregorianEtherPainter({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4019
        unit:       params.intervalUnit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4020
        multiple:   ("multiple" in params) ? params.multiple : 1,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4021
        theme:      theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4022
        align:      ("align" in params) ? params.align : undefined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4023
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4024
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4025
    var eventPainterParams = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4026
        showText:   ("showEventText" in params) ? params.showEventText : true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4027
        theme:      theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4028
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4029
    // pass in custom parameters for the event painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4030
    if ("eventPainterParams" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4031
        for (var prop in params.eventPainterParams) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4032
            eventPainterParams[prop] = params.eventPainterParams[prop];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4033
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4034
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4035
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4036
    if ("trackHeight" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4037
        eventPainterParams.trackHeight = params.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4038
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4039
    if ("trackGap" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4040
        eventPainterParams.trackGap = params.trackGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4041
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4042
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4043
    var layout = ("overview" in params && params.overview) ? "overview" : ("layout" in params ? params.layout : "original");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4044
    var eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4045
    if ("eventPainter" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4046
        eventPainter = new params.eventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4047
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4048
        switch (layout) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4049
            case "overview" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4050
                eventPainter = new Timeline.OverviewEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4051
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4052
            case "detailed" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4053
                eventPainter = new Timeline.DetailedEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4054
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4055
            default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4056
                eventPainter = new Timeline.OriginalEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4057
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4058
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4059
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4060
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4061
        width:          params.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4062
        eventSource:    eventSource,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4063
        timeZone:       ("timeZone" in params) ? params.timeZone : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4064
        ether:          ether,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4065
        etherPainter:   etherPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4066
        eventPainter:   eventPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4067
        theme:          theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4068
        zoomIndex:      ("zoomIndex" in params) ? params.zoomIndex : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4069
        zoomSteps:      ("zoomSteps" in params) ? params.zoomSteps : null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4070
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4071
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4072
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4073
Timeline.createHotZoneBandInfo = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4074
    var theme = ("theme" in params) ? params.theme : Timeline.getDefaultTheme();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4075
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4076
    var eventSource = ("eventSource" in params) ? params.eventSource : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4078
    var ether = new Timeline.HotZoneEther({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4079
        centersOn:          ("date" in params) ? params.date : new Date(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4080
        interval:           SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4081
        pixelsPerInterval:  params.intervalPixels,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4082
        zones:              params.zones,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4083
        theme:              theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4084
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4085
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4086
    var etherPainter = new Timeline.HotZoneGregorianEtherPainter({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4087
        unit:       params.intervalUnit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4088
        zones:      params.zones,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4089
        theme:      theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4090
        align:      ("align" in params) ? params.align : undefined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4091
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4092
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4093
    var eventPainterParams = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4094
        showText:   ("showEventText" in params) ? params.showEventText : true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4095
        theme:      theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4096
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4097
    // pass in custom parameters for the event painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4098
    if ("eventPainterParams" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4099
        for (var prop in params.eventPainterParams) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4100
            eventPainterParams[prop] = params.eventPainterParams[prop];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4101
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4102
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4103
    if ("trackHeight" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4104
        eventPainterParams.trackHeight = params.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4105
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4106
    if ("trackGap" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4107
        eventPainterParams.trackGap = params.trackGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4108
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4109
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4110
    var layout = ("overview" in params && params.overview) ? "overview" : ("layout" in params ? params.layout : "original");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4111
    var eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4112
    if ("eventPainter" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4113
        eventPainter = new params.eventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4114
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4115
        switch (layout) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4116
            case "overview" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4117
                eventPainter = new Timeline.OverviewEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4118
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4119
            case "detailed" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4120
                eventPainter = new Timeline.DetailedEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4121
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4122
            default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4123
                eventPainter = new Timeline.OriginalEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4124
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4125
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4126
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4127
        width:          params.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4128
        eventSource:    eventSource,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4129
        timeZone:       ("timeZone" in params) ? params.timeZone : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4130
        ether:          ether,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4131
        etherPainter:   etherPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4132
        eventPainter:   eventPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4133
        theme:          theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4134
        zoomIndex:      ("zoomIndex" in params) ? params.zoomIndex : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4135
        zoomSteps:      ("zoomSteps" in params) ? params.zoomSteps : null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4136
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4137
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4138
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4139
Timeline.getDefaultTheme = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4140
    if (Timeline._defaultTheme == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4141
        Timeline._defaultTheme = Timeline.ClassicTheme.create(Timeline.getDefaultLocale());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4142
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4143
    return Timeline._defaultTheme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4144
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4145
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4146
Timeline.setDefaultTheme = function(theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4147
    Timeline._defaultTheme = theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4148
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4149
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4150
Timeline.loadXML = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4151
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4152
        alert("Failed to load data xml from " + url + "\n" + statusText);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4153
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4154
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4155
        var xml = xmlhttp.responseXML;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4156
        if (!xml.documentElement && xmlhttp.responseStream) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4157
            xml.load(xmlhttp.responseStream);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4158
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4159
        f(xml, url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4160
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4161
    SimileAjax.XmlHttp.get(url, fError, fDone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4162
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4163
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4164
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4165
Timeline.loadJSON = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4166
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4167
        alert("Failed to load json data from " + url + "\n" + statusText);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4168
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4169
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4170
        f(eval('(' + xmlhttp.responseText + ')'), url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4171
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4172
    SimileAjax.XmlHttp.get(url, fError, fDone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4173
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4174
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4175
Timeline.getTimelineFromID = function(timelineID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4176
    return Timeline.timelines[timelineID];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4177
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4178
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4179
// Write the current Timeline version as the contents of element with id el_id
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4180
Timeline.writeVersion = function(el_id) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4181
  document.getElementById(el_id).innerHTML = this.display_version;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4182
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4184
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4185
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4186
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4187
 *  Timeline Implementation object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4188
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4189
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4190
Timeline._Impl = function(elmt, bandInfos, orientation, unit, timelineID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4191
    SimileAjax.WindowManager.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4192
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4193
    this._containerDiv = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4194
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4195
    this._bandInfos = bandInfos;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4196
    this._orientation = orientation == null ? Timeline.HORIZONTAL : orientation;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4197
    this._unit = (unit != null) ? unit : SimileAjax.NativeDateUnit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4198
    this._starting = true; // is the Timeline being created? Used by autoWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4199
                           // functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4200
    this._autoResizing = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4201
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4202
    // autoWidth is a "public" property of the Timeline object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4203
    this.autoWidth = bandInfos && bandInfos[0] && bandInfos[0].theme &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4204
                     bandInfos[0].theme.autoWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4205
    this.autoWidthAnimationTime = bandInfos && bandInfos[0] && bandInfos[0].theme &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4206
                     bandInfos[0].theme.autoWidthAnimationTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4207
    this.timelineID = timelineID; // also public attribute
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4208
    this.timeline_start = bandInfos && bandInfos[0] && bandInfos[0].theme &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4209
                     bandInfos[0].theme.timeline_start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4210
    this.timeline_stop  = bandInfos && bandInfos[0] && bandInfos[0].theme &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4211
                     bandInfos[0].theme.timeline_stop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4212
    this.timeline_at_start = false; // already at start or stop? Then won't
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4213
    this.timeline_at_stop = false;  // try to move further in the wrong direction
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4214
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4215
    this._initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4216
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4217
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4218
//
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4219
// Public functions used by client sw
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4220
//
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4221
Timeline._Impl.prototype.dispose = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4222
    for (var i = 0; i < this._bands.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4223
        this._bands[i].dispose();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4224
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4225
    this._bands = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4226
    this._bandInfos = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4227
    this._containerDiv.innerHTML = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4228
    // remove from array of Timelines
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4229
    Timeline.timelines[this.timelineID] = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4230
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4231
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4232
Timeline._Impl.prototype.getBandCount = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4233
    return this._bands.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4234
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4235
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4236
Timeline._Impl.prototype.getBand = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4237
    return this._bands[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4238
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4239
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4240
Timeline._Impl.prototype.finishedEventLoading = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4241
    // Called by client after events have been loaded into Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4242
    // Only used if the client has set autoWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4243
    // Sets width to Timeline's requested amount and will shrink down the div if
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4244
    // need be.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4245
    this._autoWidthCheck(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4246
    this._starting = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4247
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4248
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4249
Timeline._Impl.prototype.layout = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4250
    // called by client when browser is resized
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4251
    this._autoWidthCheck(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4252
    this._distributeWidths();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4253
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4254
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4255
Timeline._Impl.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4256
    for (var i = 0; i < this._bands.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4257
        this._bands[i].paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4258
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4259
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4260
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4261
Timeline._Impl.prototype.getDocument = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4262
    return this._containerDiv.ownerDocument;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4263
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4264
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4265
Timeline._Impl.prototype.addDiv = function(div) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4266
    this._containerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4267
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4268
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4269
Timeline._Impl.prototype.removeDiv = function(div) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4270
    this._containerDiv.removeChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4271
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4272
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4273
Timeline._Impl.prototype.isHorizontal = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4274
    return this._orientation == Timeline.HORIZONTAL;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4275
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4276
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4277
Timeline._Impl.prototype.isVertical = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4278
    return this._orientation == Timeline.VERTICAL;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4279
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4280
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4281
Timeline._Impl.prototype.getPixelLength = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4282
    return this._orientation == Timeline.HORIZONTAL ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4283
        this._containerDiv.offsetWidth : this._containerDiv.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4284
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4285
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4286
Timeline._Impl.prototype.getPixelWidth = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4287
    return this._orientation == Timeline.VERTICAL ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4288
        this._containerDiv.offsetWidth : this._containerDiv.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4289
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4290
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4291
Timeline._Impl.prototype.getUnit = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4292
    return this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4293
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4294
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4295
Timeline._Impl.prototype.getWidthStyle = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4296
    // which element.style attribute should be changed to affect Timeline's "width"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4297
    return this._orientation == Timeline.HORIZONTAL ? 'height' : 'width';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4298
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4299
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4300
Timeline._Impl.prototype.loadXML = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4301
    var tl = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4302
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4303
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4304
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4305
        alert("Failed to load data xml from " + url + "\n" + statusText);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4306
        tl.hideLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4307
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4308
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4309
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4310
            var xml = xmlhttp.responseXML;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4311
            if (!xml.documentElement && xmlhttp.responseStream) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4312
                xml.load(xmlhttp.responseStream);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4313
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4314
            f(xml, url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4315
        } finally {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4316
            tl.hideLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4317
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4318
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4319
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4320
    this.showLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4321
    window.setTimeout(function() { SimileAjax.XmlHttp.get(url, fError, fDone); }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4322
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4323
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4324
Timeline._Impl.prototype.loadJSON = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4325
    var tl = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4326
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4327
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4328
        alert("Failed to load json data from " + url + "\n" + statusText);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4329
        tl.hideLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4330
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4331
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4332
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4333
            f(eval('(' + xmlhttp.responseText + ')'), url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4334
        } finally {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4335
            tl.hideLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4336
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4337
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4338
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4339
    this.showLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4340
    window.setTimeout(function() { SimileAjax.XmlHttp.get(url, fError, fDone); }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4341
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4342
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4343
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4344
//
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4345
// Private functions used by Timeline object functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4346
//
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4347
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4348
Timeline._Impl.prototype._autoWidthScrollListener = function(band) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4349
    band.getTimeline()._autoWidthCheck(false);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4350
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4351
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4352
// called to re-calculate auto width and adjust the overall Timeline div if needed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4353
Timeline._Impl.prototype._autoWidthCheck = function(okToShrink) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4354
    var timeline = this; // this Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4355
    var immediateChange = timeline._starting;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4356
    var newWidth = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4357
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4358
    function changeTimelineWidth() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4359
        var widthStyle = timeline.getWidthStyle();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4360
        if (immediateChange) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4361
            timeline._containerDiv.style[widthStyle] = newWidth + 'px';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4362
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4363
        	  // animate change
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4364
        	  timeline._autoResizing = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4365
        	  var animateParam ={};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4366
        	  animateParam[widthStyle] = newWidth + 'px';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4367
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4368
        	  SimileAjax.jQuery(timeline._containerDiv).animate(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4369
        	      animateParam, timeline.autoWidthAnimationTime,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4370
        	      'linear', function(){timeline._autoResizing = false;});
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4371
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4372
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4373
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4374
    function checkTimelineWidth() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4375
        var targetWidth = 0; // the new desired width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4376
        var currentWidth = timeline.getPixelWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4377
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4378
        if (timeline._autoResizing) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4379
        	return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4380
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4381
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4382
        // compute targetWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4383
        for (var i = 0; i < timeline._bands.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4384
            timeline._bands[i].checkAutoWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4385
            targetWidth += timeline._bandInfos[i].width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4386
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4387
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4388
        if (targetWidth > currentWidth || okToShrink) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4389
            // yes, let's change the size
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4390
            newWidth = targetWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4391
            changeTimelineWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4392
            timeline._distributeWidths();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4393
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4394
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4395
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4396
    // function's mainline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4397
    if (!timeline.autoWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4398
        return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4399
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4400
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4401
    checkTimelineWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4402
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4403
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4404
Timeline._Impl.prototype._initialize = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4405
    var containerDiv = this._containerDiv;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4406
    var doc = containerDiv.ownerDocument;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4407
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4408
    containerDiv.className =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4409
        containerDiv.className.split(" ").concat("timeline-container").join(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4410
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4411
	/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4412
	 * Set css-class on container div that will define orientation
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4413
	 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4414
	var orientation = (this.isHorizontal()) ? 'horizontal' : 'vertical'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4415
	containerDiv.className +=' timeline-'+orientation;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4416
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4417
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4418
    while (containerDiv.firstChild) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4419
        containerDiv.removeChild(containerDiv.firstChild);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4420
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4421
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4422
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4423
     *  inserting copyright and link to simile
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4424
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4425
    var elmtCopyright = SimileAjax.Graphics.createTranslucentImage(Timeline.urlPrefix + (this.isHorizontal() ? "images/copyright-vertical.png" : "images/copyright.png"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4426
    elmtCopyright.className = "timeline-copyright";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4427
    elmtCopyright.title = "Timeline copyright SIMILE - www.code.google.com/p/simile-widgets/";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4428
    SimileAjax.DOM.registerEvent(elmtCopyright, "click", function() { window.location = "http://www.simile-widgets.org/"; });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4429
    containerDiv.appendChild(elmtCopyright);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4430
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4431
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4432
     *  creating bands
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4433
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4434
    this._bands = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4435
    for (var i = 0; i < this._bandInfos.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4436
        var bandInfo = this._bandInfos[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4437
        var bandClass = bandInfo.bandClass || Timeline._Band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4438
        var band = new bandClass(this, this._bandInfos[i], i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4439
        this._bands.push(band);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4440
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4441
    this._distributeWidths();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4442
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4443
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4444
     *  sync'ing bands
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4445
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4446
    for (var i = 0; i < this._bandInfos.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4447
        var bandInfo = this._bandInfos[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4448
        if ("syncWith" in bandInfo) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4449
            this._bands[i].setSyncWithBand(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4450
                this._bands[bandInfo.syncWith],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4451
                ("highlight" in bandInfo) ? bandInfo.highlight : false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4452
            );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4453
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4454
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4455
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4456
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4457
    if (this.autoWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4458
        for (var i = 0; i < this._bands.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4459
            this._bands[i].addOnScrollListener(this._autoWidthScrollListener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4460
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4461
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4462
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4463
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4464
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4465
     *  creating loading UI
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4466
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4467
    var message = SimileAjax.Graphics.createMessageBubble(doc);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4468
    message.containerDiv.className = "timeline-message-container";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4469
    containerDiv.appendChild(message.containerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4470
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4471
    message.contentDiv.className = "timeline-message";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4472
    message.contentDiv.innerHTML = "<img src='" + Timeline.urlPrefix + "images/progress-running.gif' /> Loading...";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4473
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4474
    this.showLoadingMessage = function() { message.containerDiv.style.display = "block"; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4475
    this.hideLoadingMessage = function() { message.containerDiv.style.display = "none"; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4476
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4477
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4478
Timeline._Impl.prototype._distributeWidths = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4479
    var length = this.getPixelLength();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4480
    var width = this.getPixelWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4481
    var cumulativeWidth = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4482
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4483
    for (var i = 0; i < this._bands.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4484
        var band = this._bands[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4485
        var bandInfos = this._bandInfos[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4486
        var widthString = bandInfos.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4487
        var bandWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4488
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4489
        if (typeof widthString == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4490
          var x =  widthString.indexOf("%");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4491
          if (x > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4492
              var percent = parseInt(widthString.substr(0, x));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4493
              bandWidth = Math.round(percent * width / 100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4494
          } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4495
              bandWidth = parseInt(widthString);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4496
          }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4497
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4498
        	// was given an integer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4499
        	bandWidth = widthString;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4500
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4501
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4502
        band.setBandShiftAndWidth(cumulativeWidth, bandWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4503
        band.setViewLength(length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4504
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4505
        cumulativeWidth += bandWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4506
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4507
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4508
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4509
Timeline._Impl.prototype.shiftOK = function(index, shift) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4510
    // Returns true if the proposed shift is ok
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4511
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4512
    // Positive shift means going back in time
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4513
    var going_back = shift > 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4514
        going_forward = shift < 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4515
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4516
    // Is there an edge?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4517
    if ((going_back    && this.timeline_start == null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4518
        (going_forward && this.timeline_stop  == null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4519
        (shift == 0)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4520
        return (true);  // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4521
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4522
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4523
    // If any of the bands has noted that it is changing the others,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4524
    // then this shift is a secondary shift in reaction to the real shift,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4525
    // which already happened. In such cases, ignore it. (The issue is
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4526
    // that a positive original shift can cause a negative secondary shift,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4527
    // as the bands adjust.)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4528
    var secondary_shift = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4529
    for (var i = 0; i < this._bands.length && !secondary_shift; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4530
       secondary_shift = this._bands[i].busy();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4531
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4532
    if (secondary_shift) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4533
        return(true); // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4534
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4535
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4536
    // If we are already at an edge, then don't even think about going any further
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4537
    if ((going_back    && this.timeline_at_start) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4538
        (going_forward && this.timeline_at_stop)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4539
        return (false);  // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4540
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4541
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4542
    // Need to check all the bands
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4543
    var ok = false; // return value
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4544
    // If any of the bands will be or are showing an ok date, then let the shift proceed.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4545
    for (var i = 0; i < this._bands.length && !ok; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4546
       var band = this._bands[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4547
       if (going_back) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4548
           ok = (i == index ? band.getMinVisibleDateAfterDelta(shift) : band.getMinVisibleDate())
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4549
                >= this.timeline_start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4550
       } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4551
           ok = (i == index ? band.getMaxVisibleDateAfterDelta(shift) : band.getMaxVisibleDate())
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4552
                <= this.timeline_stop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4553
       }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4554
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4555
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4556
    // process results
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4557
    if (going_back) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4558
       this.timeline_at_start = !ok;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4559
       this.timeline_at_stop = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4560
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4561
       this.timeline_at_stop = !ok;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4562
       this.timeline_at_start = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4563
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4564
    // This is where you could have an effect once per hitting an
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4565
    // edge of the Timeline. Eg jitter the Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4566
    //if (!ok) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4567
        //alert(going_back ? "At beginning" : "At end");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4568
    //}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4569
    return (ok);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4570
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4571
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4572
Timeline._Impl.prototype.zoom = function (zoomIn, x, y, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4573
  var matcher = new RegExp("^timeline-band-([0-9]+)$");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4574
  var bandIndex = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4575
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4576
  var result = matcher.exec(target.id);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4577
  if (result) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4578
    bandIndex = parseInt(result[1]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4579
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4580
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4581
  if (bandIndex != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4582
    this._bands[bandIndex].zoom(zoomIn, x, y, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4583
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4584
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4585
  this.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4586
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4587
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4588
/*=================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4589
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4590
 * Coding standards:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4591
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4592
 * We aim towards Douglas Crockford's Javascript conventions.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4593
 * See:  http://javascript.crockford.com/code.html
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4594
 * See also: http://www.crockford.com/javascript/javascript.html
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4595
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4596
 * That said, this JS code was written before some recent JS
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4597
 * support libraries became widely used or available.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4598
 * In particular, the _ character is used to indicate a class function or
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4599
 * variable that should be considered private to the class.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4600
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4601
 * The code mostly uses accessor methods for getting/setting the private
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4602
 * class variables.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4603
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4604
 * Over time, we'd like to formalize the convention by using support libraries
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4605
 * which enforce privacy in objects.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4606
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4607
 * We also want to use jslint:  http://www.jslint.com/
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4608
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4609
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4610
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4611
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4612
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4613
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4614
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4615
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4616
 *  Band
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4617
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4618
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4619
Timeline._Band = function(timeline, bandInfo, index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4620
    // hack for easier subclassing
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4621
    if (timeline !== undefined) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4622
        this.initialize(timeline, bandInfo, index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4623
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4624
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4625
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4626
Timeline._Band.prototype.initialize = function(timeline, bandInfo, index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4627
    // Set up the band's object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4628
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4629
    // Munge params: If autoWidth is on for the Timeline, then ensure that
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4630
    // bandInfo.width is an integer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4631
    if (timeline.autoWidth && typeof bandInfo.width == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4632
        bandInfo.width = bandInfo.width.indexOf("%") > -1 ? 0 : parseInt(bandInfo.width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4633
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4634
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4635
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4636
    this._bandInfo = bandInfo;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4637
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4638
    this._index = index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4639
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4640
    this._locale = ("locale" in bandInfo) ? bandInfo.locale : Timeline.getDefaultLocale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4641
    this._timeZone = ("timeZone" in bandInfo) ? bandInfo.timeZone : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4642
    this._labeller = ("labeller" in bandInfo) ? bandInfo.labeller :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4643
        (("createLabeller" in timeline.getUnit()) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4644
            timeline.getUnit().createLabeller(this._locale, this._timeZone) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4645
            new Timeline.GregorianDateLabeller(this._locale, this._timeZone));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4646
    this._theme = bandInfo.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4647
    this._zoomIndex = ("zoomIndex" in bandInfo) ? bandInfo.zoomIndex : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4648
    this._zoomSteps = ("zoomSteps" in bandInfo) ? bandInfo.zoomSteps : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4649
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4650
    this._dragging = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4651
    this._changing = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4652
    this._originalScrollSpeed = 5; // pixels
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4653
    this._scrollSpeed = this._originalScrollSpeed;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4654
    this._viewOrthogonalOffset= 0; // vertical offset if the timeline is horizontal, and vice versa
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4655
    this._onScrollListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4656
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4657
    var b = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4658
    this._syncWithBand = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4659
    this._syncWithBandHandler = function(band) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4660
        b._onHighlightBandScroll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4661
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4662
    this._selectorListener = function(band) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4663
        b._onHighlightBandScroll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4664
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4665
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4666
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4667
     *  Install a textbox to capture keyboard events
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4668
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4669
    var inputDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4670
    inputDiv.className = "timeline-band-input";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4671
    this._timeline.addDiv(inputDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4672
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4673
    this._keyboardInput = document.createElement("input");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4674
    this._keyboardInput.type = "text";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4675
    inputDiv.appendChild(this._keyboardInput);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4676
    SimileAjax.DOM.registerEventWithObject(this._keyboardInput, "keydown", this, "_onKeyDown");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4677
    SimileAjax.DOM.registerEventWithObject(this._keyboardInput, "keyup", this, "_onKeyUp");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4678
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4679
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4680
     *  The band's outer most div that slides with respect to the timeline's div
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4681
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4682
    this._div = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4683
    this._div.id = "timeline-band-" + index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4684
    this._div.className = "timeline-band timeline-band-" + index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4685
    this._timeline.addDiv(this._div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4686
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4687
    SimileAjax.DOM.registerEventWithObject(this._div, "mousedown", this, "_onMouseDown");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4688
    SimileAjax.DOM.registerEventWithObject(this._div, "mousemove", this, "_onMouseMove");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4689
    SimileAjax.DOM.registerEventWithObject(this._div, "mouseup", this, "_onMouseUp");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4690
    SimileAjax.DOM.registerEventWithObject(this._div, "mouseout", this, "_onMouseOut");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4691
    SimileAjax.DOM.registerEventWithObject(this._div, "dblclick", this, "_onDblClick");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4692
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4693
    var mouseWheel = this._theme!= null ? this._theme.mouseWheel : 'scroll'; // theme is not always defined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4694
    if (mouseWheel === 'zoom' || mouseWheel === 'scroll' || this._zoomSteps) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4695
        // capture mouse scroll
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4696
        if (SimileAjax.Platform.browser.isFirefox) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4697
            SimileAjax.DOM.registerEventWithObject(this._div, "DOMMouseScroll", this, "_onMouseScroll");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4698
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4699
            SimileAjax.DOM.registerEventWithObject(this._div, "mousewheel", this, "_onMouseScroll");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4700
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4701
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4702
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4703
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4704
     *  The inner div that contains layers
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4705
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4706
    this._innerDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4707
    this._innerDiv.className = "timeline-band-inner";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4708
    this._div.appendChild(this._innerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4709
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4710
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4711
     *  Initialize parts of the band
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4712
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4713
    this._ether = bandInfo.ether;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4714
    bandInfo.ether.initialize(this, timeline);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4715
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4716
    this._etherPainter = bandInfo.etherPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4717
    bandInfo.etherPainter.initialize(this, timeline);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4718
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4719
    this._eventSource = bandInfo.eventSource;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4720
    if (this._eventSource) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4721
        this._eventListener = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4722
            onAddMany: function() { b._onAddMany(); },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4723
            onClear:   function() { b._onClear(); }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4724
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4725
        this._eventSource.addListener(this._eventListener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4726
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4727
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4728
    this._eventPainter = bandInfo.eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4729
    this._eventTracksNeeded = 0;   // set by painter via updateEventTrackInfo
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4730
    this._eventTrackIncrement = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4731
    bandInfo.eventPainter.initialize(this, timeline);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4732
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4733
    this._decorators = ("decorators" in bandInfo) ? bandInfo.decorators : [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4734
    for (var i = 0; i < this._decorators.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4735
        this._decorators[i].initialize(this, timeline);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4736
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4737
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4738
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4739
Timeline._Band.SCROLL_MULTIPLES = 5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4740
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4741
Timeline._Band.prototype.dispose = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4742
    this.closeBubble();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4743
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4744
    if (this._eventSource) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4745
        this._eventSource.removeListener(this._eventListener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4746
        this._eventListener = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4747
        this._eventSource = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4748
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4749
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4750
    this._timeline = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4751
    this._bandInfo = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4752
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4753
    this._labeller = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4754
    this._ether = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4755
    this._etherPainter = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4756
    this._eventPainter = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4757
    this._decorators = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4758
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4759
    this._onScrollListeners = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4760
    this._syncWithBandHandler = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4761
    this._selectorListener = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4762
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4763
    this._div = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4764
    this._innerDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4765
    this._keyboardInput = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4766
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4767
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4768
Timeline._Band.prototype.addOnScrollListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4769
    this._onScrollListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4770
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4771
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4772
Timeline._Band.prototype.removeOnScrollListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4773
    for (var i = 0; i < this._onScrollListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4774
        if (this._onScrollListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4775
            this._onScrollListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4776
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4777
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4778
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4779
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4780
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4781
Timeline._Band.prototype.setSyncWithBand = function(band, highlight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4782
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4783
        this._syncWithBand.removeOnScrollListener(this._syncWithBandHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4784
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4785
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4786
    this._syncWithBand = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4787
    this._syncWithBand.addOnScrollListener(this._syncWithBandHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4788
    this._highlight = highlight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4789
    this._positionHighlight();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4790
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4791
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4792
Timeline._Band.prototype.getLocale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4793
    return this._locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4794
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4795
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4796
Timeline._Band.prototype.getTimeZone = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4797
    return this._timeZone;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4798
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4799
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4800
Timeline._Band.prototype.getLabeller = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4801
    return this._labeller;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4802
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4803
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4804
Timeline._Band.prototype.getIndex = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4805
    return this._index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4806
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4807
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4808
Timeline._Band.prototype.getEther = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4809
    return this._ether;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4810
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4811
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4812
Timeline._Band.prototype.getEtherPainter = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4813
    return this._etherPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4814
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4815
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4816
Timeline._Band.prototype.getEventSource = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4817
    return this._eventSource;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4818
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4819
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4820
Timeline._Band.prototype.getEventPainter = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4821
    return this._eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4822
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4823
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4824
Timeline._Band.prototype.getTimeline = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4825
    return this._timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4826
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4827
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4828
// Autowidth support
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4829
Timeline._Band.prototype.updateEventTrackInfo = function(tracks, increment) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4830
    this._eventTrackIncrement = increment; // doesn't vary for a specific band
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4831
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4832
    if (tracks > this._eventTracksNeeded) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4833
        this._eventTracksNeeded = tracks;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4834
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4835
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4836
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4837
// Autowidth support
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4838
Timeline._Band.prototype.checkAutoWidth = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4839
    // if a new (larger) width is needed by the band
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4840
    // then: a) updates the band's bandInfo.width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4841
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4842
    // desiredWidth for the band is
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4843
    //   (number of tracks + margin) * track increment
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4844
    if (! this._timeline.autoWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4845
      return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4846
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4847
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4848
    var overviewBand = this._eventPainter.getType() == 'overview';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4849
    var margin = overviewBand ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4850
       this._theme.event.overviewTrack.autoWidthMargin :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4851
       this._theme.event.track.autoWidthMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4852
    var desiredWidth = Math.ceil((this._eventTracksNeeded + margin) *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4853
                       this._eventTrackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4854
    // add offset amount (additional margin)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4855
    desiredWidth += overviewBand ? this._theme.event.overviewTrack.offset :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4856
                                   this._theme.event.track.offset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4857
    var bandInfo = this._bandInfo;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4858
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4859
    if (desiredWidth != bandInfo.width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4860
        bandInfo.width = desiredWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4861
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4862
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4863
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4864
Timeline._Band.prototype.layout = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4865
    this.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4866
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4867
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4868
Timeline._Band.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4869
    this._etherPainter.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4870
    this._paintDecorators();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4871
    this._paintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4872
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4873
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4874
Timeline._Band.prototype.softLayout = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4875
    this.softPaint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4876
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4877
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4878
Timeline._Band.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4879
    this._etherPainter.softPaint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4880
    this._softPaintDecorators();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4881
    this._softPaintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4882
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4883
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4884
Timeline._Band.prototype.setBandShiftAndWidth = function(shift, width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4885
    var inputDiv = this._keyboardInput.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4886
    var middle = shift + Math.floor(width / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4887
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4888
        this._div.style.top = shift + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4889
        this._div.style.height = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4890
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4891
        inputDiv.style.top = middle + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4892
        inputDiv.style.left = "-1em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4893
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4894
        this._div.style.left = shift + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4895
        this._div.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4896
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4897
        inputDiv.style.left = middle + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4898
        inputDiv.style.top = "-1em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4899
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4900
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4901
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4902
Timeline._Band.prototype.getViewWidth = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4903
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4904
        return this._div.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4905
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4906
        return this._div.offsetWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4907
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4908
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4909
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4910
Timeline._Band.prototype.setViewLength = function(length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4911
    this._viewLength = length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4912
    this._recenterDiv();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4913
    this._onChanging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4914
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4915
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4916
Timeline._Band.prototype.getViewLength = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4917
    return this._viewLength;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4918
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4919
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4920
Timeline._Band.prototype.getTotalViewLength = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4921
    return Timeline._Band.SCROLL_MULTIPLES * this._viewLength;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4922
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4923
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4924
Timeline._Band.prototype.getViewOffset = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4925
    return this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4926
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4927
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4928
Timeline._Band.prototype.getMinDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4929
    return this._ether.pixelOffsetToDate(this._viewOffset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4930
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4931
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4932
Timeline._Band.prototype.getMaxDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4933
    return this._ether.pixelOffsetToDate(this._viewOffset + Timeline._Band.SCROLL_MULTIPLES * this._viewLength);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4934
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4935
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4936
Timeline._Band.prototype.getMinVisibleDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4937
    return this._ether.pixelOffsetToDate(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4938
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4939
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4940
Timeline._Band.prototype.getMinVisibleDateAfterDelta = function(delta) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4941
    return this._ether.pixelOffsetToDate(delta);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4942
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4943
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4944
Timeline._Band.prototype.getMaxVisibleDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4945
    // Max date currently visible on band
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4946
    return this._ether.pixelOffsetToDate(this._viewLength);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4947
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4948
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4949
Timeline._Band.prototype.getMaxVisibleDateAfterDelta = function(delta) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4950
    // Max date visible on band after delta px view change is applied
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4951
    return this._ether.pixelOffsetToDate(this._viewLength + delta);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4952
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4953
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4954
Timeline._Band.prototype.getCenterVisibleDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4955
    return this._ether.pixelOffsetToDate(this._viewLength / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4956
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4957
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4958
Timeline._Band.prototype.setMinVisibleDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4959
    if (!this._changing) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4960
        this._moveEther(Math.round(-this._ether.dateToPixelOffset(date)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4961
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4962
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4963
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4964
Timeline._Band.prototype.setMaxVisibleDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4965
    if (!this._changing) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4966
        this._moveEther(Math.round(this._viewLength - this._ether.dateToPixelOffset(date)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4967
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4968
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4969
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4970
Timeline._Band.prototype.setCenterVisibleDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4971
    if (!this._changing) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4972
        this._moveEther(Math.round(this._viewLength / 2 - this._ether.dateToPixelOffset(date)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4973
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4974
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4975
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4976
Timeline._Band.prototype.dateToPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4977
    return this._ether.dateToPixelOffset(date) - this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4978
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4979
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4980
Timeline._Band.prototype.pixelOffsetToDate = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4981
    return this._ether.pixelOffsetToDate(pixels + this._viewOffset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4982
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4983
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4984
Timeline._Band.prototype.getViewOrthogonalOffset = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4985
    return this._viewOrthogonalOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4986
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4988
Timeline._Band.prototype.setViewOrthogonalOffset = function(offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4989
    this._viewOrthogonalOffset = Math.max(0, offset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4990
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4991
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4992
Timeline._Band.prototype.createLayerDiv = function(zIndex, className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4993
    var div = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4994
    div.className = "timeline-band-layer" + (typeof className == "string" ? (" " + className) : "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4995
    div.style.zIndex = zIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4996
    this._innerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4997
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4998
    var innerDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4999
    innerDiv.className = "timeline-band-layer-inner";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5000
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5001
        innerDiv.style.cursor = "move";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5002
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5003
        innerDiv.style.cursor = "-moz-grab";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5004
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5005
    div.appendChild(innerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5006
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5007
    return innerDiv;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5008
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5009
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5010
Timeline._Band.prototype.removeLayerDiv = function(div) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5011
    this._innerDiv.removeChild(div.parentNode);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5012
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5013
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5014
Timeline._Band.prototype.scrollToCenter = function(date, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5015
    var pixelOffset = this._ether.dateToPixelOffset(date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5016
    if (pixelOffset < -this._viewLength / 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5017
        this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset + this._viewLength));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5018
    } else if (pixelOffset > 3 * this._viewLength / 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5019
        this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset - this._viewLength));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5020
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5021
    this._autoScroll(Math.round(this._viewLength / 2 - this._ether.dateToPixelOffset(date)), f);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5022
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5023
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5024
Timeline._Band.prototype.showBubbleForEvent = function(eventID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5025
    var evt = this.getEventSource().getEvent(eventID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5026
    if (evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5027
        var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5028
        this.scrollToCenter(evt.getStart(), function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5029
            self._eventPainter.showBubble(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5030
        });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5031
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5032
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5033
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5034
Timeline._Band.prototype.zoom = function(zoomIn, x, y, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5035
  if (!this._zoomSteps) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5036
    // zoom disabled
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5037
    return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5038
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5039
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5040
  // shift the x value by our offset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5041
  x += this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5042
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5043
  var zoomDate = this._ether.pixelOffsetToDate(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5044
  var netIntervalChange = this._ether.zoom(zoomIn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5045
  this._etherPainter.zoom(netIntervalChange);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5046
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5047
  // shift our zoom date to the far left
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5048
  this._moveEther(Math.round(-this._ether.dateToPixelOffset(zoomDate)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5049
  // then shift it back to where the mouse was
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5050
  this._moveEther(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5051
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5052
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5053
Timeline._Band.prototype._onMouseDown = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5054
    this.closeBubble();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5055
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5056
    this._dragging = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5057
    this._dragX = evt.clientX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5058
    this._dragY = evt.clientY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5059
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5060
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5061
Timeline._Band.prototype._onMouseMove = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5062
    if (this._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5063
        var diffX = evt.clientX - this._dragX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5064
        var diffY = evt.clientY - this._dragY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5065
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5066
        this._dragX = evt.clientX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5067
        this._dragY = evt.clientY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5068
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5069
        if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5070
            this._moveEther(diffX, diffY);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5071
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5072
            this._moveEther(diffY, diffX);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5073
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5074
        this._positionHighlight();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5075
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5076
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5078
Timeline._Band.prototype._onMouseUp = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5079
    this._dragging = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5080
    this._keyboardInput.focus();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5081
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5082
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5083
Timeline._Band.prototype._onMouseOut = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5084
    var coords = SimileAjax.DOM.getEventRelativeCoordinates(evt, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5085
    coords.x += this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5086
    if (coords.x < 0 || coords.x > innerFrame.offsetWidth ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5087
        coords.y < 0 || coords.y > innerFrame.offsetHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5088
        this._dragging = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5089
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5090
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5091
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5092
Timeline._Band.prototype._onMouseScroll = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5093
  var now = new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5094
  now = now.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5095
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5096
  if (!this._lastScrollTime || ((now - this._lastScrollTime) > 50)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5097
    // limit 1 scroll per 200ms due to FF3 sending multiple events back to back
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5098
    this._lastScrollTime = now;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5099
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5100
    var delta = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5101
    if (evt.wheelDelta) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5102
      delta = evt.wheelDelta/120;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5103
    } else if (evt.detail) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5104
      delta = -evt.detail/3;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5105
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5106
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5107
    // either scroll or zoom
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5108
    var mouseWheel = this._theme.mouseWheel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5109
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5110
    if (this._zoomSteps || mouseWheel === 'zoom') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5111
      var loc = SimileAjax.DOM.getEventRelativeCoordinates(evt, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5112
      if (delta != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5113
        var zoomIn;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5114
        if (delta > 0)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5115
          zoomIn = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5116
        if (delta < 0)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5117
          zoomIn = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5118
        // call zoom on the timeline so we could zoom multiple bands if desired
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5119
        this._timeline.zoom(zoomIn, loc.x, loc.y, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5120
      }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5121
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5122
    else if (mouseWheel === 'scroll') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5123
    	var move_amt = 50 * (delta < 0 ? -1 : 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5124
      this._moveEther(move_amt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5125
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5126
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5127
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5128
  // prevent bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5129
  if (evt.stopPropagation) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5130
    evt.stopPropagation();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5131
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5132
  evt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5133
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5134
  // prevent the default action
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5135
  if (evt.preventDefault) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5136
    evt.preventDefault();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5137
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5138
  evt.returnValue = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5139
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5140
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5141
Timeline._Band.prototype._onDblClick = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5142
    var coords = SimileAjax.DOM.getEventRelativeCoordinates(evt, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5143
    var distance = coords.x - (this._viewLength / 2 - this._viewOffset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5144
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5145
    this._autoScroll(-distance);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5146
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5147
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5148
Timeline._Band.prototype._onKeyDown = function(keyboardInput, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5149
    if (!this._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5150
        switch (evt.keyCode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5151
        case 27: // ESC
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5152
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5153
        case 37: // left arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5154
        case 38: // up arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5155
            this._scrollSpeed = Math.min(50, Math.abs(this._scrollSpeed * 1.05));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5156
            this._moveEther(this._scrollSpeed);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5157
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5158
        case 39: // right arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5159
        case 40: // down arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5160
            this._scrollSpeed = -Math.min(50, Math.abs(this._scrollSpeed * 1.05));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5161
            this._moveEther(this._scrollSpeed);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5162
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5163
        default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5164
            return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5165
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5166
        this.closeBubble();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5167
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5168
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5169
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5170
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5171
    return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5172
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5173
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5174
Timeline._Band.prototype._onKeyUp = function(keyboardInput, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5175
    if (!this._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5176
        this._scrollSpeed = this._originalScrollSpeed;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5177
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5178
        switch (evt.keyCode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5179
        case 35: // end
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5180
            this.setCenterVisibleDate(this._eventSource.getLatestDate());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5181
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5182
        case 36: // home
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5183
            this.setCenterVisibleDate(this._eventSource.getEarliestDate());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5184
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5185
        case 33: // page up
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5186
            this._autoScroll(this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5187
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5188
        case 34: // page down
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5189
            this._autoScroll(-this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5190
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5191
        default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5192
            return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5193
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5194
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5195
        this.closeBubble();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5196
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5197
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5198
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5199
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5200
    return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5201
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5202
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5203
Timeline._Band.prototype._autoScroll = function(distance, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5204
    var b = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5205
    var a = SimileAjax.Graphics.createAnimation(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5206
        function(abs, diff) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5207
            b._moveEther(diff);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5208
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5209
        0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5210
        distance,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5211
        1000,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5212
        f
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5213
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5214
    a.run();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5215
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5216
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5217
Timeline._Band.prototype._moveEther = function(shift, orthogonalShift) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5218
    if (orthogonalShift === undefined) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5219
        orthogonalShift = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5220
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5221
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5222
    this.closeBubble();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5223
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5224
    // A positive shift means back in time
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5225
    // Check that we're not moving beyond Timeline's limits
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5226
    if (!this._timeline.shiftOK(this._index, shift)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5227
        return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5228
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5229
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5230
    this._viewOffset += shift;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5231
    this._viewOrthogonalOffset = Math.min(0, this._viewOrthogonalOffset + orthogonalShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5232
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5233
    this._ether.shiftPixels(-shift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5234
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5235
        this._div.style.left = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5236
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5237
        this._div.style.top = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5238
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5239
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5240
    if (this._viewOffset > -this._viewLength * 0.5 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5241
        this._viewOffset < -this._viewLength * (Timeline._Band.SCROLL_MULTIPLES - 1.5)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5242
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5243
        this._recenterDiv();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5244
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5245
        this.softLayout();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5246
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5247
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5248
    this._onChanging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5249
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5250
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5251
Timeline._Band.prototype._onChanging = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5252
    this._changing = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5253
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5254
    this._fireOnScroll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5255
    this._setSyncWithBandDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5256
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5257
    this._changing = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5258
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5259
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5260
Timeline._Band.prototype.busy = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5261
    // Is this band busy changing other bands?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5262
    return(this._changing);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5263
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5264
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5265
Timeline._Band.prototype._fireOnScroll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5266
    for (var i = 0; i < this._onScrollListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5267
        this._onScrollListeners[i](this);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5268
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5269
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5270
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5271
Timeline._Band.prototype._setSyncWithBandDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5272
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5273
        var centerDate = this._ether.pixelOffsetToDate(this.getViewLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5274
        this._syncWithBand.setCenterVisibleDate(centerDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5275
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5276
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5277
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5278
Timeline._Band.prototype._onHighlightBandScroll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5279
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5280
        var centerDate = this._syncWithBand.getCenterVisibleDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5281
        var centerPixelOffset = this._ether.dateToPixelOffset(centerDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5282
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5283
        this._moveEther(Math.round(this._viewLength / 2 - centerPixelOffset));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5284
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5285
        if (this._highlight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5286
            this._etherPainter.setHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5287
                this._syncWithBand.getMinVisibleDate(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5288
                this._syncWithBand.getMaxVisibleDate());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5289
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5290
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5291
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5292
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5293
Timeline._Band.prototype._onAddMany = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5294
    this._paintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5295
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5296
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5297
Timeline._Band.prototype._onClear = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5298
    this._paintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5299
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5300
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5301
Timeline._Band.prototype._positionHighlight = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5302
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5303
        var startDate = this._syncWithBand.getMinVisibleDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5304
        var endDate = this._syncWithBand.getMaxVisibleDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5305
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5306
        if (this._highlight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5307
            this._etherPainter.setHighlight(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5308
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5309
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5310
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5311
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5312
Timeline._Band.prototype._recenterDiv = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5313
    this._viewOffset = -this._viewLength * (Timeline._Band.SCROLL_MULTIPLES - 1) / 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5314
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5315
        this._div.style.left = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5316
        this._div.style.width = (Timeline._Band.SCROLL_MULTIPLES * this._viewLength) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5317
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5318
        this._div.style.top = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5319
        this._div.style.height = (Timeline._Band.SCROLL_MULTIPLES * this._viewLength) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5320
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5321
    this.layout();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5322
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5323
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5324
Timeline._Band.prototype._paintEvents = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5325
    this._eventPainter.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5326
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5327
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5328
Timeline._Band.prototype._softPaintEvents = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5329
    this._eventPainter.softPaint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5330
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5331
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5332
Timeline._Band.prototype._paintDecorators = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5333
    for (var i = 0; i < this._decorators.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5334
        this._decorators[i].paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5335
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5336
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5337
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5338
Timeline._Band.prototype._softPaintDecorators = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5339
    for (var i = 0; i < this._decorators.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5340
        this._decorators[i].softPaint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5341
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5342
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5343
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5344
Timeline._Band.prototype.closeBubble = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5345
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5346
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5347
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5348
 *  Classic Theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5349
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5350
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5351
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5352
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5353
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5354
Timeline.ClassicTheme = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5355
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5356
Timeline.ClassicTheme.implementations = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5357
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5358
Timeline.ClassicTheme.create = function(locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5359
    if (locale == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5360
        locale = Timeline.getDefaultLocale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5361
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5362
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5363
    var f = Timeline.ClassicTheme.implementations[locale];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5364
    if (f == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5365
        f = Timeline.ClassicTheme._Impl;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5366
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5367
    return new f();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5368
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5369
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5370
Timeline.ClassicTheme._Impl = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5371
    this.firstDayOfWeek = 0; // Sunday
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5372
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5373
    // Note: Many styles previously set here are now set using CSS
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5374
    //       The comments indicate settings controlled by CSS, not
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5375
    //       lines to be un-commented.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5376
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5377
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5378
    // Attributes autoWidth, autoWidthAnimationTime, timeline_start
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5379
    // and timeline_stop must be set on the first band's theme.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5380
    // The other attributes can be set differently for each
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5381
    // band by using different themes for the bands.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5382
    this.autoWidth = false; // Should the Timeline automatically grow itself, as
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5383
                            // needed when too many events for the available width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5384
                            // are painted on the visible part of the Timeline?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5385
    this.autoWidthAnimationTime = 500; // mSec
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5386
    this.timeline_start = null; // Setting a date, eg new Date(Date.UTC(2008,0,17,20,00,00,0)) will prevent the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5387
                                // Timeline from being moved to anytime before the date.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5388
    this.timeline_stop = null;  // Use for setting a maximum date. The Timeline will not be able
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5389
                                // to be moved to anytime after this date.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5390
    this.ether = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5391
        backgroundColors: [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5392
        //    "#EEE",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5393
        //    "#DDD",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5394
        //    "#CCC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5395
        //    "#AAA"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5396
        ],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5397
     //   highlightColor:     "white",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5398
        highlightOpacity:   50,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5399
        interval: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5400
            line: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5401
                show:       true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5402
                opacity:    25
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5403
               // color:      "#aaa",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5404
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5405
            weekend: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5406
                opacity:    30
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5407
              //  color:      "#FFFFE0",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5408
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5409
            marker: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5410
                hAlign:     "Bottom",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5411
                vAlign:     "Right"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5412
                                        /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5413
                hBottomStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5414
                    elmt.className = "timeline-ether-marker-bottom";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5415
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5416
                hBottomEmphasizedStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5417
                    elmt.className = "timeline-ether-marker-bottom-emphasized";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5418
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5419
                hTopStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5420
                    elmt.className = "timeline-ether-marker-top";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5421
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5422
                hTopEmphasizedStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5423
                    elmt.className = "timeline-ether-marker-top-emphasized";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5424
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5425
                */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5426
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5427
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5428
               /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5429
                                  vRightStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5430
                    elmt.className = "timeline-ether-marker-right";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5431
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5432
                vRightEmphasizedStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5433
                    elmt.className = "timeline-ether-marker-right-emphasized";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5434
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5435
                vLeftStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5436
                    elmt.className = "timeline-ether-marker-left";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5437
                },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5438
                vLeftEmphasizedStyler:function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5439
                    elmt.className = "timeline-ether-marker-left-emphasized";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5440
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5441
                */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5442
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5443
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5444
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5445
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5446
    this.event = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5447
        track: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5448
                   height: 10, // px. You will need to change the track
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5449
                               //     height if you change the tape height.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5450
                      gap:  2, // px. Gap between tracks
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5451
                   offset:  2, // px. top margin above tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5452
          autoWidthMargin:  1.5
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5453
          /* autoWidthMargin is only used if autoWidth (see above) is true.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5454
             The autoWidthMargin setting is used to set how close the bottom of the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5455
             lowest track is to the edge of the band's div. The units are total track
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5456
             width (tape + label + gap). A min of 0.5 is suggested. Use this setting to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5457
             move the bottom track's tapes above the axis markers, if needed for your
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5458
             Timeline.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5459
          */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5460
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5461
        overviewTrack: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5462
                  offset: 20, // px -- top margin above tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5463
              tickHeight:  6, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5464
                  height:  2, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5465
                     gap:  1, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5466
         autoWidthMargin:  5 // This attribute is only used if autoWidth (see above) is true.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5467
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5468
        tape: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5469
            height:         4 // px. For thicker tapes, remember to change track height too.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5470
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5471
        instant: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5472
                           icon: Timeline.urlPrefix + "images/dull-blue-circle.png",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5473
                                 // default icon. Icon can also be specified per event
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5474
                      iconWidth: 10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5475
                     iconHeight: 10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5476
               impreciseOpacity: 20, // opacity of the tape when durationEvent is false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5477
            impreciseIconMargin: 3   // A tape and an icon are painted for imprecise instant
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5478
                                     // events. This attribute is the margin between the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5479
                                     // bottom of the tape and the top of the icon in that
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5480
                                     // case.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5481
    //        color:             "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5482
    //        impreciseColor:    "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5483
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5484
        duration: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5485
            impreciseOpacity: 20 // tape opacity for imprecise part of duration events
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5486
      //      color:            "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5487
      //      impreciseColor:   "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5488
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5489
        label: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5490
            backgroundOpacity: 50,// only used in detailed painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5491
               offsetFromLine:  3 // px left margin amount from icon's right edge
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5492
      //      backgroundColor:   "white",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5493
      //      lineColor:         "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5494
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5495
        highlightColors: [  // Use with getEventPainter().setHighlightMatcher
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5496
                            // See webapp/examples/examples.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5497
            "#FFFF00",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5498
            "#FFC000",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5499
            "#FF0000",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5500
            "#0000FF"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5501
        ],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5502
        highlightLabelBackground: false, // When highlighting an event, also change the event's label background?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5503
        bubble: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5504
            width:          250, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5505
            maxHeight:        0, // px Maximum height of bubbles. 0 means no max height.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5506
                                 // scrollbar will be added for taller bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5507
            titleStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5508
                elmt.className = "timeline-event-bubble-title";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5509
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5510
            bodyStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5511
                elmt.className = "timeline-event-bubble-body";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5512
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5513
            imageStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5514
                elmt.className = "timeline-event-bubble-image";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5515
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5516
            wikiStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5517
                elmt.className = "timeline-event-bubble-wiki";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5518
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5519
            timeStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5520
                elmt.className = "timeline-event-bubble-time";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5521
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5522
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5523
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5524
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5525
    this.mouseWheel = 'scroll'; // 'default', 'zoom', 'scroll'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5526
};/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5527
 *  An "ether" is a object that maps date/time to pixel coordinates.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5528
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5529
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5530
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5531
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5532
 *  Linear Ether
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5533
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5534
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5535
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5536
Timeline.LinearEther = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5537
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5538
    this._interval = params.interval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5539
    this._pixelsPerInterval = params.pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5540
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5541
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5542
Timeline.LinearEther.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5543
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5544
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5545
    this._unit = timeline.getUnit();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5546
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5547
    if ("startsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5548
        this._start = this._unit.parseFromObject(this._params.startsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5549
    } else if ("endsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5550
        this._start = this._unit.parseFromObject(this._params.endsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5551
        this.shiftPixels(-this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5552
    } else if ("centersOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5553
        this._start = this._unit.parseFromObject(this._params.centersOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5554
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5555
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5556
        this._start = this._unit.makeDefaultValue();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5557
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5558
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5559
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5560
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5561
Timeline.LinearEther.prototype.setDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5562
    this._start = this._unit.cloneValue(date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5563
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5564
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5565
Timeline.LinearEther.prototype.shiftPixels = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5566
    var numeric = this._interval * pixels / this._pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5567
    this._start = this._unit.change(this._start, numeric);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5568
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5569
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5570
Timeline.LinearEther.prototype.dateToPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5571
    var numeric = this._unit.compare(date, this._start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5572
    return this._pixelsPerInterval * numeric / this._interval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5573
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5574
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5575
Timeline.LinearEther.prototype.pixelOffsetToDate = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5576
    var numeric = pixels * this._interval / this._pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5577
    return this._unit.change(this._start, numeric);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5578
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5579
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5580
Timeline.LinearEther.prototype.zoom = function(zoomIn) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5581
  var netIntervalChange = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5582
  var currentZoomIndex = this._band._zoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5583
  var newZoomIndex = currentZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5584
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5585
  if (zoomIn && (currentZoomIndex > 0)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5586
    newZoomIndex = currentZoomIndex - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5587
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5588
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5589
  if (!zoomIn && (currentZoomIndex < (this._band._zoomSteps.length - 1))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5590
    newZoomIndex = currentZoomIndex + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5591
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5592
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5593
  this._band._zoomIndex = newZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5594
  this._interval =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5595
    SimileAjax.DateTime.gregorianUnitLengths[this._band._zoomSteps[newZoomIndex].unit];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5596
  this._pixelsPerInterval = this._band._zoomSteps[newZoomIndex].pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5597
  netIntervalChange = this._band._zoomSteps[newZoomIndex].unit -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5598
    this._band._zoomSteps[currentZoomIndex].unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5599
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5600
  return netIntervalChange;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5601
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5602
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5603
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5604
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5605
 *  Hot Zone Ether
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5606
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5607
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5608
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5609
Timeline.HotZoneEther = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5610
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5611
    this._interval = params.interval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5612
    this._pixelsPerInterval = params.pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5613
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5614
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5615
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5616
Timeline.HotZoneEther.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5617
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5618
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5619
    this._unit = timeline.getUnit();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5620
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5621
    this._zones = [{
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5622
        startTime:  Number.NEGATIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5623
        endTime:    Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5624
        magnify:    1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5625
    }];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5626
    var params = this._params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5627
    for (var i = 0; i < params.zones.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5628
        var zone = params.zones[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5629
        var zoneStart = this._unit.parseFromObject(zone.start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5630
        var zoneEnd =   this._unit.parseFromObject(zone.end);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5631
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5632
        for (var j = 0; j < this._zones.length && this._unit.compare(zoneEnd, zoneStart) > 0; j++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5633
            var zone2 = this._zones[j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5634
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5635
            if (this._unit.compare(zoneStart, zone2.endTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5636
                if (this._unit.compare(zoneStart, zone2.startTime) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5637
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5638
                        startTime:   zone2.startTime,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5639
                        endTime:     zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5640
                        magnify:     zone2.magnify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5641
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5642
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5643
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5644
                    zone2.startTime = zoneStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5645
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5646
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5647
                if (this._unit.compare(zoneEnd, zone2.endTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5648
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5649
                        startTime:  zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5650
                        endTime:    zoneEnd,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5651
                        magnify:    zone.magnify * zone2.magnify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5652
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5653
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5654
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5655
                    zone2.startTime = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5656
                    zoneStart = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5657
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5658
                    zone2.magnify *= zone.magnify;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5659
                    zoneStart = zone2.endTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5660
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5661
            } // else, try the next existing zone
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5662
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5663
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5664
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5665
    if ("startsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5666
        this._start = this._unit.parseFromObject(this._params.startsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5667
    } else if ("endsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5668
        this._start = this._unit.parseFromObject(this._params.endsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5669
        this.shiftPixels(-this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5670
    } else if ("centersOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5671
        this._start = this._unit.parseFromObject(this._params.centersOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5672
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5673
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5674
        this._start = this._unit.makeDefaultValue();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5675
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5676
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5677
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5678
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5679
Timeline.HotZoneEther.prototype.setDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5680
    this._start = this._unit.cloneValue(date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5681
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5682
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5683
Timeline.HotZoneEther.prototype.shiftPixels = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5684
    this._start = this.pixelOffsetToDate(pixels);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5685
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5686
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5687
Timeline.HotZoneEther.prototype.dateToPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5688
    return this._dateDiffToPixelOffset(this._start, date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5689
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5690
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5691
Timeline.HotZoneEther.prototype.pixelOffsetToDate = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5692
    return this._pixelOffsetToDate(pixels, this._start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5693
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5694
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5695
Timeline.HotZoneEther.prototype.zoom = function(zoomIn) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5696
  var netIntervalChange = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5697
  var currentZoomIndex = this._band._zoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5698
  var newZoomIndex = currentZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5699
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5700
  if (zoomIn && (currentZoomIndex > 0)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5701
    newZoomIndex = currentZoomIndex - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5702
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5703
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5704
  if (!zoomIn && (currentZoomIndex < (this._band._zoomSteps.length - 1))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5705
    newZoomIndex = currentZoomIndex + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5706
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5707
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5708
  this._band._zoomIndex = newZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5709
  this._interval =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5710
    SimileAjax.DateTime.gregorianUnitLengths[this._band._zoomSteps[newZoomIndex].unit];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5711
  this._pixelsPerInterval = this._band._zoomSteps[newZoomIndex].pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5712
  netIntervalChange = this._band._zoomSteps[newZoomIndex].unit -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5713
    this._band._zoomSteps[currentZoomIndex].unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5714
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5715
  return netIntervalChange;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5716
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5717
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5718
Timeline.HotZoneEther.prototype._dateDiffToPixelOffset = function(fromDate, toDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5719
    var scale = this._getScale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5720
    var fromTime = fromDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5721
    var toTime = toDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5722
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5723
    var pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5724
    if (this._unit.compare(fromTime, toTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5725
        var z = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5726
        while (z < this._zones.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5727
            if (this._unit.compare(fromTime, this._zones[z].endTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5728
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5729
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5730
            z++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5731
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5732
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5733
        while (this._unit.compare(fromTime, toTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5734
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5735
            var toTime2 = this._unit.earlier(toTime, zone.endTime);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5736
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5737
            pixels += (this._unit.compare(toTime2, fromTime) / (scale / zone.magnify));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5738
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5739
            fromTime = toTime2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5740
            z++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5741
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5742
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5743
        var z = this._zones.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5744
        while (z >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5745
            if (this._unit.compare(fromTime, this._zones[z].startTime) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5746
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5747
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5748
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5749
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5750
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5751
        while (this._unit.compare(fromTime, toTime) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5752
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5753
            var toTime2 = this._unit.later(toTime, zone.startTime);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5754
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5755
            pixels += (this._unit.compare(toTime2, fromTime) / (scale / zone.magnify));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5756
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5757
            fromTime = toTime2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5758
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5759
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5760
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5761
    return pixels;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5762
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5763
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5764
Timeline.HotZoneEther.prototype._pixelOffsetToDate = function(pixels, fromDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5765
    var scale = this._getScale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5766
    var time = fromDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5767
    if (pixels > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5768
        var z = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5769
        while (z < this._zones.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5770
            if (this._unit.compare(time, this._zones[z].endTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5771
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5772
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5773
            z++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5774
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5775
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5776
        while (pixels > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5777
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5778
            var scale2 = scale / zone.magnify;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5779
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5780
            if (zone.endTime == Number.POSITIVE_INFINITY) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5781
                time = this._unit.change(time, pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5782
                pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5783
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5784
                var pixels2 = this._unit.compare(zone.endTime, time) / scale2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5785
                if (pixels2 > pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5786
                    time = this._unit.change(time, pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5787
                    pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5788
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5789
                    time = zone.endTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5790
                    pixels -= pixels2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5791
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5792
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5793
            z++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5794
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5795
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5796
        var z = this._zones.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5797
        while (z >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5798
            if (this._unit.compare(time, this._zones[z].startTime) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5799
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5800
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5801
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5802
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5803
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5804
        pixels = -pixels;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5805
        while (pixels > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5806
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5807
            var scale2 = scale / zone.magnify;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5808
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5809
            if (zone.startTime == Number.NEGATIVE_INFINITY) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5810
                time = this._unit.change(time, -pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5811
                pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5812
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5813
                var pixels2 = this._unit.compare(time, zone.startTime) / scale2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5814
                if (pixels2 > pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5815
                    time = this._unit.change(time, -pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5816
                    pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5817
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5818
                    time = zone.startTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5819
                    pixels -= pixels2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5820
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5821
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5822
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5823
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5824
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5825
    return time;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5826
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5827
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5828
Timeline.HotZoneEther.prototype._getScale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5829
    return this._interval / this._pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5830
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5831
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5832
 *  Gregorian Ether Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5833
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5834
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5835
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5836
Timeline.GregorianEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5837
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5838
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5839
    this._unit = params.unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5840
    this._multiple = ("multiple" in params) ? params.multiple : 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5841
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5842
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5843
Timeline.GregorianEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5844
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5845
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5846
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5847
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5848
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5849
    this._backgroundLayer.className = 'timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5850
  //  this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5851
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5852
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5853
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5854
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5855
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5856
    var align = ("align" in this._params && this._params.align != undefined) ? this._params.align :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5857
        this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5858
    var showLine = ("showLine" in this._params) ? this._params.showLine :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5859
        this._theme.ether.interval.line.show;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5860
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5861
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5862
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5863
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5864
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5865
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5866
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5867
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5868
Timeline.GregorianEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5869
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5870
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5871
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5872
Timeline.GregorianEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5873
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5874
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5875
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5876
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5877
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5878
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5879
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5880
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5881
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5882
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5883
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5884
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5885
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5886
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5887
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5888
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5889
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5890
    var timeZone = this._band.getTimeZone();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5891
    var labeller = this._band.getLabeller();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5892
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5893
    SimileAjax.DateTime.roundDownToInterval(minDate, this._unit, timeZone, this._multiple, this._theme.firstDayOfWeek);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5894
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5895
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5896
    var incrementDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5897
        for (var i = 0; i < p._multiple; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5898
            SimileAjax.DateTime.incrementByInterval(date, p._unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5899
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5900
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5901
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5902
    while (minDate.getTime() < maxDate.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5903
        this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5904
            minDate, labeller, this._unit, this._markerLayer, this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5905
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5906
        incrementDate(minDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5907
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5908
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5909
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5910
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5911
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5912
Timeline.GregorianEtherPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5913
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5914
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5915
Timeline.GregorianEtherPainter.prototype.zoom = function(netIntervalChange) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5916
  if (netIntervalChange != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5917
    this._unit += netIntervalChange;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5918
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5919
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5920
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5921
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5922
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5923
 *  Hot Zone Gregorian Ether Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5924
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5925
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5926
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5927
Timeline.HotZoneGregorianEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5928
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5929
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5930
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5931
    this._zones = [{
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5932
        startTime:  Number.NEGATIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5933
        endTime:    Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5934
        unit:       params.unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5935
        multiple:   1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5936
    }];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5937
    for (var i = 0; i < params.zones.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5938
        var zone = params.zones[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5939
        var zoneStart = SimileAjax.DateTime.parseGregorianDateTime(zone.start).getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5940
        var zoneEnd = SimileAjax.DateTime.parseGregorianDateTime(zone.end).getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5941
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5942
        for (var j = 0; j < this._zones.length && zoneEnd > zoneStart; j++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5943
            var zone2 = this._zones[j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5944
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5945
            if (zoneStart < zone2.endTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5946
                if (zoneStart > zone2.startTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5947
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5948
                        startTime:   zone2.startTime,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5949
                        endTime:     zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5950
                        unit:        zone2.unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5951
                        multiple:    zone2.multiple
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5952
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5953
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5954
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5955
                    zone2.startTime = zoneStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5956
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5957
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5958
                if (zoneEnd < zone2.endTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5959
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5960
                        startTime:  zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5961
                        endTime:    zoneEnd,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5962
                        unit:       zone.unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5963
                        multiple:   (zone.multiple) ? zone.multiple : 1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5964
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5965
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5966
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5967
                    zone2.startTime = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5968
                    zoneStart = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5969
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5970
                    zone2.multiple = zone.multiple;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5971
                    zone2.unit = zone.unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5972
                    zoneStart = zone2.endTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5973
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5974
            } // else, try the next existing zone
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5975
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5976
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5977
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5978
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5979
Timeline.HotZoneGregorianEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5980
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5981
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5982
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5983
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5984
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5985
    this._backgroundLayer.className ='timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5986
    //this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5988
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5989
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5990
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5991
    var align = ("align" in this._params && this._params.align != undefined) ? this._params.align :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5992
        this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5993
    var showLine = ("showLine" in this._params) ? this._params.showLine :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5994
        this._theme.ether.interval.line.show;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5995
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5996
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5997
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5998
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5999
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6000
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6001
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6002
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6003
Timeline.HotZoneGregorianEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6004
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6005
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6006
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6007
Timeline.HotZoneGregorianEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6008
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6009
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6010
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6011
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6012
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6013
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6014
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6015
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6016
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6017
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6018
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6019
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6020
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6021
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6022
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6023
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6024
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6025
    var timeZone = this._band.getTimeZone();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6026
    var labeller = this._band.getLabeller();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6027
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6028
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6029
    var incrementDate = function(date, zone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6030
        for (var i = 0; i < zone.multiple; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6031
            SimileAjax.DateTime.incrementByInterval(date, zone.unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6032
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6033
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6034
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6035
    var zStart = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6036
    while (zStart < this._zones.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6037
        if (minDate.getTime() < this._zones[zStart].endTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6038
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6039
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6040
        zStart++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6041
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6042
    var zEnd = this._zones.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6043
    while (zEnd >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6044
        if (maxDate.getTime() > this._zones[zEnd].startTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6045
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6046
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6047
        zEnd--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6048
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6049
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6050
    for (var z = zStart; z <= zEnd; z++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6051
        var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6052
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6053
        var minDate2 = new Date(Math.max(minDate.getTime(), zone.startTime));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6054
        var maxDate2 = new Date(Math.min(maxDate.getTime(), zone.endTime));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6055
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6056
        SimileAjax.DateTime.roundDownToInterval(minDate2, zone.unit, timeZone, zone.multiple, this._theme.firstDayOfWeek);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6057
        SimileAjax.DateTime.roundUpToInterval(maxDate2, zone.unit, timeZone, zone.multiple, this._theme.firstDayOfWeek);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6058
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6059
        while (minDate2.getTime() < maxDate2.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6060
            this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6061
                minDate2, labeller, zone.unit, this._markerLayer, this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6062
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6063
            incrementDate(minDate2, zone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6064
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6065
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6066
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6067
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6068
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6069
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6070
Timeline.HotZoneGregorianEtherPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6071
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6072
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6073
Timeline.HotZoneGregorianEtherPainter.prototype.zoom = function(netIntervalChange) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6074
  if (netIntervalChange != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6075
    for (var i = 0; i < this._zones.length; ++i) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6076
      if (this._zones[i]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6077
        this._zones[i].unit += netIntervalChange;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6078
      }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6079
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6080
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6081
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6082
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6083
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6084
 *  Year Count Ether Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6085
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6086
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6087
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6088
Timeline.YearCountEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6089
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6090
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6091
    this._startDate = SimileAjax.DateTime.parseGregorianDateTime(params.startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6092
    this._multiple = ("multiple" in params) ? params.multiple : 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6093
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6094
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6095
Timeline.YearCountEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6096
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6097
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6098
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6099
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6100
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6101
    this._backgroundLayer.className = 'timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6102
   // this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6103
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6104
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6105
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6106
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6107
    var align = ("align" in this._params) ? this._params.align :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6108
        this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6109
    var showLine = ("showLine" in this._params) ? this._params.showLine :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6110
        this._theme.ether.interval.line.show;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6111
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6112
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6113
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6114
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6115
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6116
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6117
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6118
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6119
Timeline.YearCountEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6120
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6121
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6122
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6123
Timeline.YearCountEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6124
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6125
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6126
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6127
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6128
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6129
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6130
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6131
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6132
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6133
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6134
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6135
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6136
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6137
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6138
    var minDate = new Date(this._startDate.getTime());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6139
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6140
    var yearDiff = this._band.getMinDate().getUTCFullYear() - this._startDate.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6141
    minDate.setUTCFullYear(this._band.getMinDate().getUTCFullYear() - yearDiff % this._multiple);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6142
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6143
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6144
    var incrementDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6145
        for (var i = 0; i < p._multiple; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6146
            SimileAjax.DateTime.incrementByInterval(date, SimileAjax.DateTime.YEAR);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6147
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6148
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6149
    var labeller = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6150
        labelInterval: function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6151
            var diff = date.getUTCFullYear() - p._startDate.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6152
            return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6153
                text: diff,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6154
                emphasized: diff == 0
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6155
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6156
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6157
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6158
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6159
    while (minDate.getTime() < maxDate.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6160
        this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6161
            minDate, labeller, SimileAjax.DateTime.YEAR, this._markerLayer, this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6162
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6163
        incrementDate(minDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6164
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6165
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6166
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6167
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6168
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6169
Timeline.YearCountEtherPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6170
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6171
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6172
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6173
 *  Quarterly Ether Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6174
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6175
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6176
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6177
Timeline.QuarterlyEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6178
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6179
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6180
    this._startDate = SimileAjax.DateTime.parseGregorianDateTime(params.startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6181
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6182
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6183
Timeline.QuarterlyEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6184
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6185
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6186
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6187
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6188
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6189
    this._backgroundLayer.className = 'timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6190
 //   this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6191
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6192
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6193
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6194
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6195
    var align = ("align" in this._params) ? this._params.align :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6196
        this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6197
    var showLine = ("showLine" in this._params) ? this._params.showLine :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6198
        this._theme.ether.interval.line.show;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6199
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6200
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6201
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6202
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6203
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6204
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6205
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6206
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6207
Timeline.QuarterlyEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6208
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6209
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6210
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6211
Timeline.QuarterlyEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6212
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6213
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6214
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6215
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6216
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6217
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6218
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6219
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6220
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6221
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6222
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6223
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6224
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6225
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6226
    var minDate = new Date(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6227
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6228
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6229
    minDate.setUTCFullYear(Math.max(this._startDate.getUTCFullYear(), this._band.getMinDate().getUTCFullYear()));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6230
    minDate.setUTCMonth(this._startDate.getUTCMonth());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6231
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6232
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6233
    var incrementDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6234
        date.setUTCMonth(date.getUTCMonth() + 3);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6235
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6236
    var labeller = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6237
        labelInterval: function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6238
            var quarters = (4 + (date.getUTCMonth() - p._startDate.getUTCMonth()) / 3) % 4;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6239
            if (quarters != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6240
                return { text: "Q" + (quarters + 1), emphasized: false };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6241
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6242
                return { text: "Y" + (date.getUTCFullYear() - p._startDate.getUTCFullYear() + 1), emphasized: true };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6243
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6244
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6245
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6246
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6247
    while (minDate.getTime() < maxDate.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6248
        this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6249
            minDate, labeller, SimileAjax.DateTime.YEAR, this._markerLayer, this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6250
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6251
        incrementDate(minDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6252
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6253
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6254
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6255
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6256
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6257
Timeline.QuarterlyEtherPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6258
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6259
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6260
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6261
 *  Ether Interval Marker Layout
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6262
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6263
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6264
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6265
Timeline.EtherIntervalMarkerLayout = function(timeline, band, theme, align, showLine) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6266
    var horizontal = timeline.isHorizontal();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6267
    if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6268
        if (align == "Top") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6269
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6270
                div.style.left = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6271
                div.style.top = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6272
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6273
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6274
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6275
                div.style.left = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6276
                div.style.bottom = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6277
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6278
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6279
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6280
        if (align == "Left") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6281
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6282
                div.style.top = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6283
                div.style.left = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6284
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6285
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6286
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6287
                div.style.top = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6288
                div.style.right = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6289
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6290
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6291
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6292
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6293
    var markerTheme = theme.ether.interval.marker;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6294
    var lineTheme = theme.ether.interval.line;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6295
    var weekendTheme = theme.ether.interval.weekend;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6296
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6297
    var stylePrefix = (horizontal ? "h" : "v") + align;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6298
    var labelStyler = markerTheme[stylePrefix + "Styler"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6299
    var emphasizedLabelStyler = markerTheme[stylePrefix + "EmphasizedStyler"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6300
    var day = SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.DAY];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6301
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6302
    this.createIntervalMarker = function(date, labeller, unit, markerDiv, lineDiv) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6303
        var offset = Math.round(band.dateToPixelOffset(date));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6304
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6305
        if (showLine && unit != SimileAjax.DateTime.WEEK) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6306
            var divLine = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6307
            divLine.className = "timeline-ether-lines";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6308
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6309
            if (lineTheme.opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6310
                SimileAjax.Graphics.setOpacity(divLine, lineTheme.opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6311
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6312
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6313
            if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6314
				//divLine.className += " timeline-ether-lines-vertical";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6315
				divLine.style.left = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6316
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6317
				//divLine.className += " timeline-ether-lines-horizontal";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6318
                divLine.style.top = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6319
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6320
            lineDiv.appendChild(divLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6321
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6322
        if (unit == SimileAjax.DateTime.WEEK) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6323
            var firstDayOfWeek = theme.firstDayOfWeek;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6324
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6325
            var saturday = new Date(date.getTime() + (6 - firstDayOfWeek - 7) * day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6326
            var monday = new Date(saturday.getTime() + 2 * day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6327
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6328
            var saturdayPixel = Math.round(band.dateToPixelOffset(saturday));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6329
            var mondayPixel = Math.round(band.dateToPixelOffset(monday));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6330
            var length = Math.max(1, mondayPixel - saturdayPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6331
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6332
            var divWeekend = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6333
			divWeekend.className = 'timeline-ether-weekends'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6334
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6335
            if (weekendTheme.opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6336
                SimileAjax.Graphics.setOpacity(divWeekend, weekendTheme.opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6337
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6338
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6339
            if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6340
                divWeekend.style.left = saturdayPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6341
                divWeekend.style.width = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6342
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6343
                divWeekend.style.top = saturdayPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6344
                divWeekend.style.height = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6345
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6346
            lineDiv.appendChild(divWeekend);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6347
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6348
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6349
        var label = labeller.labelInterval(date, unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6350
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6351
        var div = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6352
        div.innerHTML = label.text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6353
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6354
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6355
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6356
		div.className = 'timeline-date-label'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6357
		if(label.emphasized) div.className += ' timeline-date-label-em'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6358
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6359
        this.positionDiv(div, offset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6360
        markerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6361
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6362
        return div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6363
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6364
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6365
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6366
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6367
 *  Ether Highlight Layout
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6368
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6369
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6370
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6371
Timeline.EtherHighlight = function(timeline, band, theme, backgroundLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6372
    var horizontal = timeline.isHorizontal();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6373
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6374
    this._highlightDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6375
    this._createHighlightDiv = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6376
        if (this._highlightDiv == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6377
            this._highlightDiv = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6378
            this._highlightDiv.setAttribute("name", "ether-highlight"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6379
            this._highlightDiv.className = 'timeline-ether-highlight'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6380
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6381
            var opacity = theme.ether.highlightOpacity;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6382
            if (opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6383
                SimileAjax.Graphics.setOpacity(this._highlightDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6384
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6385
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6386
            backgroundLayer.appendChild(this._highlightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6387
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6388
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6389
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6390
    this.position = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6391
        this._createHighlightDiv();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6392
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6393
        var startPixel = Math.round(band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6394
        var endPixel = Math.round(band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6395
        var length = Math.max(endPixel - startPixel, 3);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6396
        if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6397
            this._highlightDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6398
            this._highlightDiv.style.width = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6399
            this._highlightDiv.style.height = (band.getViewWidth() - 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6400
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6401
            this._highlightDiv.style.top = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6402
            this._highlightDiv.style.height = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6403
            this._highlightDiv.style.width = (band.getViewWidth() - 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6404
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6405
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6406
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6407
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6408
 *  Event Utils
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6409
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6410
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6411
Timeline.EventUtils = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6412
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6413
Timeline.EventUtils.getNewEventID = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6414
    // global across page
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6415
    if (this._lastEventID == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6416
        this._lastEventID = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6417
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6418
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6419
    this._lastEventID += 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6420
    return "e" + this._lastEventID;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6421
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6422
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6423
Timeline.EventUtils.decodeEventElID = function(elementID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6424
    /*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6425
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6426
     * Use this function to decode an event element's id on a band (label div,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6427
     * tape div or icon img).
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6428
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6429
     * Returns {band: <bandObj>, evt: <eventObj>}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6430
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6431
     * To enable a single event listener to monitor everything
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6432
     * on a Timeline, a set format is used for the id's of the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6433
     * elements on the Timeline--
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6434
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6435
     * element id format for labels, icons, tapes:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6436
     *   labels: label-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6437
     *    icons: icon-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6438
     *    tapes: tape1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6439
     *           tape2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6440
     *           // some events have more than one tape
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6441
     *    highlight: highlight1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6442
     *               highlight2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6443
     *           // some events have more than one highlight div (future)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6444
     * Note: use split('-') to get array of the format's parts
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6445
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6446
     * You can then retrieve the timeline object and event object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6447
     * by using Timeline.getTimeline, Timeline.getBand, or
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6448
     * Timeline.getEvent and passing in the element's id
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6449
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6450
     *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6451
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6452
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6453
    var parts = elementID.split('-');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6454
    if (parts[1] != 'tl') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6455
        alert("Internal Timeline problem 101, please consult support");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6456
        return {band: null, evt: null}; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6457
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6458
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6459
    var timeline = Timeline.getTimelineFromID(parts[2]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6460
    var band = timeline.getBand(parts[3]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6461
    var evt = band.getEventSource.getEvent(parts[4]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6462
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6463
    return {band: band, evt: evt};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6464
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6465
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6466
Timeline.EventUtils.encodeEventElID = function(timeline, band, elType, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6467
    // elType should be one of {label | icon | tapeN | highlightN}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6468
    return elType + "-tl-" + timeline.timelineID +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6469
       "-" + band.getIndex() + "-" + evt.getID();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6470
};/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6471
 *  Gregorian Date Labeller
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6472
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6473
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6474
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6475
Timeline.GregorianDateLabeller = function(locale, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6476
    this._locale = locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6477
    this._timeZone = timeZone;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6478
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6479
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6480
Timeline.GregorianDateLabeller.monthNames = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6481
Timeline.GregorianDateLabeller.dayNames = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6482
Timeline.GregorianDateLabeller.labelIntervalFunctions = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6483
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6484
Timeline.GregorianDateLabeller.getMonthName = function(month, locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6485
    return Timeline.GregorianDateLabeller.monthNames[locale][month];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6486
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6487
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6488
Timeline.GregorianDateLabeller.prototype.labelInterval = function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6489
    var f = Timeline.GregorianDateLabeller.labelIntervalFunctions[this._locale];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6490
    if (f == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6491
        f = Timeline.GregorianDateLabeller.prototype.defaultLabelInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6492
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6493
    return f.call(this, date, intervalUnit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6494
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6495
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6496
Timeline.GregorianDateLabeller.prototype.labelPrecise = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6497
    return SimileAjax.DateTime.removeTimeZoneOffset(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6498
        date,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6499
        this._timeZone //+ (new Date().getTimezoneOffset() / 60)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6500
    ).toUTCString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6501
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6502
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6503
Timeline.GregorianDateLabeller.prototype.defaultLabelInterval = function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6504
    var text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6505
    var emphasized = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6506
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6507
    date = SimileAjax.DateTime.removeTimeZoneOffset(date, this._timeZone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6508
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6509
    switch(intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6510
    case SimileAjax.DateTime.MILLISECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6511
        text = date.getUTCMilliseconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6512
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6513
    case SimileAjax.DateTime.SECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6514
        text = date.getUTCSeconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6515
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6516
    case SimileAjax.DateTime.MINUTE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6517
        var m = date.getUTCMinutes();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6518
        if (m == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6519
            text = date.getUTCHours() + ":00";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6520
            emphasized = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6521
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6522
            text = m;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6523
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6524
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6525
    case SimileAjax.DateTime.HOUR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6526
        text = date.getUTCHours() + "hr";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6527
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6528
    case SimileAjax.DateTime.DAY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6529
        text = Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(), this._locale) + " " + date.getUTCDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6530
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6531
    case SimileAjax.DateTime.WEEK:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6532
        text = Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(), this._locale) + " " + date.getUTCDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6533
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6534
    case SimileAjax.DateTime.MONTH:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6535
        var m = date.getUTCMonth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6536
        if (m != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6537
            text = Timeline.GregorianDateLabeller.getMonthName(m, this._locale);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6538
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6539
        } // else, fall through
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6540
    case SimileAjax.DateTime.YEAR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6541
    case SimileAjax.DateTime.DECADE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6542
    case SimileAjax.DateTime.CENTURY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6543
    case SimileAjax.DateTime.MILLENNIUM:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6544
        var y = date.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6545
        if (y > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6546
            text = date.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6547
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6548
            text = (1 - y) + "BC";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6549
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6550
        emphasized =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6551
            (intervalUnit == SimileAjax.DateTime.MONTH) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6552
            (intervalUnit == SimileAjax.DateTime.DECADE && y % 100 == 0) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6553
            (intervalUnit == SimileAjax.DateTime.CENTURY && y % 1000 == 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6554
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6555
    default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6556
        text = date.toUTCString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6557
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6558
    return { text: text, emphasized: emphasized };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6559
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6560
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6561
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6562
 *  Default Event Source
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6563
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6564
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6565
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6566
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6567
Timeline.DefaultEventSource = function(eventIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6568
    this._events = (eventIndex instanceof Object) ? eventIndex : new SimileAjax.EventIndex();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6569
    this._listeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6570
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6571
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6572
Timeline.DefaultEventSource.prototype.addListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6573
    this._listeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6574
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6575
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6576
Timeline.DefaultEventSource.prototype.removeListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6577
    for (var i = 0; i < this._listeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6578
        if (this._listeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6579
            this._listeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6580
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6581
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6582
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6583
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6584
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6585
Timeline.DefaultEventSource.prototype.loadXML = function(xml, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6586
    var base = this._getBaseURL(url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6587
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6588
    var wikiURL = xml.documentElement.getAttribute("wiki-url");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6589
    var wikiSection = xml.documentElement.getAttribute("wiki-section");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6590
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6591
    var dateTimeFormat = xml.documentElement.getAttribute("date-time-format");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6592
    var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6593
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6594
    var node = xml.documentElement.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6595
    var added = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6596
    while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6597
        if (node.nodeType == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6598
            var description = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6599
            if (node.firstChild != null && node.firstChild.nodeType == 3) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6600
                description = node.firstChild.nodeValue;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6601
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6602
            // instant event: default is true. Or use values from isDuration or durationEvent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6603
            var instant = (node.getAttribute("isDuration")    === null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6604
                           node.getAttribute("durationEvent") === null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6605
                          node.getAttribute("isDuration") == "false" ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6606
                          node.getAttribute("durationEvent") == "false";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6607
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6608
            var evt = new Timeline.DefaultEventSource.Event( {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6609
                          id: node.getAttribute("id"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6610
                       start: parseDateTimeFunction(node.getAttribute("start")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6611
                         end: parseDateTimeFunction(node.getAttribute("end")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6612
                 latestStart: parseDateTimeFunction(node.getAttribute("latestStart")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6613
                 earliestEnd: parseDateTimeFunction(node.getAttribute("earliestEnd")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6614
                     instant: instant,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6615
                        text: node.getAttribute("title"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6616
                 description: description,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6617
                       image: this._resolveRelativeURL(node.getAttribute("image"), base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6618
                        link: this._resolveRelativeURL(node.getAttribute("link") , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6619
                        icon: this._resolveRelativeURL(node.getAttribute("icon") , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6620
                       color: node.getAttribute("color"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6621
                   textColor: node.getAttribute("textColor"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6622
                   hoverText: node.getAttribute("hoverText"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6623
                   classname: node.getAttribute("classname"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6624
                   tapeImage: node.getAttribute("tapeImage"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6625
                  tapeRepeat: node.getAttribute("tapeRepeat"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6626
                     caption: node.getAttribute("caption"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6627
                     eventID: node.getAttribute("eventID"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6628
                    trackNum: node.getAttribute("trackNum")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6629
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6630
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6631
            evt._node = node;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6632
            evt.getProperty = function(name) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6633
                return this._node.getAttribute(name);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6634
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6635
            evt.setWikiInfo(wikiURL, wikiSection);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6636
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6637
            this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6638
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6639
            added = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6640
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6641
        node = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6642
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6643
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6644
    if (added) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6645
        this._fire("onAddMany", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6646
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6647
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6648
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6649
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6650
Timeline.DefaultEventSource.prototype.loadJSON = function(data, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6651
    var base = this._getBaseURL(url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6652
    var added = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6653
    if (data && data.events){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6654
        var wikiURL = ("wikiURL" in data) ? data.wikiURL : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6655
        var wikiSection = ("wikiSection" in data) ? data.wikiSection : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6656
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6657
        var dateTimeFormat = ("dateTimeFormat" in data) ? data.dateTimeFormat : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6658
        var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6659
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6660
        for (var i=0; i < data.events.length; i++){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6661
            var event = data.events[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6662
            // Fixing issue 33:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6663
            // instant event: default (for JSON only) is false. Or use values from isDuration or durationEvent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6664
            // isDuration was negated (see issue 33, so keep that interpretation
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6665
            var instant = event.isDuration || (event.durationEvent != null && !event.durationEvent);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6666
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6667
            var evt = new Timeline.DefaultEventSource.Event({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6668
                          id: ("id" in event) ? event.id : undefined,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6669
                       start: parseDateTimeFunction(event.start),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6670
                         end: parseDateTimeFunction(event.end),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6671
                 latestStart: parseDateTimeFunction(event.latestStart),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6672
                 earliestEnd: parseDateTimeFunction(event.earliestEnd),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6673
                     instant: instant,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6674
                        text: event.title,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6675
                 description: event.description,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6676
                       image: this._resolveRelativeURL(event.image, base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6677
                        link: this._resolveRelativeURL(event.link , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6678
                        icon: this._resolveRelativeURL(event.icon , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6679
                       color: event.color,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6680
                   textColor: event.textColor,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6681
                   hoverText: event.hoverText,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6682
                   classname: event.classname,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6683
                   tapeImage: event.tapeImage,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6684
                  tapeRepeat: event.tapeRepeat,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6685
                     caption: event.caption,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6686
                     eventID: event.eventID,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6687
                    trackNum: event.trackNum
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6688
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6689
            evt._obj = event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6690
            evt.getProperty = function(name) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6691
                return this._obj[name];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6692
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6693
            evt.setWikiInfo(wikiURL, wikiSection);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6694
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6695
            this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6696
            added = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6697
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6698
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6699
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6700
    if (added) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6701
        this._fire("onAddMany", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6702
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6703
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6704
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6705
/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6706
 *  Contributed by Morten Frederiksen, http://www.wasab.dk/morten/
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6707
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6708
Timeline.DefaultEventSource.prototype.loadSPARQL = function(xml, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6709
    var base = this._getBaseURL(url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6710
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6711
    var dateTimeFormat = 'iso8601';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6712
    var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6713
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6714
    if (xml == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6715
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6716
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6717
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6718
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6719
     *  Find <results> tag
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6720
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6721
    var node = xml.documentElement.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6722
    while (node != null && (node.nodeType != 1 || node.nodeName != 'results')) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6723
        node = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6724
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6725
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6726
    var wikiURL = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6727
    var wikiSection = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6728
    if (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6729
        wikiURL = node.getAttribute("wiki-url");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6730
        wikiSection = node.getAttribute("wiki-section");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6731
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6732
        node = node.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6733
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6734
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6735
    var added = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6736
    while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6737
        if (node.nodeType == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6738
            var bindings = { };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6739
            var binding = node.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6740
            while (binding != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6741
                if (binding.nodeType == 1 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6742
                    binding.firstChild != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6743
                    binding.firstChild.nodeType == 1 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6744
                    binding.firstChild.firstChild != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6745
                    binding.firstChild.firstChild.nodeType == 3) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6746
                    bindings[binding.getAttribute('name')] = binding.firstChild.firstChild.nodeValue;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6747
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6748
                binding = binding.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6749
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6750
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6751
            if (bindings["start"] == null && bindings["date"] != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6752
                bindings["start"] = bindings["date"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6753
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6754
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6755
            // instant event: default is true. Or use values from isDuration or durationEvent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6756
            var instant = (bindings["isDuration"]    === null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6757
                           bindings["durationEvent"] === null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6758
                          bindings["isDuration"] == "false" ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6759
                          bindings["durationEvent"] == "false";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6760
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6761
            var evt = new Timeline.DefaultEventSource.Event({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6762
                          id: bindings["id"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6763
                       start: parseDateTimeFunction(bindings["start"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6764
                         end: parseDateTimeFunction(bindings["end"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6765
                 latestStart: parseDateTimeFunction(bindings["latestStart"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6766
                 earliestEnd: parseDateTimeFunction(bindings["earliestEnd"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6767
                     instant: instant, // instant
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6768
                        text: bindings["title"], // text
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6769
                 description: bindings["description"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6770
                       image: this._resolveRelativeURL(bindings["image"], base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6771
                        link: this._resolveRelativeURL(bindings["link"] , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6772
                        icon: this._resolveRelativeURL(bindings["icon"] , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6773
                       color: bindings["color"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6774
                   textColor: bindings["textColor"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6775
                   hoverText: bindings["hoverText"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6776
                     caption: bindings["caption"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6777
                   classname: bindings["classname"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6778
                   tapeImage: bindings["tapeImage"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6779
                  tapeRepeat: bindings["tapeRepeat"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6780
                     eventID: bindings["eventID"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6781
                    trackNum: bindings["trackNum"]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6782
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6783
            evt._bindings = bindings;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6784
            evt.getProperty = function(name) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6785
                return this._bindings[name];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6786
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6787
            evt.setWikiInfo(wikiURL, wikiSection);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6788
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6789
            this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6790
            added = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6791
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6792
        node = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6793
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6794
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6795
    if (added) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6796
        this._fire("onAddMany", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6797
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6798
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6799
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6800
Timeline.DefaultEventSource.prototype.add = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6801
    this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6802
    this._fire("onAddOne", [evt]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6803
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6804
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6805
Timeline.DefaultEventSource.prototype.addMany = function(events) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6806
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6807
        this._events.add(events[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6808
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6809
    this._fire("onAddMany", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6810
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6811
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6812
Timeline.DefaultEventSource.prototype.clear = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6813
    this._events.removeAll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6814
    this._fire("onClear", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6815
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6816
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6817
Timeline.DefaultEventSource.prototype.getEvent = function(id) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6818
    return this._events.getEvent(id);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6819
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6820
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6821
Timeline.DefaultEventSource.prototype.getEventIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6822
    return this._events.getIterator(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6823
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6824
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6825
Timeline.DefaultEventSource.prototype.getEventReverseIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6826
    return this._events.getReverseIterator(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6827
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6828
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6829
Timeline.DefaultEventSource.prototype.getAllEventIterator = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6830
    return this._events.getAllIterator();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6831
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6832
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6833
Timeline.DefaultEventSource.prototype.getCount = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6834
    return this._events.getCount();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6835
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6836
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6837
Timeline.DefaultEventSource.prototype.getEarliestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6838
    return this._events.getEarliestDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6839
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6840
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6841
Timeline.DefaultEventSource.prototype.getLatestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6842
    return this._events.getLatestDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6843
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6844
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6845
Timeline.DefaultEventSource.prototype._fire = function(handlerName, args) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6846
    for (var i = 0; i < this._listeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6847
        var listener = this._listeners[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6848
        if (handlerName in listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6849
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6850
                listener[handlerName].apply(listener, args);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6851
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6852
                SimileAjax.Debug.exception(e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6853
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6854
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6855
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6856
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6857
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6858
Timeline.DefaultEventSource.prototype._getBaseURL = function(url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6859
    if (url.indexOf("://") < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6860
        var url2 = this._getBaseURL(document.location.href);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6861
        if (url.substr(0,1) == "/") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6862
            url = url2.substr(0, url2.indexOf("/", url2.indexOf("://") + 3)) + url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6863
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6864
            url = url2 + url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6865
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6866
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6867
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6868
    var i = url.lastIndexOf("/");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6869
    if (i < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6870
        return "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6871
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6872
        return url.substr(0, i+1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6873
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6874
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6875
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6876
Timeline.DefaultEventSource.prototype._resolveRelativeURL = function(url, base) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6877
    if (url == null || url == "") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6878
        return url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6879
    } else if (url.indexOf("://") > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6880
        return url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6881
    } else if (url.substr(0,1) == "/") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6882
        return base.substr(0, base.indexOf("/", base.indexOf("://") + 3)) + url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6883
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6884
        return base + url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6885
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6886
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6887
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6888
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6889
Timeline.DefaultEventSource.Event = function(args) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6890
  //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6891
  // Attention developers!
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6892
  // If you add a new event attribute, please be sure to add it to
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6893
  // all three load functions: loadXML, loadSPARCL, loadJSON.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6894
  // Thanks!
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6895
  //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6896
  // args is a hash/object. It supports the following keys. Most are optional
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6897
  //   id            -- an internal id. Really shouldn't be used by events.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6898
  //                    Timeline library clients should use eventID
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6899
  //   eventID       -- For use by library client when writing custom painters or
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6900
  //                    custom fillInfoBubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6901
  //   start
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6902
  //   end
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6903
  //   latestStart
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6904
  //   earliestEnd
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6905
  //   instant      -- boolean. Controls precise/non-precise logic & duration/instant issues
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6906
  //   text         -- event source attribute 'title' -- used as the label on Timelines and in bubbles.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6907
  //   description  -- used in bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6908
  //   image        -- used in bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6909
  //   link         -- used in bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6910
  //   icon         -- on the Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6911
  //   color        -- Timeline label and tape color
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6912
  //   textColor    -- Timeline label color, overrides color attribute
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6913
  //   hoverText    -- deprecated, here for backwards compatibility.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6914
  //                   Superceeded by caption
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6915
  //   caption      -- tooltip-like caption on the Timeline. Uses HTML title attribute
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6916
  //   classname    -- used to set classname in Timeline. Enables better CSS selector rules
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6917
  //   tapeImage    -- background image of the duration event's tape div on the Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6918
  //   tapeRepeat   -- repeat attribute for tapeImage. {repeat | repeat-x | repeat-y }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6919
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6920
  function cleanArg(arg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6921
      // clean up an arg
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6922
      return (args[arg] != null && args[arg] != "") ? args[arg] : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6923
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6924
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6925
  var id = args.id ? args.id.trim() : "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6926
  this._id = id.length > 0 ? id : Timeline.EventUtils.getNewEventID();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6927
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6928
  this._instant = args.instant || (args.end == null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6929
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6930
  this._start = args.start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6931
  this._end = (args.end != null) ? args.end : args.start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6932
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6933
  this._latestStart = (args.latestStart != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6934
                       args.latestStart : (args.instant ? this._end : this._start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6935
  this._earliestEnd = (args.earliestEnd != null) ? args.earliestEnd : this._end;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6936
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6937
  // check sanity of dates since incorrect dates will later cause calculation errors
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6938
  // when painting
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6939
  var err=[];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6940
  if (this._start > this._latestStart) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6941
          this._latestStart = this._start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6942
          err.push("start is > latestStart");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6943
  if (this._start > this._earliestEnd) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6944
          this._earliestEnd = this._latestStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6945
          err.push("start is > earliestEnd");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6946
  if (this._start > this._end) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6947
          this._end = this._earliestEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6948
          err.push("start is > end");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6949
  if (this._latestStart > this._earliestEnd) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6950
          this._earliestEnd = this._latestStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6951
          err.push("latestStart is > earliestEnd");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6952
  if (this._latestStart > this._end) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6953
          this._end = this._earliestEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6954
          err.push("latestStart is > end");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6955
  if (this._earliestEnd > this._end) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6956
          this._end = this._earliestEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6957
          err.push("earliestEnd is > end");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6958
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6959
  this._eventID = cleanArg('eventID');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6960
  this._text = (args.text != null) ? SimileAjax.HTML.deEntify(args.text) : ""; // Change blank titles to ""
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6961
  if (err.length > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6962
          this._text += " PROBLEM: " + err.join(", ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6963
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6964
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6965
  this._description = SimileAjax.HTML.deEntify(args.description);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6966
  this._image = cleanArg('image');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6967
  this._link =  cleanArg('link');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6968
  this._title = cleanArg('hoverText');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6969
  this._title = cleanArg('caption');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6970
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6971
  this._icon = cleanArg('icon');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6972
  this._color = cleanArg('color');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6973
  this._textColor = cleanArg('textColor');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6974
  this._classname = cleanArg('classname');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6975
  this._tapeImage = cleanArg('tapeImage');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6976
  this._tapeRepeat = cleanArg('tapeRepeat');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6977
  this._trackNum = cleanArg('trackNum');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6978
  if (this._trackNum != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6979
      this._trackNum = parseInt(this._trackNum);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6980
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6981
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6982
  this._wikiURL = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6983
  this._wikiSection = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6984
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6985
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6986
Timeline.DefaultEventSource.Event.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6987
    getID:          function() { return this._id; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6988
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6989
    isInstant:      function() { return this._instant; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6990
    isImprecise:    function() { return this._start != this._latestStart || this._end != this._earliestEnd; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6991
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6992
    getStart:       function() { return this._start; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6993
    getEnd:         function() { return this._end; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6994
    getLatestStart: function() { return this._latestStart; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6995
    getEarliestEnd: function() { return this._earliestEnd; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6996
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6997
    getEventID:     function() { return this._eventID; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6998
    getText:        function() { return this._text; }, // title
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6999
    getDescription: function() { return this._description; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7000
    getImage:       function() { return this._image; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7001
    getLink:        function() { return this._link; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7002
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7003
    getIcon:        function() { return this._icon; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7004
    getColor:       function() { return this._color; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7005
    getTextColor:   function() { return this._textColor; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7006
    getClassName:   function() { return this._classname; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7007
    getTapeImage:   function() { return this._tapeImage; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7008
    getTapeRepeat:  function() { return this._tapeRepeat; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7009
    getTrackNum:    function() { return this._trackNum; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7010
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7011
    getProperty:    function(name) { return null; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7012
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7013
    getWikiURL:     function() { return this._wikiURL; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7014
    getWikiSection: function() { return this._wikiSection; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7015
    setWikiInfo: function(wikiURL, wikiSection) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7016
        this._wikiURL = wikiURL;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7017
        this._wikiSection = wikiSection;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7018
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7019
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7020
    fillDescription: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7021
        elmt.innerHTML = this._description;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7022
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7023
    fillWikiInfo: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7024
        // Many bubbles will not support a wiki link.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7025
        //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7026
        // Strategy: assume no wiki link. If we do have
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7027
        // enough parameters for one, then create it.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7028
        elmt.style.display = "none"; // default
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7029
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7030
        if (this._wikiURL == null || this._wikiSection == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7031
          return; // EARLY RETURN
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7032
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7033
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7034
        // create the wikiID from the property or from the event text (the title)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7035
        var wikiID = this.getProperty("wikiID");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7036
        if (wikiID == null || wikiID.length == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7037
            wikiID = this.getText(); // use the title as the backup wiki id
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7038
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7039
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7040
        if (wikiID == null || wikiID.length == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7041
          return; // No wikiID. Thus EARLY RETURN
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7042
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7043
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7044
        // ready to go...
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7045
        elmt.style.display = "inline";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7046
        wikiID = wikiID.replace(/\s/g, "_");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7047
        var url = this._wikiURL + this._wikiSection.replace(/\s/g, "_") + "/" + wikiID;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7048
        var a = document.createElement("a");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7049
        a.href = url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7050
        a.target = "new";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7051
        a.innerHTML = Timeline.strings[Timeline.clientLocale].wikiLinkLabel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7052
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7053
        elmt.appendChild(document.createTextNode("["));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7054
        elmt.appendChild(a);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7055
        elmt.appendChild(document.createTextNode("]"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7056
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7057
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7058
    fillTime: function(elmt, labeller) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7059
        if (this._instant) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7060
            if (this.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7061
                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._start)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7062
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7063
                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._end)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7064
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7065
                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._start)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7066
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7067
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7068
            if (this.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7069
                elmt.appendChild(elmt.ownerDocument.createTextNode(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7070
                    labeller.labelPrecise(this._start) + " ~ " + labeller.labelPrecise(this._latestStart)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7071
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7072
                elmt.appendChild(elmt.ownerDocument.createTextNode(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7073
                    labeller.labelPrecise(this._earliestEnd) + " ~ " + labeller.labelPrecise(this._end)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7074
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7075
                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._start)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7076
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7077
                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._end)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7078
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7079
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7080
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7081
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7082
    fillInfoBubble: function(elmt, theme, labeller) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7083
        var doc = elmt.ownerDocument;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7084
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7085
        var title = this.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7086
        var link = this.getLink();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7087
        var image = this.getImage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7088
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7089
        if (image != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7090
            var img = doc.createElement("img");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7091
            img.src = image;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7092
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7093
            theme.event.bubble.imageStyler(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7094
            elmt.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7095
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7096
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7097
        var divTitle = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7098
        var textTitle = doc.createTextNode(title);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7099
        if (link != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7100
            var a = doc.createElement("a");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7101
            a.href = link;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7102
            a.appendChild(textTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7103
            divTitle.appendChild(a);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7104
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7105
            divTitle.appendChild(textTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7106
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7107
        theme.event.bubble.titleStyler(divTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7108
        elmt.appendChild(divTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7109
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7110
        var divBody = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7111
        this.fillDescription(divBody);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7112
        theme.event.bubble.bodyStyler(divBody);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7113
        elmt.appendChild(divBody);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7114
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7115
        var divTime = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7116
        this.fillTime(divTime, labeller);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7117
        theme.event.bubble.timeStyler(divTime);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7118
        elmt.appendChild(divTime);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7119
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7120
        var divWiki = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7121
        this.fillWikiInfo(divWiki);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7122
        theme.event.bubble.wikiStyler(divWiki);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7123
        elmt.appendChild(divWiki);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7124
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7125
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7126
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7127
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7128
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7129
 *  Original Event Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7130
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7131
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7132
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7133
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7134
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7135
 * To enable a single event listener to monitor everything
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7136
 * on a Timeline, we need a way to map from an event's icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7137
 * label or tape element to the associated timeline, band and
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7138
 * specific event.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7139
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7140
 * Thus a set format is used for the id's of the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7141
 * events' elements on the Timeline--
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7142
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7143
 * element id format for labels, icons, tapes:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7144
 *   labels: label-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7145
 *    icons: icon-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7146
 *    tapes: tape1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7147
 *           tape2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7148
 *           // some events have more than one tape
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7149
 *    highlight: highlight1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7150
 *               highlight2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7151
 *           // some events have more than one highlight div (future)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7152
 * You can then retrieve the band/timeline objects and event object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7153
 * by using Timeline.EventUtils.decodeEventElID
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7154
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7155
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7156
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7157
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7158
/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7159
 *    eventPaintListener functions receive calls about painting.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7160
 *    function(band, op, evt, els)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7161
 *       context: 'this' will be an OriginalEventPainter object.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7162
 *                It has properties and methods for obtaining
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7163
 *                the relevant band, timeline, etc
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7164
 *       band = the band being painted
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7165
 *       op = 'paintStarting' // the painter is about to remove
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7166
 *            all previously painted events, if any. It will
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7167
 *            then start painting all of the visible events that
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7168
 *            pass the filter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7169
 *            evt = null, els = null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7170
 *       op = 'paintEnded' // the painter has finished painting
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7171
 *            all of the visible events that passed the filter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7172
 *            evt = null, els = null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7173
 *       op = 'paintedEvent' // the painter just finished painting an event
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7174
 *            evt = event just painted
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7175
 *            els = array of painted elements' divs. Depending on the event,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7176
 *                  the array could be just a tape or icon (if no label).
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7177
 *                  Or could include label, multiple tape divs (imprecise event),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7178
 *                  highlight divs. The array is not ordered. The meaning of
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7179
 *                  each el is available by decoding the el's id
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7180
 *      Note that there may be no paintedEvent calls if no events were visible
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7181
 *      or passed the filter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7182
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7184
Timeline.OriginalEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7185
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7186
    this._onSelectListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7187
    this._eventPaintListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7188
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7189
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7190
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7191
    this._frc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7192
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7193
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7194
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7195
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7196
Timeline.OriginalEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7197
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7198
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7199
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7200
    this._backLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7201
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7202
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7203
    this._highlightLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7204
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7205
    this._eventIdToElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7206
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7207
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7208
Timeline.OriginalEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7209
    return 'original';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7210
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7211
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7212
Timeline.OriginalEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7213
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7214
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7215
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7216
Timeline.OriginalEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7217
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7218
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7219
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7220
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7221
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7222
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7223
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7224
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7225
Timeline.OriginalEventPainter.prototype.addEventPaintListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7226
    this._eventPaintListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7227
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7228
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7229
Timeline.OriginalEventPainter.prototype.removeEventPaintListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7230
    for (var i = 0; i < this._eventPaintListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7231
        if (this._eventPaintListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7232
            this._eventPaintListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7233
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7234
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7235
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7236
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7237
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7238
Timeline.OriginalEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7239
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7240
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7241
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7242
Timeline.OriginalEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7243
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7244
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7245
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7246
Timeline.OriginalEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7247
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7248
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7249
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7250
Timeline.OriginalEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7251
    this._highlightMatcher = highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7252
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7253
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7254
Timeline.OriginalEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7255
    // Paints the events for a given section of the band--what is
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7256
    // visible on screen and some extra.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7257
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7258
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7259
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7260
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7261
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7262
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7263
    this._fireEventPaintListeners('paintStarting', null, null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7264
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7265
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7266
    var metrics = this._computeMetrics();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7267
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7268
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7269
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7270
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7271
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7272
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7273
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7274
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7275
        function(evt) { return -1; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7276
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7277
    var iterator = eventSource.getEventReverseIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7278
    while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7279
        var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7280
        if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7281
            this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7282
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7283
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7284
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7285
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7286
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7287
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7288
    // update the band object for max number of tracks in this section of the ether
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7289
    this._band.updateEventTrackInfo(this._tracks.length, metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7290
    this._fireEventPaintListeners('paintEnded', null, null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7291
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7292
    this._setOrthogonalOffset(metrics);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7293
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7294
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7295
Timeline.OriginalEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7296
    this._setOrthogonalOffset(this._computeMetrics());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7297
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7298
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7299
Timeline.OriginalEventPainter.prototype._setOrthogonalOffset = function(metrics) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7300
    var actualViewWidth = 2 * metrics.trackOffset + this._tracks.length * metrics.trackIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7301
    var minOrthogonalOffset = Math.min(0, this._band.getViewWidth() - actualViewWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7302
    var orthogonalOffset = Math.max(minOrthogonalOffset, this._band.getViewOrthogonalOffset());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7303
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7304
    this._highlightLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7305
        this._lineLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7306
            this._eventLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7307
                orthogonalOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7308
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7309
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7310
Timeline.OriginalEventPainter.prototype._computeMetrics = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7311
     var eventTheme = this._params.theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7312
     var trackHeight = Math.max(eventTheme.track.height, eventTheme.tape.height +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7313
                         this._frc.getLineHeight());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7314
     var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7315
            trackOffset: eventTheme.track.offset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7316
            trackHeight: trackHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7317
               trackGap: eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7318
         trackIncrement: trackHeight + eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7319
                   icon: eventTheme.instant.icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7320
              iconWidth: eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7321
             iconHeight: eventTheme.instant.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7322
             labelWidth: eventTheme.label.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7323
           maxLabelChar: eventTheme.label.maxLabelChar,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7324
    impreciseIconMargin: eventTheme.instant.impreciseIconMargin
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7325
     };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7326
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7327
     return metrics;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7328
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7329
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7330
Timeline.OriginalEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7331
    // Remove everything previously painted: highlight, line and event layers.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7332
    // Prepare blank layers for painting.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7333
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7334
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7335
    if (this._backLayer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7336
        this._backLayer = this._band.createLayerDiv(0, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7337
        this._backLayer.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7338
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7339
        var eventLabelPrototype = document.createElement("span");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7340
        eventLabelPrototype.className = "timeline-event-label";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7341
        this._backLayer.appendChild(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7342
        this._frc = SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7343
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7344
    this._frc.update();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7345
    this._tracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7346
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7347
    if (this._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7348
        band.removeLayerDiv(this._highlightLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7349
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7350
    this._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7351
    this._highlightLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7352
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7353
    if (this._lineLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7354
        band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7355
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7356
    this._lineLayer = band.createLayerDiv(110, "timeline-band-lines");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7357
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7358
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7359
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7360
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7361
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7362
    this._eventLayer = band.createLayerDiv(115, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7363
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7364
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7365
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7366
Timeline.OriginalEventPainter.prototype.paintEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7367
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7368
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7369
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7370
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7371
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7372
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7373
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7374
Timeline.OriginalEventPainter.prototype.paintInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7375
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7376
        this.paintImpreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7377
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7378
        this.paintPreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7379
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7380
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7381
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7382
Timeline.OriginalEventPainter.prototype.paintDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7383
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7384
        this.paintImpreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7385
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7386
        this.paintPreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7387
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7388
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7389
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7390
Timeline.OriginalEventPainter.prototype.paintPreciseInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7391
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7392
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7393
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7394
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7395
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7396
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7397
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7398
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7399
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7400
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7401
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7402
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7403
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7404
    var rightEdge = labelRight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7405
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7406
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7407
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7408
        metrics.trackOffset + track * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7409
        metrics.trackHeight / 2 - labelSize.height / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7410
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7411
    var iconElmtData = this._paintEventIcon(evt, track, iconLeftEdge, metrics, theme, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7412
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7413
        labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7414
    var els = [iconElmtData.elmt, labelElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7415
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7416
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7417
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7418
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7419
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7420
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7421
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7422
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7423
    var hDiv = this._createHighlightDiv(highlightIndex, iconElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7424
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7425
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7426
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7427
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7428
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7429
    this._tracks[track] = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7430
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7431
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7432
Timeline.OriginalEventPainter.prototype.paintImpreciseInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7433
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7434
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7435
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7436
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7437
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7438
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7439
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7440
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7441
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7442
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7443
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7444
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7445
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7446
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7447
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7448
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7449
    var rightEdge = Math.max(labelRight, endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7450
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7451
    var tapeHeight = theme.event.tape.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7452
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7453
        metrics.trackOffset + track * metrics.trackIncrement + tapeHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7454
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7455
    var iconElmtData = this._paintEventIcon(evt, track, iconLeftEdge, metrics, theme, tapeHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7456
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7457
                        labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7458
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7459
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7460
    color = color != null ? color : theme.event.instant.impreciseColor;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7461
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7462
    var tapeElmtData = this._paintEventTape(evt, track, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7463
        color, theme.event.instant.impreciseOpacity, metrics, theme, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7464
    var els = [iconElmtData.elmt, labelElmtData.elmt, tapeElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7465
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7466
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7467
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7468
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7469
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7470
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7471
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7472
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7473
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7474
    var hDiv = this._createHighlightDiv(highlightIndex, iconElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7475
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7476
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7477
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7478
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7479
    this._tracks[track] = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7480
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7481
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7482
Timeline.OriginalEventPainter.prototype.paintPreciseDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7483
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7484
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7485
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7486
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7487
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7488
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7489
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7490
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7491
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7492
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7493
    var labelLeft = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7494
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7495
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7496
    var rightEdge = Math.max(labelRight, endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7497
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7498
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7499
        metrics.trackOffset + track * metrics.trackIncrement + theme.event.tape.height);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7500
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7501
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7502
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7503
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7504
    var tapeElmtData = this._paintEventTape(evt, track, startPixel, endPixel, color, 100, metrics, theme, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7505
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7506
      labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7507
    var els = [tapeElmtData.elmt, labelElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7508
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7509
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7510
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7511
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7512
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7513
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7514
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7515
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7516
    var hDiv = this._createHighlightDiv(highlightIndex, tapeElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7517
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7518
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7519
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7520
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7521
    this._tracks[track] = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7522
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7523
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7524
Timeline.OriginalEventPainter.prototype.paintImpreciseDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7525
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7526
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7527
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7528
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7529
    var latestStartDate = evt.getLatestStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7530
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7531
    var earliestEndDate = evt.getEarliestEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7532
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7533
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7534
    var latestStartPixel = Math.round(this._band.dateToPixelOffset(latestStartDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7535
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7536
    var earliestEndPixel = Math.round(this._band.dateToPixelOffset(earliestEndDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7537
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7538
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7539
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7540
    var labelLeft = latestStartPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7541
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7542
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7543
    var rightEdge = Math.max(labelRight, endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7544
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7545
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7546
        metrics.trackOffset + track * metrics.trackIncrement + theme.event.tape.height);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7547
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7548
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7549
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7550
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7551
    // Imprecise events can have two event tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7552
    // The imprecise dates tape, uses opacity to be dimmer than precise dates
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7553
    var impreciseTapeElmtData = this._paintEventTape(evt, track, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7554
        theme.event.duration.impreciseColor,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7555
        theme.event.duration.impreciseOpacity, metrics, theme, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7556
    // The precise dates tape, regular (100%) opacity
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7557
    var tapeElmtData = this._paintEventTape(evt, track, latestStartPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7558
        earliestEndPixel, color, 100, metrics, theme, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7559
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7560
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7561
        labelSize.width, labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7562
    var els = [impreciseTapeElmtData.elmt, tapeElmtData.elmt, labelElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7563
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7564
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7565
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7566
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7567
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7568
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7569
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7570
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7571
    var hDiv = this._createHighlightDiv(highlightIndex, tapeElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7572
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7573
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7574
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7575
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7576
    this._tracks[track] = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7577
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7578
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7579
Timeline.OriginalEventPainter.prototype._encodeEventElID = function(elType, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7580
    return Timeline.EventUtils.encodeEventElID(this._timeline, this._band, elType, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7581
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7582
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7583
Timeline.OriginalEventPainter.prototype._findFreeTrack = function(event, rightEdge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7584
    var trackAttribute = event.getTrackNum();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7585
    if (trackAttribute != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7586
        return trackAttribute; // early return since event includes track number
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7587
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7588
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7589
    // normal case: find an open track
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7590
    for (var i = 0; i < this._tracks.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7591
        var t = this._tracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7592
        if (t > rightEdge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7593
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7594
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7595
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7596
    return i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7597
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7598
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7599
Timeline.OriginalEventPainter.prototype._paintEventIcon = function(evt, iconTrack, left, metrics, theme, tapeHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7600
    // If no tape, then paint the icon in the middle of the track.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7601
    // If there is a tape, paint the icon below the tape + impreciseIconMargin
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7602
    var icon = evt.getIcon();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7603
    icon = icon != null ? icon : metrics.icon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7604
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7605
    var top; // top of the icon
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7606
    if (tapeHeight > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7607
        top = metrics.trackOffset + iconTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7608
              tapeHeight + metrics.impreciseIconMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7609
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7610
        var middle = metrics.trackOffset + iconTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7611
                     metrics.trackHeight / 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7612
        top = Math.round(middle - metrics.iconHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7613
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7614
    var img = SimileAjax.Graphics.createTranslucentImage(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7615
    var iconDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7616
    iconDiv.className = this._getElClassName('timeline-event-icon', evt, 'icon');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7617
    iconDiv.id = this._encodeEventElID('icon', evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7618
    iconDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7619
    iconDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7620
    iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7621
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7622
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7623
        iconDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7624
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7625
    this._eventLayer.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7626
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7627
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7628
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7629
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7630
        width:  metrics.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7631
        height: metrics.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7632
        elmt:   iconDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7633
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7634
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7635
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7636
Timeline.OriginalEventPainter.prototype._paintEventLabel = function(evt, text, left, top, width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7637
    height, theme, labelDivClassName, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7638
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7639
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7640
    var labelDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7641
    labelDiv.className = labelDivClassName;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7642
    labelDiv.id = this._encodeEventElID('label', evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7643
    labelDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7644
    labelDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7645
    labelDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7646
    labelDiv.innerHTML = text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7647
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7648
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7649
        labelDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7650
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7651
    var color = evt.getTextColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7652
    if (color == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7653
        color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7654
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7655
    if (color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7656
        labelDiv.style.color = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7657
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7658
    if (theme.event.highlightLabelBackground && highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7659
        labelDiv.style.background = this._getHighlightColor(highlightIndex, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7660
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7661
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7662
    this._eventLayer.appendChild(labelDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7663
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7664
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7665
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7666
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7667
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7668
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7669
        elmt:   labelDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7670
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7671
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7672
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7673
Timeline.OriginalEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7674
    evt, iconTrack, startPixel, endPixel, color, opacity, metrics, theme, tape_index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7675
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7676
    var tapeWidth = endPixel - startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7677
    var tapeHeight = theme.event.tape.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7678
    var top = metrics.trackOffset + iconTrack * metrics.trackIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7679
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7680
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7681
    tapeDiv.className = this._getElClassName('timeline-event-tape', evt, 'tape');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7682
    tapeDiv.id = this._encodeEventElID('tape' + tape_index, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7683
    tapeDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7684
    tapeDiv.style.width = tapeWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7685
    tapeDiv.style.height = tapeHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7686
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7687
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7688
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7689
        tapeDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7690
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7691
    if(color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7692
        tapeDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7693
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7694
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7695
    var backgroundImage = evt.getTapeImage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7696
    var backgroundRepeat = evt.getTapeRepeat();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7697
    backgroundRepeat = backgroundRepeat != null ? backgroundRepeat : 'repeat';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7698
    if(backgroundImage != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7699
      tapeDiv.style.backgroundImage = "url(" + backgroundImage + ")";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7700
      tapeDiv.style.backgroundRepeat = backgroundRepeat;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7701
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7702
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7703
    SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7704
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7705
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7706
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7707
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7708
        left:   startPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7709
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7710
        width:  tapeWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7711
        height: tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7712
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7713
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7714
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7715
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7716
Timeline.OriginalEventPainter.prototype._getLabelDivClassName = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7717
    return this._getElClassName('timeline-event-label', evt, 'label');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7718
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7719
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7720
Timeline.OriginalEventPainter.prototype._getElClassName = function(elClassName, evt, prefix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7721
    // Prefix and '_' is added to the event's classname. Set to null for no prefix
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7722
    var evt_classname = evt.getClassName(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7723
        pieces = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7724
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7725
    if (evt_classname) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7726
      if (prefix) {pieces.push(prefix + '-' + evt_classname + ' ');}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7727
      pieces.push(evt_classname + ' ');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7728
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7729
    pieces.push(elClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7730
    return(pieces.join(''));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7731
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7732
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7733
Timeline.OriginalEventPainter.prototype._getHighlightColor = function(highlightIndex, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7734
    var highlightColors = theme.event.highlightColors;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7735
    return highlightColors[Math.min(highlightIndex, highlightColors.length - 1)];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7736
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7737
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7738
Timeline.OriginalEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7739
    var div = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7740
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7741
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7742
        var color = this._getHighlightColor(highlightIndex, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7743
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7744
        div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7745
        div.className = this._getElClassName('timeline-event-highlight', evt, 'highlight');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7746
        div.id = this._encodeEventElID('highlight0', evt); // in future will have other
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7747
                                                           // highlight divs for tapes + icons
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7748
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7749
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7750
        div.style.left =    (dimensions.left - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7751
        div.style.width =   (dimensions.width + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7752
        div.style.top =     (dimensions.top - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7753
        div.style.height =  (dimensions.height + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7754
        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7755
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7756
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7757
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7758
    return div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7759
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7760
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7761
Timeline.OriginalEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7762
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7763
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7764
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7765
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7766
        evt
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7767
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7768
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7769
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7770
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7771
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7772
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7773
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7774
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7775
Timeline.OriginalEventPainter.prototype._onClickDurationEvent = function(target, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7776
    if ("pageX" in domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7777
        var x = domEvt.pageX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7778
        var y = domEvt.pageY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7779
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7780
        var c = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7781
        var x = domEvt.offsetX + c.left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7782
        var y = domEvt.offsetY + c.top;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7783
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7784
    this._showBubble(x, y, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7785
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7786
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7787
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7788
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7789
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7790
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7791
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7792
Timeline.OriginalEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7793
    var elmt = this._eventIdToElmt[evt.getID()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7794
    if (elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7795
        var c = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7796
        this._showBubble(c.left + elmt.offsetWidth / 2, c.top + elmt.offsetHeight / 2, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7797
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7798
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7799
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7800
Timeline.OriginalEventPainter.prototype._showBubble = function(x, y, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7801
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7802
    var themeBubble = this._params.theme.event.bubble;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7803
    evt.fillInfoBubble(div, this._params.theme, this._band.getLabeller());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7804
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7805
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7806
    SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7807
        themeBubble.width, null, themeBubble.maxHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7808
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7809
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7810
Timeline.OriginalEventPainter.prototype._fireOnSelect = function(eventID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7811
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7812
        this._onSelectListeners[i](eventID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7813
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7814
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7815
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7816
Timeline.OriginalEventPainter.prototype._fireEventPaintListeners = function(op, evt, els) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7817
    for (var i = 0; i < this._eventPaintListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7818
        this._eventPaintListeners[i](this._band, op, evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7819
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7820
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7821
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7822
 *  Detailed Event Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7823
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7824
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7825
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7826
// Note: a number of features from original-painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7827
//       are not yet implemented in detailed painter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7828
//       Eg classname, id attributes for icons, labels, tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7829
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7830
Timeline.DetailedEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7831
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7832
    this._onSelectListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7833
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7834
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7835
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7836
    this._frc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7837
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7838
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7839
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7840
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7841
Timeline.DetailedEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7842
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7843
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7844
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7845
    this._backLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7846
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7847
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7848
    this._highlightLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7849
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7850
    this._eventIdToElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7851
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7852
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7853
Timeline.DetailedEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7854
    return 'detailed';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7855
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7856
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7857
Timeline.DetailedEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7858
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7859
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7860
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7861
Timeline.DetailedEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7862
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7863
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7864
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7865
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7866
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7867
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7868
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7869
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7870
Timeline.DetailedEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7871
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7872
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7873
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7874
Timeline.DetailedEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7875
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7876
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7877
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7878
Timeline.DetailedEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7879
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7880
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7881
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7882
Timeline.DetailedEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7883
    this._highlightMatcher = highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7884
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7885
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7886
Timeline.DetailedEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7887
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7888
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7889
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7890
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7891
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7892
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7893
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7894
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7895
    var eventTheme = this._params.theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7896
    var trackHeight = Math.max(eventTheme.track.height, this._frc.getLineHeight());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7897
    var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7898
        trackOffset:    Math.round(this._band.getViewWidth() / 2 - trackHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7899
        trackHeight:    trackHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7900
        trackGap:       eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7901
        trackIncrement: trackHeight + eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7902
        icon:           eventTheme.instant.icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7903
        iconWidth:      eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7904
        iconHeight:     eventTheme.instant.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7905
        labelWidth:     eventTheme.label.width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7906
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7907
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7908
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7909
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7910
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7911
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7912
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7913
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7914
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7915
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7916
        function(evt) { return -1; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7917
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7918
    var iterator = eventSource.getEventReverseIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7919
    while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7920
        var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7921
        if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7922
            this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7923
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7924
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7925
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7926
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7927
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7928
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7929
    // update the band object for max number of tracks in this section of the ether
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7930
    this._band.updateEventTrackInfo(this._lowerTracks.length + this._upperTracks.length,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7931
                                 metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7932
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7933
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7934
Timeline.DetailedEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7935
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7936
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7937
Timeline.DetailedEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7938
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7939
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7940
    if (this._backLayer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7941
        this._backLayer = this._band.createLayerDiv(0, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7942
        this._backLayer.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7943
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7944
        var eventLabelPrototype = document.createElement("span");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7945
        eventLabelPrototype.className = "timeline-event-label";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7946
        this._backLayer.appendChild(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7947
        this._frc = SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7948
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7949
    this._frc.update();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7950
    this._lowerTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7951
    this._upperTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7952
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7953
    if (this._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7954
        band.removeLayerDiv(this._highlightLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7955
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7956
    this._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7957
    this._highlightLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7958
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7959
    if (this._lineLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7960
        band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7961
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7962
    this._lineLayer = band.createLayerDiv(110, "timeline-band-lines");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7963
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7964
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7965
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7966
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7967
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7968
    this._eventLayer = band.createLayerDiv(110, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7969
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7970
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7971
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7972
Timeline.DetailedEventPainter.prototype.paintEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7973
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7974
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7975
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7976
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7977
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7978
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7979
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7980
Timeline.DetailedEventPainter.prototype.paintInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7981
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7982
        this.paintImpreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7983
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7984
        this.paintPreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7985
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7986
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7988
Timeline.DetailedEventPainter.prototype.paintDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7989
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7990
        this.paintImpreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7991
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7992
        this.paintPreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7993
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7994
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7995
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7996
Timeline.DetailedEventPainter.prototype.paintPreciseInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7997
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7998
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7999
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8000
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8001
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8002
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8003
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8004
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8005
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8006
    var iconTrack = this._findFreeTrackForSolid(iconRightEdge, startPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8007
    var iconElmtData = this._paintEventIcon(evt, iconTrack, iconLeftEdge, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8008
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8009
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8010
    var labelTrack = iconTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8011
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8012
    var iconTrackData = this._getTrackData(iconTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8013
    if (Math.min(iconTrackData.solid, iconTrackData.text) >= labelLeft + labelSize.width) { // label on the same track, to the right of icon
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8014
        iconTrackData.solid = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8015
        iconTrackData.text = labelLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8016
    } else { // label on a different track, below icon
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8017
        iconTrackData.solid = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8018
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8019
        labelLeft = startPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8020
        labelTrack = this._findFreeTrackForText(iconTrack, labelLeft + labelSize.width, function(t) { t.line = startPixel - 2; });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8021
        this._getTrackData(labelTrack).text = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8022
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8023
        this._paintEventLine(evt, startPixel, iconTrack, labelTrack, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8024
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8025
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8026
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8027
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8028
        metrics.trackHeight / 2 - labelSize.height / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8029
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8030
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width, labelSize.height, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8031
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8032
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8033
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8034
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8035
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8036
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8037
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8038
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8039
    this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8040
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8041
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8042
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8043
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8044
Timeline.DetailedEventPainter.prototype.paintImpreciseInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8045
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8046
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8047
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8048
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8049
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8050
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8051
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8052
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8053
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8054
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8055
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8056
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8057
    var iconTrack = this._findFreeTrackForSolid(endPixel, startPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8058
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8059
    var tapeElmtData = this._paintEventTape(evt, iconTrack, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8060
        theme.event.instant.impreciseColor, theme.event.instant.impreciseOpacity, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8061
    var iconElmtData = this._paintEventIcon(evt, iconTrack, iconLeftEdge, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8062
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8063
    var iconTrackData = this._getTrackData(iconTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8064
    iconTrackData.solid = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8065
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8066
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8067
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8068
    var labelTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8069
    if (labelRight < endPixel) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8070
        labelTrack = iconTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8071
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8072
        labelLeft = startPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8073
        labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8074
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8075
        labelTrack = this._findFreeTrackForText(iconTrack, labelRight, function(t) { t.line = startPixel - 2; });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8076
        this._getTrackData(labelTrack).text = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8078
        this._paintEventLine(evt, startPixel, iconTrack, labelTrack, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8079
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8080
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8081
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8082
        metrics.trackHeight / 2 - labelSize.height / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8083
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8084
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width, labelSize.height, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8085
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8086
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8087
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8088
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8089
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8090
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8091
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8092
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8093
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8094
    this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8095
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8096
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8097
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8098
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8099
Timeline.DetailedEventPainter.prototype.paintPreciseDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8100
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8101
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8102
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8103
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8104
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8105
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8106
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8107
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8108
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8109
    var tapeTrack = this._findFreeTrackForSolid(endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8110
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8111
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8112
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8113
    var tapeElmtData = this._paintEventTape(evt, tapeTrack, startPixel, endPixel, color, 100, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8114
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8115
    var tapeTrackData = this._getTrackData(tapeTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8116
    tapeTrackData.solid = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8117
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8118
    var labelLeft = startPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8119
    var labelTrack = this._findFreeTrackForText(tapeTrack, labelLeft + labelSize.width, function(t) { t.line = startPixel - 2; });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8120
    this._getTrackData(labelTrack).text = startPixel - 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8121
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8122
    this._paintEventLine(evt, startPixel, tapeTrack, labelTrack, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8123
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8124
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8125
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8126
        metrics.trackHeight / 2 - labelSize.height / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8127
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8128
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width, labelSize.height, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8129
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8130
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8131
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8132
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8133
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8134
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8135
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8136
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8137
    this._createHighlightDiv(highlightIndex, tapeElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8138
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8139
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8140
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8141
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8142
Timeline.DetailedEventPainter.prototype.paintImpreciseDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8143
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8144
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8145
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8146
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8147
    var latestStartDate = evt.getLatestStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8148
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8149
    var earliestEndDate = evt.getEarliestEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8150
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8151
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8152
    var latestStartPixel = Math.round(this._band.dateToPixelOffset(latestStartDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8153
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8154
    var earliestEndPixel = Math.round(this._band.dateToPixelOffset(earliestEndDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8155
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8156
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8157
    var tapeTrack = this._findFreeTrackForSolid(endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8158
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8159
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8160
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8161
    var impreciseTapeElmtData = this._paintEventTape(evt, tapeTrack, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8162
        theme.event.duration.impreciseColor, theme.event.duration.impreciseOpacity, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8163
    var tapeElmtData = this._paintEventTape(evt, tapeTrack, latestStartPixel, earliestEndPixel, color, 100, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8164
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8165
    var tapeTrackData = this._getTrackData(tapeTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8166
    tapeTrackData.solid = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8167
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8168
    var labelLeft = latestStartPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8169
    var labelTrack = this._findFreeTrackForText(tapeTrack, labelLeft + labelSize.width, function(t) { t.line = latestStartPixel - 2; });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8170
    this._getTrackData(labelTrack).text = latestStartPixel - 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8171
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8172
    this._paintEventLine(evt, latestStartPixel, tapeTrack, labelTrack, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8173
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8174
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8175
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8176
        metrics.trackHeight / 2 - labelSize.height / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8177
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8178
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop, labelSize.width, labelSize.height, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8179
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8180
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8181
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8182
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8183
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8184
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8185
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8186
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8187
    this._createHighlightDiv(highlightIndex, tapeElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8188
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8189
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8190
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8191
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8192
Timeline.DetailedEventPainter.prototype._findFreeTrackForSolid = function(solidEdge, softEdge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8193
    for (var i = 0; true; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8194
        if (i < this._lowerTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8195
            var t = this._lowerTracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8196
            if (Math.min(t.solid, t.text) > solidEdge && (!(softEdge) || t.line > softEdge)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8197
                return i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8198
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8199
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8200
            this._lowerTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8201
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8202
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8203
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8204
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8205
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8206
            return i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8207
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8208
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8209
        if (i < this._upperTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8210
            var t = this._upperTracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8211
            if (Math.min(t.solid, t.text) > solidEdge && (!(softEdge) || t.line > softEdge)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8212
                return -1 - i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8213
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8214
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8215
            this._upperTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8216
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8217
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8218
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8219
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8220
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8221
            return -1 - i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8222
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8223
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8224
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8225
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8226
Timeline.DetailedEventPainter.prototype._findFreeTrackForText = function(fromTrack, edge, occupiedTrackVisitor) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8227
    var extendUp;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8228
    var index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8229
    var firstIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8230
    var result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8231
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8232
    if (fromTrack < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8233
        extendUp = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8234
        firstIndex = -fromTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8235
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8236
        index = this._findFreeUpperTrackForText(firstIndex, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8237
        result = -1 - index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8238
    } else if (fromTrack > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8239
        extendUp = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8240
        firstIndex = fromTrack + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8241
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8242
        index = this._findFreeLowerTrackForText(firstIndex, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8243
        result = index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8244
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8245
        var upIndex = this._findFreeUpperTrackForText(0, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8246
        var downIndex = this._findFreeLowerTrackForText(1, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8247
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8248
        if (downIndex - 1 <= upIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8249
            extendUp = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8250
            firstIndex = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8251
            index = downIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8252
            result = index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8253
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8254
            extendUp = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8255
            firstIndex = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8256
            index = upIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8257
            result = -1 - index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8258
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8259
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8260
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8261
    if (extendUp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8262
        if (index == this._upperTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8263
            this._upperTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8264
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8265
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8266
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8267
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8268
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8269
        for (var i = firstIndex; i < index; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8270
            occupiedTrackVisitor(this._upperTracks[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8271
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8272
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8273
        if (index == this._lowerTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8274
            this._lowerTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8275
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8276
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8277
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8278
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8279
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8280
        for (var i = firstIndex; i < index; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8281
            occupiedTrackVisitor(this._lowerTracks[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8282
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8283
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8284
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8285
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8286
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8287
Timeline.DetailedEventPainter.prototype._findFreeLowerTrackForText = function(index, edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8288
    for (; index < this._lowerTracks.length; index++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8289
        var t = this._lowerTracks[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8290
        if (Math.min(t.solid, t.text) >= edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8291
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8292
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8293
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8294
    return index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8295
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8296
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8297
Timeline.DetailedEventPainter.prototype._findFreeUpperTrackForText = function(index, edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8298
    for (; index < this._upperTracks.length; index++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8299
        var t = this._upperTracks[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8300
        if (Math.min(t.solid, t.text) >= edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8301
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8302
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8303
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8304
    return index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8305
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8306
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8307
Timeline.DetailedEventPainter.prototype._getTrackData = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8308
    return (index < 0) ? this._upperTracks[-index - 1] : this._lowerTracks[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8309
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8310
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8311
Timeline.DetailedEventPainter.prototype._paintEventLine = function(evt, left, startTrack, endTrack, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8312
    var top = Math.round(metrics.trackOffset + startTrack * metrics.trackIncrement + metrics.trackHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8313
    var height = Math.round(Math.abs(endTrack - startTrack) * metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8314
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8315
    var lineStyle = "1px solid " + theme.event.label.lineColor;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8316
    var lineDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8317
	lineDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8318
    lineDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8319
    lineDiv.style.width = theme.event.label.offsetFromLine + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8320
    lineDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8321
    if (startTrack > endTrack) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8322
        lineDiv.style.top = (top - height) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8323
        lineDiv.style.borderTop = lineStyle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8324
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8325
        lineDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8326
        lineDiv.style.borderBottom = lineStyle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8327
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8328
    lineDiv.style.borderLeft = lineStyle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8329
    this._lineLayer.appendChild(lineDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8330
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8331
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8332
Timeline.DetailedEventPainter.prototype._paintEventIcon = function(evt, iconTrack, left, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8333
    var icon = evt.getIcon();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8334
    icon = icon != null ? icon : metrics.icon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8335
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8336
    var middle = metrics.trackOffset + iconTrack * metrics.trackIncrement + metrics.trackHeight / 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8337
    var top = Math.round(middle - metrics.iconHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8338
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8339
    var img = SimileAjax.Graphics.createTranslucentImage(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8340
    var iconDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8341
    iconDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8342
    iconDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8343
    iconDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8344
    iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8345
    iconDiv.style.cursor = "pointer";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8346
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8347
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8348
        iconDiv.title = evt._title
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8349
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8350
    this._eventLayer.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8351
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8352
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8353
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8354
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8355
        width:  metrics.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8356
        height: metrics.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8357
        elmt:   iconDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8358
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8359
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8360
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8361
Timeline.DetailedEventPainter.prototype._paintEventLabel = function(evt, text, left, top, width, height, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8362
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8363
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8364
    var labelBackgroundDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8365
    labelBackgroundDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8366
    labelBackgroundDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8367
    labelBackgroundDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8368
    labelBackgroundDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8369
    labelBackgroundDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8370
    labelBackgroundDiv.style.backgroundColor = theme.event.label.backgroundColor;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8371
    SimileAjax.Graphics.setOpacity(labelBackgroundDiv, theme.event.label.backgroundOpacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8372
    this._eventLayer.appendChild(labelBackgroundDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8373
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8374
    var labelDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8375
    labelDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8376
    labelDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8377
    labelDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8378
    labelDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8379
    labelDiv.innerHTML = text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8380
    labelDiv.style.cursor = "pointer";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8381
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8382
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8383
        labelDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8384
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8385
    var color = evt.getTextColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8386
    if (color == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8387
        color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8388
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8389
    if (color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8390
        labelDiv.style.color = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8391
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8392
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8393
    this._eventLayer.appendChild(labelDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8394
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8395
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8396
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8397
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8398
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8399
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8400
        elmt:   labelDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8401
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8402
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8403
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8404
Timeline.DetailedEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8405
    evt, iconTrack, startPixel, endPixel, color, opacity, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8406
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8407
    var tapeWidth = endPixel - startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8408
    var tapeHeight = theme.event.tape.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8409
    var middle = metrics.trackOffset + iconTrack * metrics.trackIncrement + metrics.trackHeight / 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8410
    var top = Math.round(middle - tapeHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8411
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8412
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8413
    tapeDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8414
    tapeDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8415
    tapeDiv.style.width = tapeWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8416
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8417
    tapeDiv.style.height = tapeHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8418
    tapeDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8419
    tapeDiv.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8420
    tapeDiv.style.cursor = "pointer";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8421
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8422
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8423
        tapeDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8424
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8425
    SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8426
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8427
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8428
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8429
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8430
        left:   startPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8431
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8432
        width:  tapeWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8433
        height: tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8434
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8435
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8436
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8437
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8438
Timeline.DetailedEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8439
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8440
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8441
        var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8442
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8443
        var color = eventTheme.highlightColors[Math.min(highlightIndex, eventTheme.highlightColors.length - 1)];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8444
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8445
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8446
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8447
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8448
        div.style.left =    (dimensions.left - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8449
        div.style.width =   (dimensions.width + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8450
        div.style.top =     (dimensions.top - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8451
        div.style.height =  (dimensions.height + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8452
        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8453
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8454
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8455
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8456
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8457
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8458
Timeline.DetailedEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8459
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8460
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8461
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8462
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8463
        evt
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8464
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8465
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8466
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8467
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8468
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8469
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8470
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8471
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8472
Timeline.DetailedEventPainter.prototype._onClickDurationEvent = function(target, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8473
    if ("pageX" in domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8474
        var x = domEvt.pageX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8475
        var y = domEvt.pageY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8476
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8477
        var c = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8478
        var x = domEvt.offsetX + c.left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8479
        var y = domEvt.offsetY + c.top;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8480
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8481
    this._showBubble(x, y, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8482
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8483
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8484
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8485
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8486
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8487
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8488
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8489
Timeline.DetailedEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8490
    var elmt = this._eventIdToElmt[evt.getID()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8491
    if (elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8492
        var c = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8493
        this._showBubble(c.left + elmt.offsetWidth / 2, c.top + elmt.offsetHeight / 2, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8494
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8495
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8496
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8497
Timeline.DetailedEventPainter.prototype._showBubble = function(x, y, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8498
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8499
    var themeBubble = this._params.theme.event.bubble;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8500
    evt.fillInfoBubble(div, this._params.theme, this._band.getLabeller());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8501
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8502
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8503
    SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8504
       themeBubble.width, null, themeBubble.maxHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8505
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8506
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8507
Timeline.DetailedEventPainter.prototype._fireOnSelect = function(eventID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8508
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8509
        this._onSelectListeners[i](eventID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8510
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8511
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8512
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8513
 *  Overview Event Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8514
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8515
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8516
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8517
Timeline.OverviewEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8518
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8519
    this._onSelectListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8520
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8521
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8522
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8523
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8524
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8525
Timeline.OverviewEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8526
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8527
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8528
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8529
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8530
    this._highlightLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8531
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8532
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8533
Timeline.OverviewEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8534
    return 'overview';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8535
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8536
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8537
Timeline.OverviewEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8538
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8539
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8540
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8541
Timeline.OverviewEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8542
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8543
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8544
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8545
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8546
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8547
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8548
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8549
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8550
Timeline.OverviewEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8551
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8552
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8553
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8554
Timeline.OverviewEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8555
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8556
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8557
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8558
Timeline.OverviewEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8559
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8560
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8561
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8562
Timeline.OverviewEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8563
    this._highlightMatcher = highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8564
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8565
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8566
Timeline.OverviewEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8567
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8568
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8569
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8570
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8571
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8572
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8573
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8574
    var eventTheme = this._params.theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8575
    var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8576
        trackOffset:    eventTheme.overviewTrack.offset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8577
        trackHeight:    eventTheme.overviewTrack.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8578
        trackGap:       eventTheme.overviewTrack.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8579
        trackIncrement: eventTheme.overviewTrack.height + eventTheme.overviewTrack.gap
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8580
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8581
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8582
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8583
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8584
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8585
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8586
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8587
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8588
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8589
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8590
        function(evt) { return -1; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8591
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8592
    var iterator = eventSource.getEventReverseIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8593
    while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8594
        var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8595
        if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8596
            this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8597
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8598
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8599
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8600
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8601
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8602
    // update the band object for max number of tracks in this section of the ether
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8603
    this._band.updateEventTrackInfo(this._tracks.length, metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8604
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8605
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8606
Timeline.OverviewEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8607
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8608
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8609
Timeline.OverviewEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8610
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8611
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8612
    this._tracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8613
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8614
    if (this._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8615
        band.removeLayerDiv(this._highlightLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8616
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8617
    this._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8618
    this._highlightLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8619
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8620
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8621
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8622
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8623
    this._eventLayer = band.createLayerDiv(110, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8624
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8625
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8626
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8627
Timeline.OverviewEventPainter.prototype.paintEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8628
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8629
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8630
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8631
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8632
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8633
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8634
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8635
Timeline.OverviewEventPainter.prototype.paintInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8636
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8637
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8638
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8639
    var color = evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8640
        klassName = evt.getClassName();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8641
    if (klassName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8642
      color = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8643
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8644
      color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8645
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8646
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8647
    var tickElmtData = this._paintEventTick(evt, startPixel, color, 100, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8648
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8649
    this._createHighlightDiv(highlightIndex, tickElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8650
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8651
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8652
Timeline.OverviewEventPainter.prototype.paintDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8653
    var latestStartDate = evt.getLatestStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8654
    var earliestEndDate = evt.getEarliestEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8655
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8656
    var latestStartPixel = Math.round(this._band.dateToPixelOffset(latestStartDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8657
    var earliestEndPixel = Math.round(this._band.dateToPixelOffset(earliestEndDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8658
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8659
    var tapeTrack = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8660
    for (; tapeTrack < this._tracks.length; tapeTrack++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8661
        if (earliestEndPixel < this._tracks[tapeTrack]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8662
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8663
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8664
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8665
    this._tracks[tapeTrack] = earliestEndPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8666
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8667
    var color = evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8668
        klassName = evt.getClassName();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8669
    if (klassName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8670
      color = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8671
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8672
      color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8673
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8674
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8675
    var tapeElmtData = this._paintEventTape(evt, tapeTrack, latestStartPixel, earliestEndPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8676
      color, 100, metrics, theme, klassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8677
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8678
    this._createHighlightDiv(highlightIndex, tapeElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8679
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8680
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8681
Timeline.OverviewEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8682
    evt, track, left, right, color, opacity, metrics, theme, klassName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8683
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8684
    var top = metrics.trackOffset + track * metrics.trackIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8685
    var width = right - left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8686
    var height = metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8687
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8688
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8689
    tapeDiv.className = 'timeline-small-event-tape'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8690
    if (klassName) {tapeDiv.className += ' small-' + klassName;}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8691
    tapeDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8692
    tapeDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8693
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8694
    tapeDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8695
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8696
    if (color) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8697
      tapeDiv.style.backgroundColor = color; // set color here if defined by event. Else use css
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8698
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8699
 //   tapeDiv.style.overflow = "hidden";   // now set in css
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8700
 //   tapeDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8701
    if(opacity<100) SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8702
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8703
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8704
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8705
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8706
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8707
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8708
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8709
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8710
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8711
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8712
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8713
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8714
Timeline.OverviewEventPainter.prototype._paintEventTick = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8715
    evt, left, color, opacity, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8716
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8717
    var height = theme.event.overviewTrack.tickHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8718
    var top = metrics.trackOffset - height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8719
    var width = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8720
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8721
    var tickDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8722
	  tickDiv.className = 'timeline-small-event-icon'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8723
    tickDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8724
    tickDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8725
  //  tickDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8726
  //  tickDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8727
  //  tickDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8728
  //  tickDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8729
  //  tickDiv.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8730
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8731
    var klassName = evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8732
    if (klassName) {tickDiv.className +=' small-' + klassName};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8733
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8734
    if(opacity<100) {SimileAjax.Graphics.setOpacity(tickDiv, opacity)};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8735
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8736
    this._eventLayer.appendChild(tickDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8737
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8738
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8739
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8740
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8741
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8742
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8743
        elmt:   tickDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8744
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8745
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8746
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8747
Timeline.OverviewEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8748
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8749
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8750
        var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8751
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8752
        var color = eventTheme.highlightColors[Math.min(highlightIndex, eventTheme.highlightColors.length - 1)];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8753
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8754
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8755
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8756
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8757
        div.style.left =    (dimensions.left - 1) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8758
        div.style.width =   (dimensions.width + 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8759
        div.style.top =     (dimensions.top - 1) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8760
        div.style.height =  (dimensions.height + 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8761
        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8762
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8763
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8764
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8765
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8766
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8767
Timeline.OverviewEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8768
    // not implemented
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8769
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8770
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8771
 *  Compact Event Painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8772
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8773
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8774
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8775
Timeline.CompactEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8776
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8777
    this._onSelectListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8778
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8779
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8780
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8781
    this._frc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8782
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8783
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8784
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8785
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8786
Timeline.CompactEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8787
    return 'compact';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8788
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8789
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8790
Timeline.CompactEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8791
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8792
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8793
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8794
    this._backLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8795
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8796
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8797
    this._highlightLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8798
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8799
    this._eventIdToElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8800
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8801
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8802
Timeline.CompactEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8803
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8804
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8805
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8806
Timeline.CompactEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8807
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8808
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8809
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8810
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8811
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8812
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8813
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8814
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8815
Timeline.CompactEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8816
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8817
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8818
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8819
Timeline.CompactEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8820
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8821
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8822
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8823
Timeline.CompactEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8824
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8825
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8826
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8827
Timeline.CompactEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8828
    this._highlightMatcher = highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8829
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8830
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8831
Timeline.CompactEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8832
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8833
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8834
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8835
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8836
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8837
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8838
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8839
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8840
    var metrics = this._computeMetrics();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8841
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8842
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8843
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8844
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8845
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8846
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8847
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8848
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8849
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8850
        function(evt) { return -1; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8851
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8852
    var iterator = eventSource.getEventIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8853
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8854
    var stackConcurrentPreciseInstantEvents = "stackConcurrentPreciseInstantEvents" in this._params && typeof this._params.stackConcurrentPreciseInstantEvents == "object";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8855
    var collapseConcurrentPreciseInstantEvents = "collapseConcurrentPreciseInstantEvents" in this._params && this._params.collapseConcurrentPreciseInstantEvents;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8856
    if (collapseConcurrentPreciseInstantEvents || stackConcurrentPreciseInstantEvents) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8857
        var bufferedEvents = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8858
        var previousInstantEvent = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8859
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8860
        while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8861
            var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8862
            if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8863
                if (!evt.isInstant() || evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8864
                    this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8865
                } else if (previousInstantEvent != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8866
                        previousInstantEvent.getStart().getTime() == evt.getStart().getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8867
                    bufferedEvents[bufferedEvents.length - 1].push(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8868
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8869
                    bufferedEvents.push([ evt ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8870
                    previousInstantEvent = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8871
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8872
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8873
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8874
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8875
        for (var i = 0; i < bufferedEvents.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8876
            var compositeEvents = bufferedEvents[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8877
            if (compositeEvents.length == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8878
                this.paintEvent(compositeEvents[0], metrics, this._params.theme, highlightMatcher(evt));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8879
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8880
                var match = -1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8881
                for (var j = 0; match < 0 && j < compositeEvents.length; j++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8882
                    match = highlightMatcher(compositeEvents[j]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8883
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8884
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8885
                if (stackConcurrentPreciseInstantEvents) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8886
                    this.paintStackedPreciseInstantEvents(compositeEvents, metrics, this._params.theme, match);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8887
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8888
                    this.paintCompositePreciseInstantEvents(compositeEvents, metrics, this._params.theme, match);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8889
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8890
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8891
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8892
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8893
        while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8894
            var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8895
            if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8896
                this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8897
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8898
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8899
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8900
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8901
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8902
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8903
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8904
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8905
    this._setOrthogonalOffset(metrics);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8906
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8907
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8908
Timeline.CompactEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8909
    this._setOrthogonalOffset(this._computeMetrics());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8910
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8911
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8912
Timeline.CompactEventPainter.prototype._setOrthogonalOffset = function(metrics) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8913
    var actualViewWidth = 2 * metrics.trackOffset + this._tracks.length * metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8914
    var minOrthogonalOffset = Math.min(0, this._band.getViewWidth() - actualViewWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8915
    var orthogonalOffset = Math.max(minOrthogonalOffset, this._band.getViewOrthogonalOffset());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8916
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8917
    this._highlightLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8918
        this._lineLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8919
            this._eventLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8920
                orthogonalOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8921
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8922
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8923
Timeline.CompactEventPainter.prototype._computeMetrics = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8924
    var theme = this._params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8925
    var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8926
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8927
    var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8928
        trackOffset:            "trackOffset" in this._params ? this._params.trackOffset : 10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8929
        trackHeight:            "trackHeight" in this._params ? this._params.trackHeight : 10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8930
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8931
        tapeHeight:             theme.event.tape.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8932
        tapeBottomMargin:       "tapeBottomMargin" in this._params ? this._params.tapeBottomMargin : 2,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8933
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8934
        labelBottomMargin:      "labelBottomMargin" in this._params ? this._params.labelBottomMargin : 5,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8935
        labelRightMargin:       "labelRightMargin" in this._params ? this._params.labelRightMargin : 5,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8936
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8937
        defaultIcon:            eventTheme.instant.icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8938
        defaultIconWidth:       eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8939
        defaultIconHeight:      eventTheme.instant.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8940
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8941
        customIconWidth:        "iconWidth" in this._params ? this._params.iconWidth : eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8942
        customIconHeight:       "iconHeight" in this._params ? this._params.iconHeight : eventTheme.instant.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8943
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8944
        iconLabelGap:           "iconLabelGap" in this._params ? this._params.iconLabelGap : 2,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8945
        iconBottomMargin:       "iconBottomMargin" in this._params ? this._params.iconBottomMargin : 2
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8946
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8947
    if ("compositeIcon" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8948
        metrics.compositeIcon = this._params.compositeIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8949
        metrics.compositeIconWidth = this._params.compositeIconWidth || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8950
        metrics.compositeIconHeight = this._params.compositeIconHeight || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8951
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8952
        metrics.compositeIcon = metrics.defaultIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8953
        metrics.compositeIconWidth = metrics.defaultIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8954
        metrics.compositeIconHeight = metrics.defaultIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8955
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8956
    metrics.defaultStackIcon = "icon" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8957
        this._params.stackConcurrentPreciseInstantEvents.icon : metrics.defaultIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8958
    metrics.defaultStackIconWidth = "iconWidth" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8959
        this._params.stackConcurrentPreciseInstantEvents.iconWidth : metrics.defaultIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8960
    metrics.defaultStackIconHeight = "iconHeight" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8961
        this._params.stackConcurrentPreciseInstantEvents.iconHeight : metrics.defaultIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8962
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8963
    return metrics;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8964
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8965
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8966
Timeline.CompactEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8967
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8968
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8969
    if (this._backLayer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8970
        this._backLayer = this._band.createLayerDiv(0, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8971
        this._backLayer.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8972
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8973
        var eventLabelPrototype = document.createElement("span");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8974
        eventLabelPrototype.className = "timeline-event-label";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8975
        this._backLayer.appendChild(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8976
        this._frc = SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8977
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8978
    this._frc.update();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8979
    this._tracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8980
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8981
    if (this._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8982
        band.removeLayerDiv(this._highlightLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8983
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8984
    this._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8985
    this._highlightLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8986
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8987
    if (this._lineLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8988
        band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8989
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8990
    this._lineLayer = band.createLayerDiv(110, "timeline-band-lines");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8991
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8992
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8993
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8994
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8995
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8996
    this._eventLayer = band.createLayerDiv(115, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8997
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8998
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8999
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9000
Timeline.CompactEventPainter.prototype.paintEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9001
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9002
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9003
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9004
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9005
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9006
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9007
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9008
Timeline.CompactEventPainter.prototype.paintInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9009
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9010
        this.paintImpreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9011
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9012
        this.paintPreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9013
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9014
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9015
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9016
Timeline.CompactEventPainter.prototype.paintDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9017
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9018
        this.paintImpreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9019
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9020
        this.paintPreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9021
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9022
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9023
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9024
Timeline.CompactEventPainter.prototype.paintPreciseInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9025
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9026
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9027
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9028
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9029
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9030
        url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9031
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9032
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9033
        iconData.url = metrics.defaultIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9034
        iconData.width = metrics.defaultIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9035
        iconData.height = metrics.defaultIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9036
        iconData.className = "timeline-event-icon-default";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9037
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9038
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9039
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9040
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9041
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9042
    var labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9043
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9044
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9045
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9046
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9047
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9048
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9049
        evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9050
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9051
        null, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9052
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9053
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9054
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9055
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9056
        highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9057
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9058
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9059
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9060
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9061
        return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9062
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9063
    SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9064
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9065
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9066
    this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9067
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9068
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9069
Timeline.CompactEventPainter.prototype.paintCompositePreciseInstantEvents = function(events, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9070
    var evt = events[0];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9071
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9072
    var tooltips = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9073
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9074
        tooltips.push(events[i].getProperty("tooltip") || events[i].getText());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9075
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9076
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9077
        tooltip: tooltips.join("; ")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9078
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9079
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9080
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9081
        url: metrics.compositeIcon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9082
        width: metrics.compositeIconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9083
        height: metrics.compositeIconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9084
        className: "timeline-event-icon-composite"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9085
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9086
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9087
    var labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9088
        text: String.substitute(this._params.compositeEventLabelTemplate, [ events.length ])
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9089
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9090
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9091
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9092
        evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9093
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9094
        null, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9095
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9096
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9097
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9098
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9099
        highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9100
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9101
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9102
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9103
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9104
        return self._onClickMultiplePreciseInstantEvent(result.iconElmtData.elmt, domEvt, events);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9105
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9106
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9107
    SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9108
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9109
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9110
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9111
        this._eventIdToElmt[events[i].getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9112
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9113
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9114
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9115
Timeline.CompactEventPainter.prototype.paintStackedPreciseInstantEvents = function(events, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9116
    var limit = "limit" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9117
        this._params.stackConcurrentPreciseInstantEvents.limit : 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9118
    var moreMessageTemplate = "moreMessageTemplate" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9119
        this._params.stackConcurrentPreciseInstantEvents.moreMessageTemplate : "%0 More Events";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9120
    var showMoreMessage = limit <= events.length - 2; // We want at least 2 more events above the limit.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9121
                                                      // Otherwise we'd need the singular case of "1 More Event"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9122
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9123
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9124
    var getPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9125
        return Math.round(band.dateToPixelOffset(date));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9126
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9127
    var getIconData = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9128
        var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9129
            url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9130
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9131
        if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9132
            iconData.url = metrics.defaultStackIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9133
            iconData.width = metrics.defaultStackIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9134
            iconData.height = metrics.defaultStackIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9135
            iconData.className = "timeline-event-icon-stack timeline-event-icon-default";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9136
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9137
            iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9138
            iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9139
            iconData.className = "timeline-event-icon-stack";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9140
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9141
        return iconData;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9142
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9143
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9144
    var firstIconData = getIconData(events[0]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9145
    var horizontalIncrement = 5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9146
    var leftIconEdge = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9147
    var totalLabelWidth = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9148
    var totalLabelHeight = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9149
    var totalIconHeight = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9150
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9151
    var records = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9152
    for (var i = 0; i < events.length && (!showMoreMessage || i < limit); i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9153
        var evt = events[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9154
        var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9155
        var iconData = getIconData(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9156
        var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9157
        var record = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9158
            text:       text,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9159
            iconData:   iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9160
            labelSize:  labelSize,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9161
            iconLeft:   firstIconData.width + i * horizontalIncrement - iconData.width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9162
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9163
        record.labelLeft = firstIconData.width + i * horizontalIncrement + metrics.iconLabelGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9164
        record.top = totalLabelHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9165
        records.push(record);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9166
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9167
        leftIconEdge = Math.min(leftIconEdge, record.iconLeft);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9168
        totalLabelHeight += labelSize.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9169
        totalLabelWidth = Math.max(totalLabelWidth, record.labelLeft + labelSize.width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9170
        totalIconHeight = Math.max(totalIconHeight, record.top + iconData.height);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9171
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9172
    if (showMoreMessage) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9173
        var moreMessage = String.substitute(moreMessageTemplate, [ events.length - limit ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9174
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9175
        var moreMessageLabelSize = this._frc.computeSize(moreMessage);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9176
        var moreMessageLabelLeft = firstIconData.width + (limit - 1) * horizontalIncrement + metrics.iconLabelGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9177
        var moreMessageLabelTop = totalLabelHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9178
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9179
        totalLabelHeight += moreMessageLabelSize.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9180
        totalLabelWidth = Math.max(totalLabelWidth, moreMessageLabelLeft + moreMessageLabelSize.width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9181
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9182
    totalLabelWidth += metrics.labelRightMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9183
    totalLabelHeight += metrics.labelBottomMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9184
    totalIconHeight += metrics.iconBottomMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9185
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9186
    var anchorPixel = getPixelOffset(events[0].getStart());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9187
    var newTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9188
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9189
    var trackCount = Math.ceil(Math.max(totalIconHeight, totalLabelHeight) / metrics.trackHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9190
    var rightIconEdge = firstIconData.width + (events.length - 1) * horizontalIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9191
    for (var i = 0; i < trackCount; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9192
        newTracks.push({ start: leftIconEdge, end: rightIconEdge });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9193
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9194
    var labelTrackCount = Math.ceil(totalLabelHeight / metrics.trackHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9195
    for (var i = 0; i < labelTrackCount; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9196
        var track = newTracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9197
        track.end = Math.max(track.end, totalLabelWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9198
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9199
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9200
    var firstTrack = this._fitTracks(anchorPixel, newTracks);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9201
    var verticalPixelOffset = firstTrack * metrics.trackHeight + metrics.trackOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9202
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9203
    var iconStackDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9204
    iconStackDiv.className = 'timeline-event-icon-stack';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9205
    iconStackDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9206
    iconStackDiv.style.overflow = "visible";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9207
    iconStackDiv.style.left = anchorPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9208
    iconStackDiv.style.top = verticalPixelOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9209
    iconStackDiv.style.width = rightIconEdge + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9210
    iconStackDiv.style.height = totalIconHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9211
    iconStackDiv.innerHTML = "<div style='position: relative'></div>";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9212
    this._eventLayer.appendChild(iconStackDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9213
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9214
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9215
    var onMouseOver = function(domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9216
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9217
            var n = parseInt(this.getAttribute("index"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9218
            var childNodes = iconStackDiv.firstChild.childNodes;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9219
            for (var i = 0; i < childNodes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9220
                var child = childNodes[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9221
                if (i == n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9222
                    child.style.zIndex = childNodes.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9223
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9224
                    child.style.zIndex = childNodes.length - i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9225
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9226
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9227
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9228
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9229
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9230
    var paintEvent = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9231
        var record = records[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9232
        var evt = events[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9233
        var tooltip = evt.getProperty("tooltip") || evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9234
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9235
        var labelElmtData = self._paintEventLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9236
            { tooltip: tooltip },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9237
            { text: record.text },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9238
            anchorPixel + record.labelLeft,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9239
            verticalPixelOffset + record.top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9240
            record.labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9241
            record.labelSize.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9242
            theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9243
        );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9244
        labelElmtData.elmt.setAttribute("index", index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9245
        labelElmtData.elmt.onmouseover = onMouseOver;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9246
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9247
        var img = SimileAjax.Graphics.createTranslucentImage(record.iconData.url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9248
        var iconDiv = self._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9249
        iconDiv.className = 'timeline-event-icon' + ("className" in record.iconData ? (" " + record.iconData.className) : "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9250
        iconDiv.style.left = record.iconLeft + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9251
        iconDiv.style.top = record.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9252
        iconDiv.style.zIndex = (records.length - index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9253
        iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9254
        iconDiv.setAttribute("index", index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9255
        iconDiv.onmouseover = onMouseOver;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9256
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9257
        iconStackDiv.firstChild.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9258
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9259
        var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9260
            return self._onClickInstantEvent(labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9261
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9262
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9263
        SimileAjax.DOM.registerEvent(iconDiv, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9264
        SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9265
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9266
        self._eventIdToElmt[evt.getID()] = iconDiv;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9267
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9268
    for (var i = 0; i < records.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9269
        paintEvent(i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9270
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9271
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9272
    if (showMoreMessage) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9273
        var moreEvents = events.slice(limit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9274
        var moreMessageLabelElmtData = this._paintEventLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9275
            { tooltip: moreMessage },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9276
            { text: moreMessage },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9277
            anchorPixel + moreMessageLabelLeft,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9278
            verticalPixelOffset + moreMessageLabelTop,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9279
            moreMessageLabelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9280
            moreMessageLabelSize.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9281
            theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9282
        );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9283
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9284
        var moreMessageClickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9285
            return self._onClickMultiplePreciseInstantEvent(moreMessageLabelElmtData.elmt, domEvt, moreEvents);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9286
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9287
        SimileAjax.DOM.registerEvent(moreMessageLabelElmtData.elmt, "mousedown", moreMessageClickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9288
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9289
        for (var i = 0; i < moreEvents.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9290
            this._eventIdToElmt[moreEvents[i].getID()] = moreMessageLabelElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9291
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9292
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9293
    //this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9294
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9295
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9296
Timeline.CompactEventPainter.prototype.paintImpreciseInstantEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9297
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9298
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9299
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9300
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9301
    var tapeData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9302
        start:          evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9303
        end:            evt.getEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9304
        latestStart:    evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9305
        earliestEnd:    evt.getEarliestEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9306
        isInstant:      true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9307
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9308
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9309
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9310
        url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9311
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9312
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9313
        iconData = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9314
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9315
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9316
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9317
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9318
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9319
    var labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9320
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9321
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9322
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9323
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9324
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9325
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9326
        evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9327
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9328
        tapeData, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9329
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9330
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9331
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9332
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9333
        highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9334
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9335
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9336
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9337
    var clickHandler = iconData != null ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9338
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9339
            return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9340
        } :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9341
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9342
            return self._onClickInstantEvent(result.labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9343
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9344
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9345
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9346
    SimileAjax.DOM.registerEvent(result.impreciseTapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9347
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9348
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9349
        SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9350
        this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9351
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9352
        this._eventIdToElmt[evt.getID()] = result.labelElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9353
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9354
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9355
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9356
Timeline.CompactEventPainter.prototype.paintPreciseDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9357
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9358
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9359
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9360
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9361
    var tapeData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9362
        start:          evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9363
        end:            evt.getEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9364
        isInstant:      false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9365
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9366
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9367
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9368
        url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9369
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9370
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9371
        iconData = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9372
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9373
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9374
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9375
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9376
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9377
    var labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9378
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9379
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9380
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9381
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9382
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9383
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9384
        evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9385
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9386
        tapeData, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9387
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9388
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9389
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9390
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9391
        highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9392
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9393
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9394
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9395
    var clickHandler = iconData != null ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9396
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9397
            return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9398
        } :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9399
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9400
            return self._onClickInstantEvent(result.labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9401
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9402
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9403
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9404
    SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9405
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9406
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9407
        SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9408
        this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9409
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9410
        this._eventIdToElmt[evt.getID()] = result.labelElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9411
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9412
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9413
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9414
Timeline.CompactEventPainter.prototype.paintImpreciseDurationEvent = function(evt, metrics, theme, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9415
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9416
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9417
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9418
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9419
    var tapeData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9420
        start:          evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9421
        end:            evt.getEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9422
        latestStart:    evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9423
        earliestEnd:    evt.getEarliestEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9424
        isInstant:      false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9425
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9426
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9427
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9428
        url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9429
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9430
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9431
        iconData = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9432
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9433
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9434
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9435
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9436
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9437
    var labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9438
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9439
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9440
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9441
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9442
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9443
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9444
        evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9445
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9446
        tapeData, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9447
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9448
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9449
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9450
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9451
        highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9452
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9453
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9454
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9455
    var clickHandler = iconData != null ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9456
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9457
            return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9458
        } :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9459
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9460
            return self._onClickInstantEvent(result.labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9461
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9462
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9463
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9464
    SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9465
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9466
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9467
        SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9468
        this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9469
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9470
        this._eventIdToElmt[evt.getID()] = result.labelElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9471
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9472
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9473
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9474
Timeline.CompactEventPainter.prototype.paintTapeIconLabel = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9475
    anchorDate,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9476
    commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9477
    tapeData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9478
    iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9479
    labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9480
    metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9481
    theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9482
    highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9483
) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9484
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9485
    var getPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9486
        return Math.round(band.dateToPixelOffset(date));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9487
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9488
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9489
    var anchorPixel = getPixelOffset(anchorDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9490
    var newTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9491
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9492
    var tapeHeightOccupied = 0;         // how many pixels (vertically) the tape occupies, including bottom margin
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9493
    var tapeTrackCount = 0;             // how many tracks the tape takes up, usually just 1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9494
    var tapeLastTrackExtraSpace = 0;    // on the last track that the tape occupies, how many pixels are left (for icon and label to occupy as well)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9495
    if (tapeData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9496
        tapeHeightOccupied = metrics.tapeHeight + metrics.tapeBottomMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9497
        tapeTrackCount = Math.ceil(metrics.tapeHeight / metrics.trackHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9498
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9499
        var tapeEndPixelOffset = getPixelOffset(tapeData.end) - anchorPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9500
        var tapeStartPixelOffset = getPixelOffset(tapeData.start) - anchorPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9501
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9502
        for (var t = 0; t < tapeTrackCount; t++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9503
            newTracks.push({ start: tapeStartPixelOffset, end: tapeEndPixelOffset });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9504
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9505
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9506
        tapeLastTrackExtraSpace = metrics.trackHeight - (tapeHeightOccupied % metrics.tapeHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9507
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9508
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9509
    var iconStartPixelOffset = 0;        // where the icon starts compared to the anchor pixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9510
                                         // this can be negative if the icon is center-aligned around the anchor
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9511
    var iconHorizontalSpaceOccupied = 0; // how many pixels the icon take up from the anchor pixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9512
                                         // including the gap between the icon and the label
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9513
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9514
        if ("iconAlign" in iconData && iconData.iconAlign == "center") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9515
            iconStartPixelOffset = -Math.floor(iconData.width / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9516
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9517
        iconHorizontalSpaceOccupied = iconStartPixelOffset + iconData.width + metrics.iconLabelGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9518
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9519
        if (tapeTrackCount > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9520
            newTracks[tapeTrackCount - 1].end = Math.max(newTracks[tapeTrackCount - 1].end, iconHorizontalSpaceOccupied);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9521
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9522
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9523
        var iconHeight = iconData.height + metrics.iconBottomMargin + tapeLastTrackExtraSpace;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9524
        while (iconHeight > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9525
            newTracks.push({ start: iconStartPixelOffset, end: iconHorizontalSpaceOccupied });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9526
            iconHeight -= metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9527
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9528
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9529
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9530
    var text = labelData.text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9531
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9532
    var labelHeight = labelSize.height + metrics.labelBottomMargin + tapeLastTrackExtraSpace;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9533
    var labelEndPixelOffset = iconHorizontalSpaceOccupied + labelSize.width + metrics.labelRightMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9534
    if (tapeTrackCount > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9535
        newTracks[tapeTrackCount - 1].end = Math.max(newTracks[tapeTrackCount - 1].end, labelEndPixelOffset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9536
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9537
    for (var i = 0; labelHeight > 0; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9538
        if (tapeTrackCount + i < newTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9539
            var track = newTracks[tapeTrackCount + i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9540
            track.end = labelEndPixelOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9541
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9542
            newTracks.push({ start: 0, end: labelEndPixelOffset });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9543
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9544
        labelHeight -= metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9545
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9546
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9547
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9548
     *  Try to fit the new track on top of the existing tracks, then
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9549
     *  render the various elements.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9550
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9551
    var firstTrack = this._fitTracks(anchorPixel, newTracks);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9552
    var verticalPixelOffset = firstTrack * metrics.trackHeight + metrics.trackOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9553
    var result = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9554
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9555
    result.labelElmtData = this._paintEventLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9556
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9557
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9558
        anchorPixel + iconHorizontalSpaceOccupied,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9559
        verticalPixelOffset + tapeHeightOccupied,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9560
        labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9561
        labelSize.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9562
        theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9563
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9564
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9565
    if (tapeData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9566
        if ("latestStart" in tapeData || "earliestEnd" in tapeData) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9567
            result.impreciseTapeElmtData = this._paintEventTape(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9568
                commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9569
                tapeData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9570
                metrics.tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9571
                verticalPixelOffset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9572
                getPixelOffset(tapeData.start),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9573
                getPixelOffset(tapeData.end),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9574
                theme.event.duration.impreciseColor,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9575
                theme.event.duration.impreciseOpacity,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9576
                metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9577
                theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9578
            );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9579
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9580
        if (!tapeData.isInstant && "start" in tapeData && "end" in tapeData) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9581
            result.tapeElmtData = this._paintEventTape(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9582
                commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9583
                tapeData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9584
                metrics.tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9585
                verticalPixelOffset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9586
                anchorPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9587
                getPixelOffset("earliestEnd" in tapeData ? tapeData.earliestEnd : tapeData.end),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9588
                tapeData.color,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9589
                100,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9590
                metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9591
                theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9592
            );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9593
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9594
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9595
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9596
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9597
        result.iconElmtData = this._paintEventIcon(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9598
            commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9599
            iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9600
            verticalPixelOffset + tapeHeightOccupied,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9601
            anchorPixel + iconStartPixelOffset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9602
            metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9603
            theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9604
        );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9605
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9606
    //this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9607
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9608
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9609
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9610
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9611
Timeline.CompactEventPainter.prototype._fitTracks = function(anchorPixel, newTracks) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9612
    var firstTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9613
    for (firstTrack = 0; firstTrack < this._tracks.length; firstTrack++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9614
        var fit = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9615
        for (var j = 0; j < newTracks.length && (firstTrack + j) < this._tracks.length; j++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9616
            var existingTrack = this._tracks[firstTrack + j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9617
            var newTrack = newTracks[j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9618
            if (anchorPixel + newTrack.start < existingTrack) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9619
                fit = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9620
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9621
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9622
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9623
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9624
        if (fit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9625
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9626
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9627
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9628
    for (var i = 0; i < newTracks.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9629
        this._tracks[firstTrack + i] = anchorPixel + newTracks[i].end;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9630
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9631
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9632
    return firstTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9633
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9634
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9635
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9636
Timeline.CompactEventPainter.prototype._paintEventIcon = function(commonData, iconData, top, left, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9637
    var img = SimileAjax.Graphics.createTranslucentImage(iconData.url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9638
    var iconDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9639
    iconDiv.className = 'timeline-event-icon' + ("className" in iconData ? (" " + iconData.className) : "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9640
    iconDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9641
    iconDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9642
    iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9643
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9644
    if ("tooltip" in commonData && typeof commonData.tooltip == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9645
        iconDiv.title = commonData.tooltip;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9646
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9647
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9648
    this._eventLayer.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9649
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9650
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9651
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9652
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9653
        width:  metrics.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9654
        height: metrics.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9655
        elmt:   iconDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9656
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9657
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9658
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9659
Timeline.CompactEventPainter.prototype._paintEventLabel = function(commonData, labelData, left, top, width, height, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9660
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9661
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9662
    var labelDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9663
    labelDiv.className = 'timeline-event-label';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9664
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9665
    labelDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9666
    labelDiv.style.width = (width + 1) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9667
    labelDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9668
    labelDiv.innerHTML = labelData.text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9669
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9670
    if ("tooltip" in commonData && typeof commonData.tooltip == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9671
        labelDiv.title = commonData.tooltip;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9672
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9673
    if ("color" in labelData && typeof labelData.color == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9674
        labelDiv.style.color = labelData.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9675
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9676
    if ("className" in labelData && typeof labelData.className == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9677
        labelDiv.className += ' ' + labelData.className;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9678
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9679
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9680
    this._eventLayer.appendChild(labelDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9681
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9682
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9683
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9684
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9685
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9686
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9687
        elmt:   labelDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9688
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9689
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9690
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9691
Timeline.CompactEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9692
    commonData, tapeData, height, top, startPixel, endPixel, color, opacity, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9693
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9694
    var width = endPixel - startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9695
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9696
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9697
    tapeDiv.className = "timeline-event-tape"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9698
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9699
    tapeDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9700
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9701
    tapeDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9702
    tapeDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9703
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9704
    if ("tooltip" in commonData && typeof commonData.tooltip == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9705
        tapeDiv.title = commonData.tooltip;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9706
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9707
    if (color != null && typeof tapeData.color == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9708
        tapeDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9709
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9710
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9711
    if ("backgroundImage" in tapeData && typeof tapeData.backgroundImage == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9712
        tapeDiv.style.backgroundImage = "url(" + backgroundImage + ")";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9713
        tapeDiv.style.backgroundRepeat =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9714
            ("backgroundRepeat" in tapeData && typeof tapeData.backgroundRepeat == "string")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9715
                ? tapeData.backgroundRepeat : 'repeat';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9716
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9717
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9718
    SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9719
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9720
    if ("className" in tapeData && typeof tapeData.className == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9721
        tapeDiv.className += ' ' + tapeData.className;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9722
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9723
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9724
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9725
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9726
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9727
        left:   startPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9728
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9729
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9730
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9731
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9732
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9733
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9734
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9735
Timeline.CompactEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9736
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9737
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9738
        var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9739
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9740
        var color = eventTheme.highlightColors[Math.min(highlightIndex, eventTheme.highlightColors.length - 1)];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9741
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9742
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9743
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9744
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9745
        div.style.left =    (dimensions.left - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9746
        div.style.width =   (dimensions.width + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9747
        div.style.top =     (dimensions.top - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9748
        div.style.height =  (dimensions.height + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9749
//        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9750
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9751
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9752
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9753
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9754
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9755
Timeline.CompactEventPainter.prototype._onClickMultiplePreciseInstantEvent = function(icon, domEvt, events) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9756
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9757
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9758
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9759
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9760
        events
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9761
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9762
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9763
    var ids = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9764
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9765
        ids.push(events[i].getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9766
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9767
    this._fireOnSelect(ids);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9768
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9769
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9770
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9771
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9772
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9773
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9774
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9775
Timeline.CompactEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9776
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9777
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9778
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9779
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9780
        [evt]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9781
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9782
    this._fireOnSelect([evt.getID()]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9783
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9784
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9785
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9786
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9787
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9788
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9789
Timeline.CompactEventPainter.prototype._onClickDurationEvent = function(target, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9790
    if ("pageX" in domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9791
        var x = domEvt.pageX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9792
        var y = domEvt.pageY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9793
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9794
        var c = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9795
        var x = domEvt.offsetX + c.left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9796
        var y = domEvt.offsetY + c.top;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9797
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9798
    this._showBubble(x, y, [evt]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9799
    this._fireOnSelect([evt.getID()]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9800
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9801
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9802
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9803
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9804
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9805
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9806
Timeline.CompactEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9807
    var elmt = this._eventIdToElmt[evt.getID()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9808
    if (elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9809
        var c = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9810
        this._showBubble(c.left + elmt.offsetWidth / 2, c.top + elmt.offsetHeight / 2, [evt]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9811
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9812
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9813
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9814
Timeline.CompactEventPainter.prototype._showBubble = function(x, y, evts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9815
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9816
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9817
    evts = ("fillInfoBubble" in evts) ? [evts] : evts;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9818
    for (var i = 0; i < evts.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9819
        var div2 = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9820
        div.appendChild(div2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9821
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9822
        evts[i].fillInfoBubble(div2, this._params.theme, this._band.getLabeller());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9823
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9824
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9825
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9826
    SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y, this._params.theme.event.bubble.width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9827
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9828
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9829
Timeline.CompactEventPainter.prototype._fireOnSelect = function(eventIDs) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9830
    for (var i = 0; i < this._onSelectListeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9831
        this._onSelectListeners[i](eventIDs);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9832
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9833
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9834
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9835
 *  Span Highlight Decorator
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9836
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9837
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9838
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9839
Timeline.SpanHighlightDecorator = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9840
    // When evaluating params, test against null. Not "p in params". Testing against
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9841
    // null enables caller to explicitly request the default. Testing against "in" means
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9842
    // that the param has to be ommitted to get the default.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9843
    this._unit = params.unit != null ? params.unit : SimileAjax.NativeDateUnit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9844
    this._startDate = (typeof params.startDate == "string") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9845
        this._unit.parseFromObject(params.startDate) : params.startDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9846
    this._endDate = (typeof params.endDate == "string") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9847
        this._unit.parseFromObject(params.endDate) : params.endDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9848
    this._startLabel = params.startLabel != null ? params.startLabel : ""; // not null!
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9849
    this._endLabel   = params.endLabel   != null ? params.endLabel   : ""; // not null!
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9850
    this._color = params.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9851
    this._cssClass = params.cssClass != null ? params.cssClass : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9852
    this._opacity = params.opacity != null ? params.opacity : 100;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9853
         // Default z is 10, behind everything but background grid.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9854
         // If inFront, then place just behind events, in front of everything else
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9855
    this._zIndex = (params.inFront != null && params.inFront) ? 113 : 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9856
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9857
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9858
Timeline.SpanHighlightDecorator.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9859
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9860
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9861
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9862
    this._layerDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9863
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9864
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9865
Timeline.SpanHighlightDecorator.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9866
    if (this._layerDiv != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9867
        this._band.removeLayerDiv(this._layerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9868
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9869
    this._layerDiv = this._band.createLayerDiv(this._zIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9870
    this._layerDiv.setAttribute("name", "span-highlight-decorator"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9871
    this._layerDiv.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9872
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9873
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9874
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9875
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9876
    if (this._unit.compare(this._startDate, maxDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9877
        this._unit.compare(this._endDate, minDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9878
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9879
        minDate = this._unit.later(minDate, this._startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9880
        maxDate = this._unit.earlier(maxDate, this._endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9881
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9882
        var minPixel = this._band.dateToPixelOffset(minDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9883
        var maxPixel = this._band.dateToPixelOffset(maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9884
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9885
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9886
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9887
        var createTable = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9888
            var table = doc.createElement("table");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9889
            table.insertRow(0).insertCell(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9890
            return table;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9891
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9892
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9893
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9894
        div.className='timeline-highlight-decorator'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9895
        if(this._cssClass) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9896
        	  div.className += ' ' + this._cssClass;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9897
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9898
        if(this._color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9899
        	  div.style.backgroundColor = this._color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9900
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9901
        if (this._opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9902
            SimileAjax.Graphics.setOpacity(div, this._opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9903
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9904
        this._layerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9905
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9906
        var tableStartLabel = createTable();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9907
        tableStartLabel.className = 'timeline-highlight-label timeline-highlight-label-start'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9908
        var tdStart =  tableStartLabel.rows[0].cells[0]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9909
        tdStart.innerHTML = this._startLabel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9910
        if (this._cssClass) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9911
        	  tdStart.className = 'label_' + this._cssClass;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9912
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9913
        this._layerDiv.appendChild(tableStartLabel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9914
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9915
        var tableEndLabel = createTable();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9916
        tableEndLabel.className = 'timeline-highlight-label timeline-highlight-label-end'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9917
        var tdEnd = tableEndLabel.rows[0].cells[0]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9918
        tdEnd.innerHTML = this._endLabel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9919
        if (this._cssClass) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9920
        	   tdEnd.className = 'label_' + this._cssClass;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9921
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9922
        this._layerDiv.appendChild(tableEndLabel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9923
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9924
        if (this._timeline.isHorizontal()){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9925
            div.style.left = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9926
            div.style.width = (maxPixel - minPixel) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9927
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9928
            tableStartLabel.style.right = (this._band.getTotalViewLength() - minPixel) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9929
            tableStartLabel.style.width = (this._startLabel.length) + "em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9930
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9931
            tableEndLabel.style.left = maxPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9932
            tableEndLabel.style.width = (this._endLabel.length) + "em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9933
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9934
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9935
            div.style.top = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9936
            div.style.height = (maxPixel - minPixel) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9937
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9938
            tableStartLabel.style.bottom = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9939
            tableStartLabel.style.height = "1.5px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9940
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9941
            tableEndLabel.style.top = maxPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9942
            tableEndLabel.style.height = "1.5px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9943
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9944
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9945
    this._layerDiv.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9946
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9947
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9948
Timeline.SpanHighlightDecorator.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9949
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9950
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9951
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9952
 *  Point Highlight Decorator
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9953
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9954
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9955
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9956
Timeline.PointHighlightDecorator = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9957
    this._unit = params.unit != null ? params.unit : SimileAjax.NativeDateUnit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9958
    this._date = (typeof params.date == "string") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9959
        this._unit.parseFromObject(params.date) : params.date;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9960
    this._width = params.width != null ? params.width : 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9961
      // Since the width is used to calculate placements (see minPixel, below), we
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9962
      // specify width here, not in css.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9963
    this._color = params.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9964
    this._cssClass = params.cssClass != null ? params.cssClass : '';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9965
    this._opacity = params.opacity != null ? params.opacity : 100;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9966
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9967
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9968
Timeline.PointHighlightDecorator.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9969
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9970
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9971
    this._layerDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9972
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9973
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9974
Timeline.PointHighlightDecorator.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9975
    if (this._layerDiv != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9976
        this._band.removeLayerDiv(this._layerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9977
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9978
    this._layerDiv = this._band.createLayerDiv(10);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9979
    this._layerDiv.setAttribute("name", "span-highlight-decorator"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9980
    this._layerDiv.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9981
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9982
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9983
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9984
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9985
    if (this._unit.compare(this._date, maxDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9986
        this._unit.compare(this._date, minDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9988
        var pixel = this._band.dateToPixelOffset(this._date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9989
        var minPixel = pixel - Math.round(this._width / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9990
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9991
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9992
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9993
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9994
        div.className='timeline-highlight-point-decorator';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9995
        div.className += ' ' + this._cssClass;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9996
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9997
        if(this._color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9998
        	  div.style.backgroundColor = this._color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9999
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10000
        if (this._opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10001
            SimileAjax.Graphics.setOpacity(div, this._opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10002
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10003
        this._layerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10004
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10005
        if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10006
            div.style.left = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10007
            div.style.width = this._width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10008
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10009
            div.style.top = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10010
            div.style.height = this._width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10011
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10012
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10013
    this._layerDiv.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10014
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10015
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10016
Timeline.PointHighlightDecorator.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10017
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10018
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10019
 *  Default Unit
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10020
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10021
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10022
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10023
Timeline.NativeDateUnit = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10024
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10025
Timeline.NativeDateUnit.createLabeller = function(locale, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10026
    return new Timeline.GregorianDateLabeller(locale, timeZone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10027
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10028
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10029
Timeline.NativeDateUnit.makeDefaultValue = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10030
    return new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10031
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10032
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10033
Timeline.NativeDateUnit.cloneValue = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10034
    return new Date(v.getTime());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10035
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10036
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10037
Timeline.NativeDateUnit.getParser = function(format) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10038
    if (typeof format == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10039
        format = format.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10040
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10041
    return (format == "iso8601" || format == "iso 8601") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10042
        Timeline.DateTime.parseIso8601DateTime : 
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10043
        Timeline.DateTime.parseGregorianDateTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10044
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10045
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10046
Timeline.NativeDateUnit.parseFromObject = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10047
    return Timeline.DateTime.parseGregorianDateTime(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10048
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10049
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10050
Timeline.NativeDateUnit.toNumber = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10051
    return v.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10052
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10053
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10054
Timeline.NativeDateUnit.fromNumber = function(n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10055
    return new Date(n);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10056
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10057
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10058
Timeline.NativeDateUnit.compare = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10059
    var n1, n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10060
    if (typeof v1 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10061
        n1 = v1.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10062
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10063
        n1 = Number(v1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10064
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10065
    if (typeof v2 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10066
        n2 = v2.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10067
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10068
        n2 = Number(v2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10069
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10070
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10071
    return n1 - n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10072
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10073
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10074
Timeline.NativeDateUnit.earlier = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10075
    return Timeline.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10076
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10078
Timeline.NativeDateUnit.later = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10079
    return Timeline.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10080
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10081
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10082
Timeline.NativeDateUnit.change = function(v, n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10083
    return new Date(v.getTime() + n);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10084
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10085
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10086
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10087
 *  Common localization strings
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10088
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10089
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10090
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10091
Timeline.strings["fr"] = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10092
    wikiLinkLabel:  "Discute"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10093
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10094
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10095
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10096
 *  Localization of labellers.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10097
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10098
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10099
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10100
Timeline.GregorianDateLabeller.monthNames["fr"] = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10101
    "jan", "fev", "mar", "avr", "mai", "jui", "jui", "aou", "sep", "oct", "nov", "dec"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10102
];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10103
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10104
 *  Common localization strings
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10105
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10106
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10107
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10108
Timeline.strings["en"] = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10109
    wikiLinkLabel:  "Discuss"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10110
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10111
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10112
/*==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10113
 *  Localization of labellers.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10114
 *==================================================
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10115
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10116
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10117
Timeline.GregorianDateLabeller.monthNames["en"] = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10118
    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10119
];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10121
Timeline.GregorianDateLabeller.dayNames["en"] = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10122
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10123
];