web/data/cubicweb.timeline-bundle.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 22 Jan 2014 15:49:32 +0100
changeset 9463 d62e13eba033
parent 7529 2fdc310be7cd
child 9819 95902c0b991b
permissions -rw-r--r--
[multi-sources-removal] Simplify ConnectionsSet internal structures and public methods since it now handles a connection to the system source only Related to #2919300 [jcr: adjust 3.17.11 migration, fix a number of bugs in new ConnectionsSet implementation, fix source.{open,close}_source_connections]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5774
diff changeset
     1
/**
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5774
diff changeset
     2
 *  This file contains timeline utilities
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5774
diff changeset
     3
 *  :organization: Logilab
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5774
diff changeset
     4
 */
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5774
diff changeset
     5
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     6
var SimileAjax_urlPrefix = baseuri() + 'data/';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     7
var Timeline_urlPrefix = baseuri() + 'data/';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
     8
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
     9
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    10
 *  Simile Ajax API
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    11
 *
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5774
diff changeset
    12
 *  Include this file in your HTML file as follows::
1156
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
 *    <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
    15
 *
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
    16
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    17
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    18
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    19
if (typeof SimileAjax == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    20
    var SimileAjax = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    21
        loaded:                 false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    22
        loadingScriptsCount:    0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    23
        error:                  null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    24
        params:                 { bundle:"true" }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    25
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    26
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    27
    SimileAjax.Platform = new Object();
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
            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
    30
            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
    31
            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
    32
            before it loads ajax.js and platform.js.
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    35
    var getHead = function(doc) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    36
        return doc.getElementsByTagName("head")[0];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    37
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    38
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    39
    SimileAjax.findScript = function(doc, substring) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    40
        var heads = doc.documentElement.getElementsByTagName("head");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    41
        for (var h = 0; h < heads.length; h++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    42
            var node = heads[h].firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    43
            while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    44
                if (node.nodeType == 1 && node.tagName.toLowerCase() == "script") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    45
                    var url = node.src;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    46
                    var i = url.indexOf(substring);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    47
                    if (i >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    48
                        return url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    49
                    }
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
                node = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    52
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    53
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    54
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    55
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    56
    SimileAjax.includeJavascriptFile = function(doc, url, onerror, charset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    57
        onerror = onerror || "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    58
        if (doc.body == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    59
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    60
                var q = "'" + onerror.replace( /'/g, '&apos' ) + "'"; // "
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    61
                doc.write("<script src='" + url + "' onerror="+ q +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    62
                          (charset ? " charset='"+ charset +"'" : "") +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    63
                          " type='text/javascript'>"+ onerror + "</script>");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    64
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    65
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    66
                // fall through
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    67
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    68
        }
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
        var script = doc.createElement("script");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    71
        if (onerror) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    72
            try { script.innerHTML = onerror; } catch(e) {}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    73
            script.setAttribute("onerror", onerror);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    74
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    75
        if (charset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    76
            script.setAttribute("charset", charset);
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
        script.type = "text/javascript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    79
        script.language = "JavaScript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    80
        script.src = url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    81
        return getHead(doc).appendChild(script);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    82
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    83
    SimileAjax.includeJavascriptFiles = function(doc, urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    84
        for (var i = 0; i < filenames.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    85
            SimileAjax.includeJavascriptFile(doc, urlPrefix + filenames[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    86
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    87
        SimileAjax.loadingScriptsCount += filenames.length;
2097
400bdbcc5699 [javascript] timeline is already bundled, don't try to include dynamically other js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1156
diff changeset
    88
        // XXX adim SimileAjax.includeJavascriptFile(doc, SimileAjax.urlPrefix + "scripts/signal.js?" + filenames.length);
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    89
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    90
    SimileAjax.includeCssFile = function(doc, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    91
        if (doc.body == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    92
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    93
                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
    94
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    95
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    96
                // fall through
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    97
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    98
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
    99
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   100
        var link = doc.createElement("link");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   101
        link.setAttribute("rel", "stylesheet");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   102
        link.setAttribute("type", "text/css");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   103
        link.setAttribute("href", url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   104
        getHead(doc).appendChild(link);
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
    SimileAjax.includeCssFiles = function(doc, urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   107
        for (var i = 0; i < filenames.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   108
            SimileAjax.includeCssFile(doc, urlPrefix + filenames[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   109
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   110
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   111
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
     * 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
   114
     * @param {Array} urls
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   115
     * @param {String} urlPrefix
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   116
     * @param {Array} suffixes
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
    SimileAjax.prefixURLs = function(urls, urlPrefix, suffixes) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   119
        for (var i = 0; i < suffixes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   120
            urls.push(urlPrefix + suffixes[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   121
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   122
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   123
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   124
    /**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   125
     * Parse out the query parameters from a URL
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   126
     * @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
   127
     * @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
   128
     * @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
   129
     *        (String, Number, Boolean or Array, String by default)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   130
     * @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
   131
     * @type Object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   132
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   133
    SimileAjax.parseURLParameters = function(url, to, types) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   134
        to = to || {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   135
        types = types || {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   136
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   137
        if (typeof url == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   138
            url = location.href;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   139
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   140
        var q = url.indexOf("?");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   141
        if (q < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   142
            return to;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   143
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   144
        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
   145
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   146
        var params = url.split("&"), param, parsed = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   147
        var decode = window.decodeURIComponent || unescape;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   148
        for (var i = 0; param = params[i]; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   149
            var eq = param.indexOf("=");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   150
            var name = decode(param.slice(0,eq));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   151
            var old = parsed[name];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   152
            if (typeof old == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   153
                old = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   154
            } else if (!(old instanceof Array)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   155
                old = [old];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   156
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   157
            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
   158
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   159
        for (var i in parsed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   160
            if (!parsed.hasOwnProperty(i)) continue;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   161
            var type = types[i] || String;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   162
            var data = parsed[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   163
            if (!(data instanceof Array)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   164
                data = [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
            if (type === Boolean && data[0] == "false") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   167
                to[i] = false; // because Boolean("false") === true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   168
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   169
                to[i] = type.apply(this, data);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   170
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   171
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   172
        return to;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   173
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   174
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   175
    (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   176
        var javascriptFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   177
            "jquery-1.2.6.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   178
            "platform.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   179
            "debug.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   180
            "xmlhttp.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   181
            "json.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   182
            "dom.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   183
            "graphics.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   184
            "date-time.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   185
            "string.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   186
            "html.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   187
            "data-structure.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   188
            "units.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   189
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   190
            "ajax.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   191
            "history.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   192
            "window-manager.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   193
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   194
        var cssFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   195
            "graphics.css"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   196
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   197
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   198
        if (typeof SimileAjax_urlPrefix == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   199
            SimileAjax.urlPrefix = SimileAjax_urlPrefix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   200
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   201
            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
   202
            if (url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   203
                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
   204
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   205
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   206
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   207
            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
   208
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   209
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   210
        SimileAjax.parseURLParameters(url, SimileAjax.params, {bundle:Boolean});
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   211
//         if (SimileAjax.params.bundle) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   212
//             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
   213
//         } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   214
//             SimileAjax.includeJavascriptFiles(document, SimileAjax.urlPrefix + "scripts/", javascriptFiles);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   215
//         }
2097
400bdbcc5699 [javascript] timeline is already bundled, don't try to include dynamically other js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1156
diff changeset
   216
//         SimileAjax.includeCssFiles(document, SimileAjax.urlPrefix + "styles/", cssFiles);
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   217
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   218
        SimileAjax.loaded = true;
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
}
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   221
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   222
 *  Platform Utility Functions and Constants
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   223
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   224
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   225
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   226
/*  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
   227
    but before control returns to user-code.
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
SimileAjax.jQuery = jQuery;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   230
// SimileAjax.jQuery = jQuery.noConflict(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   231
if (typeof window["$"] == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   232
    window.$ = SimileAjax.jQuery;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   233
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   234
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   235
SimileAjax.Platform.os = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   236
    isMac:   false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   237
    isWin:   false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   238
    isWin32: false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   239
    isUnix:  false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   240
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   241
SimileAjax.Platform.browser = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   242
    isIE:           false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   243
    isNetscape:     false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   244
    isMozilla:      false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   245
    isFirefox:      false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   246
    isOpera:        false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   247
    isSafari:       false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   248
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   249
    majorVersion:   0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   250
    minorVersion:   0
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
(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   254
    var an = navigator.appName.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   255
	var ua = navigator.userAgent.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   256
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   257
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   258
     *  Operating system
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   259
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   260
	SimileAjax.Platform.os.isMac = (ua.indexOf('mac') != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   261
	SimileAjax.Platform.os.isWin = (ua.indexOf('win') != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   262
	SimileAjax.Platform.os.isWin32 = SimileAjax.Platform.isWin && (
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   263
        ua.indexOf('95') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   264
        ua.indexOf('98') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   265
        ua.indexOf('nt') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   266
        ua.indexOf('win32') != -1 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   267
        ua.indexOf('32bit') != -1
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.os.isUnix = (ua.indexOf('x11') != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   270
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   271
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   272
     *  Browser
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   273
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   274
    SimileAjax.Platform.browser.isIE = (an.indexOf("microsoft") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   275
    SimileAjax.Platform.browser.isNetscape = (an.indexOf("netscape") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   276
    SimileAjax.Platform.browser.isMozilla = (ua.indexOf("mozilla") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   277
    SimileAjax.Platform.browser.isFirefox = (ua.indexOf("firefox") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   278
    SimileAjax.Platform.browser.isOpera = (an.indexOf("opera") != -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   279
    SimileAjax.Platform.browser.isSafari = (an.indexOf("safari") != -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 parseVersionString = function(s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   282
        var a = s.split(".");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   283
        SimileAjax.Platform.browser.majorVersion = parseInt(a[0]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   284
        SimileAjax.Platform.browser.minorVersion = parseInt(a[1]);
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
    var indexOf = function(s, sub, start) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   287
        var i = s.indexOf(sub, start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   288
        return i >= 0 ? i : s.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   289
    };
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
    if (SimileAjax.Platform.browser.isMozilla) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   292
        var offset = ua.indexOf("mozilla/");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   293
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   294
            parseVersionString(ua.substring(offset + 8, indexOf(ua, " ", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   295
        }
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
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   298
        var offset = ua.indexOf("msie ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   299
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   300
            parseVersionString(ua.substring(offset + 5, indexOf(ua, ";", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   301
        }
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
    if (SimileAjax.Platform.browser.isNetscape) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   304
        var offset = ua.indexOf("rv:");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   305
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   306
            parseVersionString(ua.substring(offset + 3, indexOf(ua, ")", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   307
        }
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
    if (SimileAjax.Platform.browser.isFirefox) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   310
        var offset = ua.indexOf("firefox/");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   311
        if (offset >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   312
            parseVersionString(ua.substring(offset + 8, indexOf(ua, " ", offset)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   313
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   314
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   315
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   316
    if (!("localeCompare" in String.prototype)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   317
        String.prototype.localeCompare = function (s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   318
            if (this < s) return -1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   319
            else if (this > s) return 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   320
            else return 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   321
        };
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
})();
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
SimileAjax.Platform.getDefaultLocale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   326
    return SimileAjax.Platform.clientLocale;
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   327
};
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   328
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   329
 *  Debug Utility Functions
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   330
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   331
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   332
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   333
SimileAjax.Debug = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   334
    silent: false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   335
};
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
SimileAjax.Debug.log = function(msg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   338
    var f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   339
    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
   340
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   341
            console.log(msg2);
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   344
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   345
            if (!SimileAjax.Debug.silent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   346
                alert(msg2);
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
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   349
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   350
    SimileAjax.Debug.log = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   351
    f(msg);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   352
};
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
SimileAjax.Debug.warn = function(msg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   355
    var f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   356
    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
   357
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   358
            console.warn(msg2);
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   361
        f = function(msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   362
            if (!SimileAjax.Debug.silent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   363
                alert(msg2);
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
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   366
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   367
    SimileAjax.Debug.warn = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   368
    f(msg);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   369
};
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
SimileAjax.Debug.exception = function(e, msg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   372
    var f, params = SimileAjax.parseURLParameters();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   373
    if (params.errors == "throw" || SimileAjax.params.errors == "throw") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   374
        f = function(e2, msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   375
            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
   376
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   377
    } 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
   378
        f = function(e2, msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   379
            if (msg2 != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   380
                console.error(msg2 + " %o", e2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   381
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   382
                console.error(e2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   383
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   384
            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
   385
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   386
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   387
        f = function(e2, msg2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   388
            if (!SimileAjax.Debug.silent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   389
                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
   390
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   391
            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
   392
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   393
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   394
    SimileAjax.Debug.exception = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   395
    f(e, msg);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   396
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   397
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   398
SimileAjax.Debug.objectToString = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   399
    return SimileAjax.Debug._objectToString(o, "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   400
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   401
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   402
SimileAjax.Debug._objectToString = function(o, indent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   403
    var indent2 = indent + " ";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   404
    if (typeof o == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   405
        var s = "{";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   406
        for (n in o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   407
            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
   408
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   409
        s += indent + "}";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   410
        return s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   411
    } else if (typeof o == "array") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   412
        var s = "[";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   413
        for (var n = 0; n < o.length; n++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   414
            s += SimileAjax.Debug._objectToString(o[n], indent2) + "\n";
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
        s += indent + "]";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   417
        return s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   418
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   419
        return o;
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
};
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
 * @fileOverview XmlHttp utility functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   424
 * @name SimileAjax.XmlHttp
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   427
SimileAjax.XmlHttp = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   428
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   429
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   430
 *  Callback for XMLHttp onRequestStateChange.
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
SimileAjax.XmlHttp._onReadyStateChange = function(xmlhttp, fError, fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   433
    switch (xmlhttp.readyState) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   434
    // 1: Request not yet made
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   435
    // 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
   436
    // 3: Called multiple while downloading in progress
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
    // Download complete
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   439
    case 4:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   440
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   441
            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
   442
             || xmlhttp.status == 200   // http:// urls
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   443
            ) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   444
                if (fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   445
                    fDone(xmlhttp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   446
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   447
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   448
                if (fError) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   449
                    fError(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   450
                        xmlhttp.statusText,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   451
                        xmlhttp.status,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   452
                        xmlhttp
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   453
                    );
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
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   457
            SimileAjax.Debug.exception("XmlHttp: Error handling onReadyStateChange", e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   458
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   459
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   460
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   461
};
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   464
 *  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
   465
 *  function creates a platform-specific function for
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   466
 *  instantiating an XMLHttpRequest object and then replaces
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   467
 *  itself with that function.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   468
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   469
SimileAjax.XmlHttp._createRequest = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   470
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   471
        var programIDs = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   472
        "Msxml2.XMLHTTP",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   473
        "Microsoft.XMLHTTP",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   474
        "Msxml2.XMLHTTP.4.0"
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
        for (var i = 0; i < programIDs.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   477
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   478
                var programID = programIDs[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   479
                var f = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   480
                    return new ActiveXObject(programID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   481
                };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   482
                var o = f();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   483
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   484
                // We are replacing the SimileAjax._createXmlHttpRequest
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   485
                // function with this inner function as we've
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   486
                // 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
   487
                // 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
   488
                // on subsequent calls.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   489
                SimileAjax.XmlHttp._createRequest = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   490
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   491
                return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   492
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   493
                // silent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   494
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   495
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   496
        // fall through to try new XMLHttpRequest();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   497
    }
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
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   500
        var f = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   501
            return new XMLHttpRequest();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   502
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   503
        var o = f();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   504
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   505
        // We are replacing the SimileAjax._createXmlHttpRequest
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   506
        // function with this inner function as we've
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   507
        // 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
   508
        // 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
   509
        // on subsequent calls.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   510
        SimileAjax.XmlHttp._createRequest = f;
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
        return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   513
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   514
        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
   515
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   516
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   517
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
 * Performs an asynchronous HTTP GET.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   520
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   521
 * @param {Function} fError a function of the form
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   522
     function(statusText, statusCode, xmlhttp)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   523
 * @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
   524
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   525
SimileAjax.XmlHttp.get = function(url, fError, fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   526
    var xmlhttp = SimileAjax.XmlHttp._createRequest();
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
    xmlhttp.open("GET", url, true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   529
    xmlhttp.onreadystatechange = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   530
        SimileAjax.XmlHttp._onReadyStateChange(xmlhttp, fError, fDone);
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
    xmlhttp.send(null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   533
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   534
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
 * Performs an asynchronous HTTP POST.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   537
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   538
 * @param {Function} fError a function of the form
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   539
     function(statusText, statusCode, xmlhttp)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   540
 * @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
   541
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   542
SimileAjax.XmlHttp.post = function(url, body, fError, fDone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   543
    var xmlhttp = SimileAjax.XmlHttp._createRequest();
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
    xmlhttp.open("POST", url, true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   546
    xmlhttp.onreadystatechange = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   547
        SimileAjax.XmlHttp._onReadyStateChange(xmlhttp, fError, fDone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   548
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   549
    xmlhttp.send(body);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   550
};
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
SimileAjax.XmlHttp._forceXML = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   553
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   554
        xmlhttp.overrideMimeType("text/xml");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   555
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   556
        xmlhttp.setrequestheader("Content-Type", "text/xml");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   557
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   558
};/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   559
 *  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
   560
 */
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
/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   563
    json.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   564
    2006-04-28
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   565
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   566
    This file adds these methods to JavaScript:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   567
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   568
        object.toJSONString()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   569
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   570
            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
   571
            object must not contain any cyclical references.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   572
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   573
        array.toJSONString()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   574
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   575
            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
   576
            array must not contain any cyclical references.
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
        string.parseJSON()
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
            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
   581
            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
   582
*/
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   583
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   584
SimileAjax.JSON = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   585
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   586
(function () {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   587
    var m = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   588
        '\b': '\\b',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   589
        '\t': '\\t',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   590
        '\n': '\\n',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   591
        '\f': '\\f',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   592
        '\r': '\\r',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   593
        '"' : '\\"',
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   594
        '\\': '\\\\'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   595
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   596
    var s = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   597
        array: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   598
            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
   599
            for (i = 0; i < l; i += 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   600
                v = x[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   601
                f = s[typeof v];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   602
                if (f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   603
                    v = f(v);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   604
                    if (typeof v == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   605
                        if (b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   606
                            a[a.length] = ',';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   607
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   608
                        a[a.length] = v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   609
                        b = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   610
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   611
                }
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
            a[a.length] = ']';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   614
            return a.join('');
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
        'boolean': function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   617
            return String(x);
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
        'null': function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   620
            return "null";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   621
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   622
        number: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   623
            return isFinite(x) ? String(x) : 'null';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   624
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   625
        object: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   626
            if (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   627
                if (x instanceof Array) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   628
                    return s.array(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   629
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   630
                var a = ['{'], b, f, i, v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   631
                for (i in x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   632
                    v = x[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   633
                    f = s[typeof v];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   634
                    if (f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   635
                        v = f(v);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   636
                        if (typeof v == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   637
                            if (b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   638
                                a[a.length] = ',';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   639
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   640
                            a.push(s.string(i), ':', v);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   641
                            b = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   642
                        }
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
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   645
                a[a.length] = '}';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   646
                return a.join('');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   647
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   648
            return 'null';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   649
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   650
        string: function (x) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   651
            if (/["\\\x00-\x1f]/.test(x)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   652
                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
   653
                    var c = m[b];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   654
                    if (c) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   655
                        return c;
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
                    c = b.charCodeAt();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   658
                    return '\\u00' +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   659
                        Math.floor(c / 16).toString(16) +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   660
                        (c % 16).toString(16);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   661
                });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   662
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   663
            return '"' + x + '"';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   664
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   665
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   666
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   667
    SimileAjax.JSON.toJSONString = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   668
        if (o instanceof Object) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   669
            return s.object(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   670
        } else if (o instanceof Array) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   671
            return s.array(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   672
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   673
            return o.toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   674
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   675
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   676
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   677
    SimileAjax.JSON.parseJSON = function () {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   678
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   679
            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
   680
                    this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   681
                eval('(' + this + ')');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   682
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   683
            return false;
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
})();
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   687
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   688
 *  DOM Utility Functions
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
   689
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   690
 */
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
SimileAjax.DOM = new Object();
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.registerEventWithObject = function(elmt, eventName, obj, handlerName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   695
    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
   696
        return obj[handlerName].call(obj, elmt2, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   697
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   698
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   699
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   700
SimileAjax.DOM.registerEvent = function(elmt, eventName, handler) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   701
    var handler2 = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   702
        evt = (evt) ? evt : ((event) ? event : null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   703
        if (evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   704
            var target = (evt.target) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   705
                evt.target : ((evt.srcElement) ? evt.srcElement : null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   706
            if (target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   707
                target = (target.nodeType == 1 || target.nodeType == 9) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   708
                    target : target.parentNode;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   711
            return handler(elmt, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   712
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   713
        return true;
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
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   717
        elmt.attachEvent("on" + eventName, handler2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   718
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   719
        elmt.addEventListener(eventName, handler2, false);
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   722
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   723
SimileAjax.DOM.getPageCoordinates = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   724
    var left = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   725
    var top = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   726
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   727
    if (elmt.nodeType != 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   728
        elmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   729
    }
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
    var elmt2 = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   732
    while (elmt2 != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   733
        left += elmt2.offsetLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   734
        top += elmt2.offsetTop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   735
        elmt2 = elmt2.offsetParent;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   736
    }
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
    var body = document.body;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   739
    while (elmt != null && elmt != body) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   740
        if ("scrollLeft" in elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   741
            left -= elmt.scrollLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   742
            top -= elmt.scrollTop;
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
        elmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   745
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   746
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   747
    return { left: left, top: top };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   748
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   749
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   750
SimileAjax.DOM.getSize = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   751
	var w = this.getStyle(elmt,"width");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   752
	var h = this.getStyle(elmt,"height");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   753
	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
   754
	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
   755
	return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   756
		w: w,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   757
		h: h
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   758
	}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   759
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   760
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   761
SimileAjax.DOM.getStyle = function(elmt, styleProp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   762
    if (elmt.currentStyle) { // IE
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   763
        var style = elmt.currentStyle[styleProp];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   764
    } else if (window.getComputedStyle) { // standard DOM
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   765
        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
   766
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   767
    	var style = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   768
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   769
    return style;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   770
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   771
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   772
SimileAjax.DOM.getEventRelativeCoordinates = function(evt, elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   773
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   774
      if (evt.type == "mousewheel") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   775
        var coords = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   776
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   777
          x: evt.clientX - coords.left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   778
          y: evt.clientY - coords.top
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
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   782
          x: evt.offsetX,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   783
          y: evt.offsetY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   784
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   785
      }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   786
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   787
        var coords = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   788
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   789
        if ((evt.type == "DOMMouseScroll") &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   790
          SimileAjax.Platform.browser.isFirefox &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   791
          (SimileAjax.Platform.browser.majorVersion == 2)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   792
          // 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
   793
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   794
          return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   795
            x: evt.screenX - coords.left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   796
            y: evt.screenY - coords.top
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
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   799
          return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   800
              x: evt.pageX - coords.left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   801
              y: evt.pageY - coords.top
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   802
          };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   803
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   804
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   805
};
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
SimileAjax.DOM.getEventPageCoordinates = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   808
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   809
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   810
            x: evt.clientX + document.body.scrollLeft,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   811
            y: evt.clientY + document.body.scrollTop
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   814
        return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   815
            x: evt.pageX,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   816
            y: evt.pageY
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   820
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   821
SimileAjax.DOM.hittest = function(x, y, except) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   822
    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
   823
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   824
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   825
SimileAjax.DOM._hittest = function(elmt, x, y, except) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   826
    var childNodes = elmt.childNodes;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   827
    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
   828
        var childNode = childNodes[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   829
        for (var j = 0; j < except.length; j++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   830
            if (childNode == except[j]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   831
                continue outer;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   832
            }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   835
        if (childNode.offsetWidth == 0 && childNode.offsetHeight == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   836
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   837
             *  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
   838
             *  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
   839
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   840
            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
   841
            if (hitNode != childNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   842
                return hitNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   843
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   844
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   845
            var top = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   846
            var left = 0;
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
            var node = childNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   849
            while (node) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   850
                top += node.offsetTop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   851
                left += node.offsetLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   852
                node = node.offsetParent;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   853
            }
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
            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
   856
                return SimileAjax.DOM._hittest(childNode, x, y, except);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   857
            } else if (childNode.nodeType == 1 && childNode.tagName == "TR") {
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
                 *  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
   860
                 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   861
                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
   862
                if (childNode2 != childNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   863
                    return childNode2;
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
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   866
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   867
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   868
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   869
};
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
SimileAjax.DOM.cancelEvent = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   872
    evt.returnValue = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   873
    evt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   874
    if ("preventDefault" in evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   875
        evt.preventDefault();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   876
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   877
};
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
SimileAjax.DOM.appendClassName = function(elmt, className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   880
    var classes = elmt.className.split(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   881
    for (var i = 0; i < classes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   882
        if (classes[i] == className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   883
            return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   884
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   885
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   886
    classes.push(className);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   887
    elmt.className = classes.join(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   888
};
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
SimileAjax.DOM.createInputElement = function(type) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   891
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   892
    div.innerHTML = "<input type='" + type + "' />";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   893
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   894
    return div.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   895
};
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
SimileAjax.DOM.createDOMFromTemplate = function(template) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   898
    var result = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   899
    result.elmt = SimileAjax.DOM._createDOMFromTemplate(template, result, 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
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   902
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   903
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   904
SimileAjax.DOM._createDOMFromTemplate = function(templateNode, result, parentElmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   905
    if (templateNode == null) {
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
        var node = doc.createTextNode("--null--");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   908
        if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   909
            parentElmt.appendChild(node);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   910
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   911
        return 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 null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   914
    } else if (typeof templateNode != "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   915
        var node = document.createTextNode(templateNode);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   916
        if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   917
            parentElmt.appendChild(node);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   918
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   919
        return node;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   920
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   921
        var elmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   922
        if ("tag" in templateNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   923
            var tag = templateNode.tag;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   924
            if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   925
                if (tag == "tr") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   926
                    elmt = parentElmt.insertRow(parentElmt.rows.length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   927
                } else if (tag == "td") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   928
                    elmt = parentElmt.insertCell(parentElmt.cells.length);
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
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   931
            if (elmt == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   932
                elmt = tag == "input" ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   933
                    SimileAjax.DOM.createInputElement(templateNode.type) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   934
                    document.createElement(tag);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   935
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
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   941
            elmt = templateNode.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   942
            if (parentElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   943
                parentElmt.appendChild(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   944
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   945
        }
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
        for (var attribute in templateNode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   948
            var value = templateNode[attribute];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   949
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   950
            if (attribute == "field") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   951
                result[value] = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   952
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   953
            } else if (attribute == "className") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   954
                elmt.className = value;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   955
            } else if (attribute == "id") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   956
                elmt.id = value;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   957
            } else if (attribute == "title") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   958
                elmt.title = value;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   959
            } else if (attribute == "type" && elmt.tagName == "input") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   960
                // do nothing
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   961
            } else if (attribute == "style") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   962
                for (n in value) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   963
                    var v = value[n];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   964
                    if (n == "float") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   965
                        n = SimileAjax.Platform.browser.isIE ? "styleFloat" : "cssFloat";
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
                    elmt.style[n] = v;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   968
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   969
            } else if (attribute == "children") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   970
                for (var i = 0; i < value.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   971
                    SimileAjax.DOM._createDOMFromTemplate(value[i], result, 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
            } else if (attribute != "tag" && attribute != "elmt") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   974
                elmt.setAttribute(attribute, value);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   975
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   976
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   977
        return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   978
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   981
SimileAjax.DOM._cachedParent = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   982
SimileAjax.DOM.createElementFromString = function(s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   983
    if (SimileAjax.DOM._cachedParent == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   984
        SimileAjax.DOM._cachedParent = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   985
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   986
    SimileAjax.DOM._cachedParent.innerHTML = s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   987
    return SimileAjax.DOM._cachedParent.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   988
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   989
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   990
SimileAjax.DOM.createDOMFromString = function(root, s, fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   991
    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
   992
    elmt.innerHTML = s;
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
    var dom = { elmt: elmt };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   995
    SimileAjax.DOM._processDOMChildrenConstructedFromString(dom, elmt, fieldElmts != null ? fieldElmts : {} );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   996
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   997
    return dom;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   998
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
   999
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1000
SimileAjax.DOM._processDOMConstructedFromString = function(dom, elmt, fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1001
    var id = elmt.id;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1002
    if (id != null && id.length > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1003
        elmt.removeAttribute("id");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1004
        if (id in fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1005
            var parentElmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1006
            parentElmt.insertBefore(fieldElmts[id], elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1007
            parentElmt.removeChild(elmt);
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
            dom[id] = fieldElmts[id];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1010
            return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1011
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1012
            dom[id] = elmt;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1016
    if (elmt.hasChildNodes()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1017
        SimileAjax.DOM._processDOMChildrenConstructedFromString(dom, elmt, fieldElmts);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1018
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1019
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1020
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1021
SimileAjax.DOM._processDOMChildrenConstructedFromString = function(dom, elmt, fieldElmts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1022
    var node = elmt.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1023
    while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1024
        var node2 = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1025
        if (node.nodeType == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1026
            SimileAjax.DOM._processDOMConstructedFromString(dom, node, fieldElmts);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1027
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1028
        node = node2;
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
};
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
 * @fileOverview Graphics utility functions and constants
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1033
 * @name SimileAjax.Graphics
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1034
 */
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
SimileAjax.Graphics = new Object();
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1039
 * 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
  1040
 * user's browser or not.
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
 * @type Boolean
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
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
  1045
if (!SimileAjax.Graphics.pngIsTranslucent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1046
    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
  1047
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1048
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1049
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1050
 *  Opacity, translucency
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1051
 *
1156
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
SimileAjax.Graphics._createTranslucentImage1 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1054
    var elmt = document.createElement("img");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1055
    elmt.setAttribute("src", url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1056
    if (verticalAlign != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1057
        elmt.style.verticalAlign = verticalAlign;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1058
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1059
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1060
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1061
SimileAjax.Graphics._createTranslucentImage2 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1062
    var elmt = document.createElement("img");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1063
    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
  1064
    elmt.style.height = "1px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1065
    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
  1066
    elmt.style.verticalAlign = (verticalAlign != null) ? verticalAlign : "middle";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1067
    return elmt;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1070
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1071
 * 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
  1072
 * 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
  1073
 * allow for translucency, even on IE.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1074
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1075
 * @function
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1076
 * @param {String} url the URL to the image
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1077
 * @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
  1078
 * @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
  1079
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1080
SimileAjax.Graphics.createTranslucentImage = SimileAjax.Graphics.pngIsTranslucent ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1081
    SimileAjax.Graphics._createTranslucentImage1 :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1082
    SimileAjax.Graphics._createTranslucentImage2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1083
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1084
SimileAjax.Graphics._createTranslucentImageHTML1 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1085
    return "<img src=\"" + url + "\"" +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1086
        (verticalAlign != null ? " style=\"vertical-align: " + verticalAlign + ";\"" : "") +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1087
        " />";
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
SimileAjax.Graphics._createTranslucentImageHTML2 = function(url, verticalAlign) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1090
    var style =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1091
        "width: 1px; height: 1px; " +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1092
        "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
  1093
        (verticalAlign != null ? " vertical-align: " + verticalAlign + ";" : "");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1094
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1095
    return "<img src='" + url + "' style=\"" + style + "\" />";
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1098
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1099
 * 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
  1100
 * 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
  1101
 * to allow for translucency, even on IE.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1102
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1103
 * @function
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1104
 * @param {String} url the URL to the image
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1105
 * @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
  1106
 * @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
  1107
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1108
SimileAjax.Graphics.createTranslucentImageHTML = SimileAjax.Graphics.pngIsTranslucent ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1109
    SimileAjax.Graphics._createTranslucentImageHTML1 :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1110
    SimileAjax.Graphics._createTranslucentImageHTML2;
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1113
 * Sets the opacity on the given DOM element.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1114
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1115
 * @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
  1116
 * @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
  1117
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1118
SimileAjax.Graphics.setOpacity = function(elmt, opacity) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1119
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1120
        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
  1121
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1122
        var o = (opacity / 100).toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1123
        elmt.style.opacity = o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1124
        elmt.style.MozOpacity = o;
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1128
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1129
 *  Bubble
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1130
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1133
SimileAjax.Graphics.bubbleConfig = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1134
    containerCSSClass:              "simileAjax-bubble-container",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1135
    innerContainerCSSClass:         "simileAjax-bubble-innerContainer",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1136
    contentContainerCSSClass:       "simileAjax-bubble-contentContainer",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1137
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1138
    borderGraphicSize:              50,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1139
    borderGraphicCSSClassPrefix:    "simileAjax-bubble-border-",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1140
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1141
    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
  1142
    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
  1143
    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
  1144
    arrowGraphicCSSClassPrefix:     "simileAjax-bubble-arrow-",
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
    closeGraphicCSSClass:           "simileAjax-bubble-close",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1147
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1148
    extraPadding:                   20
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1149
};
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1152
 * 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
  1153
 * 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
  1154
 * 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
  1155
 * should be given in pixels.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1156
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1157
 * @param {Element} the content div
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1158
 * @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
  1159
 * @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
  1160
 * @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
  1161
 * @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
  1162
 *   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
  1163
 * @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
  1164
 *   Default of 0 or null means no maximum
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1165
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1166
SimileAjax.Graphics.createBubbleForContentAndPoint = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1167
       div, pageX, pageY, contentWidth, orientation, maxHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1168
    if (typeof contentWidth != "number") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1169
        contentWidth = 300;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1170
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1171
    if (typeof maxHeight != "number") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1172
        maxHeight = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1173
    }
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
    div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1176
    div.style.left = "-5000px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1177
    div.style.top = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1178
    div.style.width = contentWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1179
    document.body.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1180
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1181
    window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1182
        var width = div.scrollWidth + 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1183
        var height = div.scrollHeight + 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1184
        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
  1185
        if (maxHeight > 0 && height > maxHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1186
          height = maxHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1187
          scrollDivW = width - 25;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1188
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1189
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1190
        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
  1191
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1192
        document.body.removeChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1193
        div.style.position = "static";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1194
        div.style.left = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1195
        div.style.top = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1196
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1197
        // create a scroll div if needed
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1198
        if (scrollDivW > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1199
          var scrollDiv = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1200
          div.style.width = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1201
          scrollDiv.style.width = scrollDivW + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1202
          scrollDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1203
          bubble.content.appendChild(scrollDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1204
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1205
          div.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1206
          bubble.content.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1207
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1208
    }, 200);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1209
};
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1212
 * 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
  1213
 * 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
  1214
 * 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
  1215
 * pixels.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1216
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1217
 * @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
  1218
 * @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
  1219
 * @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
  1220
 * @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
  1221
 * @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
  1222
 *   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
  1223
 * @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
  1224
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1225
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
  1226
    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
  1227
    contentHeight = parseInt(contentHeight, 10); // getting numbers-as-strings
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1228
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1229
    var bubbleConfig = SimileAjax.Graphics.bubbleConfig;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1230
    var pngTransparencyClassSuffix =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1231
        SimileAjax.Graphics.pngIsTranslucent ? "pngTranslucent" : "pngNotTranslucent";
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
    var bubbleWidth = contentWidth + 2 * bubbleConfig.borderGraphicSize;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1234
    var bubbleHeight = contentHeight + 2 * bubbleConfig.borderGraphicSize;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1235
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1236
    var generatePngSensitiveClass = function(className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1237
        return className + " " + className + "-" + pngTransparencyClassSuffix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1238
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1239
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1240
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1241
     *  Render container divs
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1242
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1243
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1244
    div.className = generatePngSensitiveClass(bubbleConfig.containerCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1245
    div.style.width = contentWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1246
    div.style.height = contentHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1247
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1248
    var divInnerContainer = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1249
    divInnerContainer.className = generatePngSensitiveClass(bubbleConfig.innerContainerCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1250
    div.appendChild(divInnerContainer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1251
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1252
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1253
     *  Create layer for bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1254
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1255
    var close = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1256
        if (!bubble._closed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1257
            document.body.removeChild(bubble._div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1258
            bubble._doc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1259
            bubble._div = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1260
            bubble._content = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1261
            bubble._closed = true;
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
    var bubble = { _closed: false };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1265
    var layer = SimileAjax.WindowManager.pushLayer(close, true, div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1266
    bubble._div = div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1267
    bubble.close = function() { SimileAjax.WindowManager.popLayer(layer); }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1268
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1269
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1270
     *  Render border graphics
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1271
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1272
    var createBorder = function(classNameSuffix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1273
        var divBorderGraphic = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1274
        divBorderGraphic.className = generatePngSensitiveClass(bubbleConfig.borderGraphicCSSClassPrefix + classNameSuffix);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1275
        divInnerContainer.appendChild(divBorderGraphic);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1276
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1277
    createBorder("top-left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1278
    createBorder("top-right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1279
    createBorder("bottom-left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1280
    createBorder("bottom-right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1281
    createBorder("left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1282
    createBorder("right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1283
    createBorder("top");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1284
    createBorder("bottom");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1285
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1286
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1287
     *  Render content
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
    var divContentContainer = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1290
    divContentContainer.className = generatePngSensitiveClass(bubbleConfig.contentContainerCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1291
    divInnerContainer.appendChild(divContentContainer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1292
    bubble.content = divContentContainer;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1293
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1294
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1295
     *  Render close button
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1296
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1297
    var divClose = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1298
    divClose.className = generatePngSensitiveClass(bubbleConfig.closeGraphicCSSClass);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1299
    divInnerContainer.appendChild(divClose);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1300
    SimileAjax.WindowManager.registerEventWithObject(divClose, "click", bubble, "close");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1301
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1302
    (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1303
        var dims = SimileAjax.Graphics.getWindowDimensions();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1304
        var docWidth = dims.w;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1305
        var docHeight = dims.h;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1306
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1307
        var halfArrowGraphicWidth = Math.ceil(bubbleConfig.arrowGraphicWidth / 2);
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
        var createArrow = function(classNameSuffix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1310
            var divArrowGraphic = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1311
            divArrowGraphic.className = generatePngSensitiveClass(bubbleConfig.arrowGraphicCSSClassPrefix + "point-" + classNameSuffix);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1312
            divInnerContainer.appendChild(divArrowGraphic);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1313
            return divArrowGraphic;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1314
        };
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
        if (pageX - halfArrowGraphicWidth - bubbleConfig.borderGraphicSize - bubbleConfig.extraPadding > 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1317
            pageX + halfArrowGraphicWidth + bubbleConfig.borderGraphicSize + bubbleConfig.extraPadding < docWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1318
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1319
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1320
             *  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
  1321
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1322
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1323
            var left = pageX - Math.round(contentWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1324
            left = pageX < (docWidth / 2) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1325
                Math.max(left, bubbleConfig.extraPadding + bubbleConfig.borderGraphicSize) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1326
                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
  1327
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1328
            if ((orientation && orientation == "top") ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1329
                (!orientation &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1330
                    (pageY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1331
                        - bubbleConfig.arrowGraphicTargetOffset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1332
                        - contentHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1333
                        - bubbleConfig.borderGraphicSize
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1334
                        - bubbleConfig.extraPadding > 0))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1335
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
                 *  Position bubble above the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1338
                 */
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
                var divArrow = createArrow("down");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1341
                divArrow.style.left = (pageX - halfArrowGraphicWidth - left) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1342
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1343
                div.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1344
                div.style.top = (pageY - bubbleConfig.arrowGraphicTargetOffset - contentHeight) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1345
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1346
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1347
            } else if ((orientation && orientation == "bottom") ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1348
                (!orientation &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1349
                    (pageY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1350
                        + bubbleConfig.arrowGraphicTargetOffset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1351
                        + contentHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1352
                        + bubbleConfig.borderGraphicSize
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1353
                        + bubbleConfig.extraPadding < docHeight))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1354
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
                 *  Position bubble below the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1357
                 */
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
                var divArrow = createArrow("up");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1360
                divArrow.style.left = (pageX - halfArrowGraphicWidth - left) + "px";
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
                div.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1363
                div.style.top = (pageY + bubbleConfig.arrowGraphicTargetOffset) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1364
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1365
                return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1366
            }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1369
        var top = pageY - Math.round(contentHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1370
        top = pageY < (docHeight / 2) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1371
            Math.max(top, bubbleConfig.extraPadding + bubbleConfig.borderGraphicSize) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1372
            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
  1373
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1374
        if ((orientation && orientation == "left") ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1375
            (!orientation &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1376
                (pageX
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1377
                    - bubbleConfig.arrowGraphicTargetOffset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1378
                    - contentWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1379
                    - bubbleConfig.borderGraphicSize
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1380
                    - bubbleConfig.extraPadding > 0))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1381
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
             *  Position bubble left of the target point.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1384
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1385
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1386
            var divArrow = createArrow("right");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1387
            divArrow.style.top = (pageY - halfArrowGraphicWidth - top) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1388
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1389
            div.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1390
            div.style.left = (pageX - bubbleConfig.arrowGraphicTargetOffset - contentWidth) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1391
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1392
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
             *  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
  1395
             */
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
            var divArrow = createArrow("left");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1398
            divArrow.style.top = (pageY - halfArrowGraphicWidth - top) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1399
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1400
            div.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1401
            div.style.left = (pageX + bubbleConfig.arrowGraphicTargetOffset) + "px";
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1405
    document.body.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1406
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1407
    return bubble;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1408
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1409
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1410
SimileAjax.Graphics.getWindowDimensions = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1411
    if (typeof window.innerHeight == 'number') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1412
        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
  1413
    } else if (document.documentElement && document.documentElement.clientHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1414
        return { // IE6+, in "standards compliant mode"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1415
            w:document.documentElement.clientWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1416
            h:document.documentElement.clientHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1417
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1418
    } else if (document.body && document.body.clientHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1419
        return { // IE 4 compatible
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1420
            w:document.body.clientWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1421
            h:document.body.clientHeight
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1422
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1423
    }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1424
};
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1425
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1426
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1427
/**
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1428
 * 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
  1429
 * displaying modal information, e.g. "Loading..."
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1430
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1431
 * @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
  1432
 * @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
  1433
 *   consisting of the newly created DOM elements
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1434
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1435
SimileAjax.Graphics.createMessageBubble = function(doc) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1436
    var containerDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1437
    if (SimileAjax.Graphics.pngIsTranslucent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1438
        var topDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1439
        topDiv.style.height = "33px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1440
        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
  1441
        topDiv.style.paddingLeft = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1442
        containerDiv.appendChild(topDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1443
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1444
        var topRightDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1445
        topRightDiv.style.height = "33px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1446
        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
  1447
        topDiv.appendChild(topRightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1448
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1449
        var middleDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1450
        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
  1451
        middleDiv.style.paddingLeft = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1452
        containerDiv.appendChild(middleDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1453
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1454
        var middleRightDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1455
        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
  1456
        middleRightDiv.style.paddingRight = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1457
        middleDiv.appendChild(middleRightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1458
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1459
        var contentDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1460
        middleRightDiv.appendChild(contentDiv);
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 bottomDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1463
        bottomDiv.style.height = "55px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1464
        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
  1465
        bottomDiv.style.paddingLeft = "44px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1466
        containerDiv.appendChild(bottomDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1467
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1468
        var bottomRightDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1469
        bottomRightDiv.style.height = "55px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1470
        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
  1471
        bottomDiv.appendChild(bottomRightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1472
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1473
        containerDiv.style.border = "2px solid #7777AA";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1474
        containerDiv.style.padding = "20px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1475
        containerDiv.style.background = "white";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1476
        SimileAjax.Graphics.setOpacity(containerDiv, 90);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1477
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1478
        var contentDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1479
        containerDiv.appendChild(contentDiv);
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
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1483
        containerDiv:   containerDiv,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1484
        contentDiv:     contentDiv
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1488
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1489
 *  Animation
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1490
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1493
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1494
 * 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
  1495
 * "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
  1496
 * 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
  1497
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1498
 * @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
  1499
 *   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
  1500
 *   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
  1501
 * @param {Number} from a starting value
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1502
 * @param {Number} to an ending value
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1503
 * @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
  1504
 * @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
  1505
 *   the animation, i.e. a continuation.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1506
 * @return {SimileAjax.Graphics._Animation} a new animation object
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1507
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1508
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
  1509
    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
  1510
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1511
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1512
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
  1513
    this.f = f;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1514
    this.cont = (typeof cont == "function") ? cont : function() {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1515
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1516
    this.from = from;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1517
    this.to = to;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1518
    this.current = from;
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
    this.duration = duration;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1521
    this.start = new Date().getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1522
    this.timePassed = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1523
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1524
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
 * Runs this animation.
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
SimileAjax.Graphics._Animation.prototype.run = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1529
    var a = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1530
    window.setTimeout(function() { a.step(); }, 50);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1531
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1532
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
 * 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
  1535
 * <code>run()</code>.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1536
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1537
SimileAjax.Graphics._Animation.prototype.step = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1538
    this.timePassed += 50;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1539
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1540
    var timePassedFraction = this.timePassed / this.duration;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1541
    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
  1542
    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
  1543
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1544
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1545
        this.f(current, current - this.current);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1546
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1547
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1548
    this.current = current;
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
    if (this.timePassed < this.duration) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1551
        this.run();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1552
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1553
        this.f(this.to, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1554
        this["cont"]();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1555
    }
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1558
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1559
 *  CopyPasteButton
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1560
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1561
 *  Adapted from http://spaces.live.com/editorial/rayozzie/demo/liveclip/liveclipsample/techPreview.html.
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1562
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1565
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1566
 * 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
  1567
 * 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
  1568
 * createDataFunction parameter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1569
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1570
 * @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
  1571
 *   generated box
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1572
 * @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
  1573
 * @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
  1574
 * @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
  1575
 *   arguments to generate the structured data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1576
 * @return a new DOM element
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1577
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1578
SimileAjax.Graphics.createStructuredDataCopyButton = function(image, width, height, createDataFunction) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1579
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1580
    div.style.position = "relative";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1581
    div.style.display = "inline";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1582
    div.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1583
    div.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1584
    div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1585
    div.style.margin = "2px";
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
    if (SimileAjax.Graphics.pngIsTranslucent) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1588
        div.style.background = "url(" + image + ") no-repeat";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1589
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1590
        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
  1591
    }
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
    var style;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1594
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1595
        style = "filter:alpha(opacity=0)";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1596
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1597
        style = "opacity: 0";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1598
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1599
    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
  1600
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1601
    var textarea = div.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1602
    textarea.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1603
    textarea.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1604
    textarea.onmousedown = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1605
        evt = (evt) ? evt : ((event) ? event : null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1606
        if (evt.button == 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1607
            textarea.value = createDataFunction();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1608
            textarea.select();
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
    };
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
    return div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1613
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1614
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1615
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1616
 *  getWidthHeight
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1617
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1618
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1619
SimileAjax.Graphics.getWidthHeight = function(el) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1620
    // RETURNS hash {width:  w, height: h} in pixels
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1621
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1622
    var w, h;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1623
    // 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
  1624
    // 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
  1625
    if (el.getBoundingClientRect == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1626
    	// use offsetWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1627
      w = el.offsetWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1628
      h = el.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1629
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1630
    	// use getBoundingClientRect
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1631
      var rect = el.getBoundingClientRect();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1632
      w = Math.ceil(rect.right - rect.left);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1633
    	h = Math.ceil(rect.bottom - rect.top);
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
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1636
        width:  w,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1637
        height: h
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1638
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1639
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1640
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1641
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1642
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1643
 *  FontRenderingContext
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  1644
 *
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1645
 */
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1646
SimileAjax.Graphics.getFontRenderingContext = function(elmt, width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1647
    return new SimileAjax.Graphics._FontRenderingContext(elmt, width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1648
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1649
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1650
SimileAjax.Graphics._FontRenderingContext = function(elmt, width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1651
    this._elmt = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1652
    this._elmt.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1653
    if (typeof width == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1654
        this._elmt.style.width = width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1655
    } else if (typeof width == "number") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1656
        this._elmt.style.width = width + "px";
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1659
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1660
SimileAjax.Graphics._FontRenderingContext.prototype.dispose = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1661
    this._elmt = null;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1664
SimileAjax.Graphics._FontRenderingContext.prototype.update = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1665
    this._elmt.innerHTML = "A";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1666
    this._lineHeight = this._elmt.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1667
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1668
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1669
SimileAjax.Graphics._FontRenderingContext.prototype.computeSize = function(text, className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1670
    // className arg is optional
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1671
    var el = this._elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1672
    el.innerHTML = text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1673
    el.className = className === undefined ? '' : className;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1674
    var wh = SimileAjax.Graphics.getWidthHeight(el);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1675
    el.className = ''; // reset for the next guy
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
    return wh;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1680
SimileAjax.Graphics._FontRenderingContext.prototype.getLineHeight = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1681
    return this._lineHeight;
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
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
 * @fileOverview A collection of date/time utility functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1686
 * @name SimileAjax.DateTime
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1687
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1688
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1689
SimileAjax.DateTime = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1690
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1691
SimileAjax.DateTime.MILLISECOND    = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1692
SimileAjax.DateTime.SECOND         = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1693
SimileAjax.DateTime.MINUTE         = 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1694
SimileAjax.DateTime.HOUR           = 3;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1695
SimileAjax.DateTime.DAY            = 4;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1696
SimileAjax.DateTime.WEEK           = 5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1697
SimileAjax.DateTime.MONTH          = 6;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1698
SimileAjax.DateTime.YEAR           = 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1699
SimileAjax.DateTime.DECADE         = 8;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1700
SimileAjax.DateTime.CENTURY        = 9;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1701
SimileAjax.DateTime.MILLENNIUM     = 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1702
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1703
SimileAjax.DateTime.EPOCH          = -1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1704
SimileAjax.DateTime.ERA            = -2;
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1707
 * 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
  1708
 * 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
  1709
 * SimileAjax.DateTime object, e.g. SimileAjax.DateTime.YEAR.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1710
 * @type Array
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1711
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1712
SimileAjax.DateTime.gregorianUnitLengths = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1713
    (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1714
        var d = SimileAjax.DateTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1715
        var a = d.gregorianUnitLengths;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1716
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1717
        a[d.MILLISECOND] = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1718
        a[d.SECOND]      = 1000;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1719
        a[d.MINUTE]      = a[d.SECOND] * 60;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1720
        a[d.HOUR]        = a[d.MINUTE] * 60;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1721
        a[d.DAY]         = a[d.HOUR] * 24;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1722
        a[d.WEEK]        = a[d.DAY] * 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1723
        a[d.MONTH]       = a[d.DAY] * 31;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1724
        a[d.YEAR]        = a[d.DAY] * 365;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1725
        a[d.DECADE]      = a[d.YEAR] * 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1726
        a[d.CENTURY]     = a[d.YEAR] * 100;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1727
        a[d.MILLENNIUM]  = a[d.YEAR] * 1000;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1728
    })();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1729
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1730
SimileAjax.DateTime._dateRegexp = new RegExp(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1731
    "^(-?)([0-9]{4})(" + [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1732
        "(-?([0-9]{2})(-?([0-9]{2}))?)", // -month-dayOfMonth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1733
        "(-?([0-9]{3}))",                // -dayOfYear
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1734
        "(-?W([0-9]{2})(-?([1-7]))?)"    // -Wweek-dayOfWeek
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1735
    ].join("|") + ")?$"
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
SimileAjax.DateTime._timezoneRegexp = new RegExp(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1738
    "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1739
);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1740
SimileAjax.DateTime._timeRegexp = new RegExp(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1741
    "^([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
  1742
);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1743
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1744
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1745
 * 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
  1746
 * 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
  1747
 * does not parse any time information.
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
 * @param {Date} dateObject the date object to modify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1750
 * @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
  1751
 * @return {Date} the modified date object
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
SimileAjax.DateTime.setIso8601Date = function(dateObject, string) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1754
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1755
     *  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
  1756
     *  http://dojotoolkit.org/.
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1759
    var d = string.match(SimileAjax.DateTime._dateRegexp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1760
    if(!d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1761
        throw new Error("Invalid date string: " + string);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1762
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1763
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1764
    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
  1765
    var year = sign * d[2];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1766
    var month = d[5];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1767
    var date = d[7];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1768
    var dayofyear = d[9];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1769
    var week = d[11];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1770
    var dayofweek = (d[13]) ? d[13] : 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1771
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1772
    dateObject.setUTCFullYear(year);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1773
    if (dayofyear) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1774
        dateObject.setUTCMonth(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1775
        dateObject.setUTCDate(Number(dayofyear));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1776
    } else if (week) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1777
        dateObject.setUTCMonth(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1778
        dateObject.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1779
        var gd = dateObject.getUTCDay();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1780
        var day =  (gd) ? gd : 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1781
        var offset = Number(dayofweek) + (7 * Number(week));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1782
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1783
        if (day <= 4) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1784
            dateObject.setUTCDate(offset + 1 - day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1785
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1786
            dateObject.setUTCDate(offset + 8 - day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1787
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1788
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1789
        if (month) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1790
            dateObject.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1791
            dateObject.setUTCMonth(month - 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1792
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1793
        if (date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1794
            dateObject.setUTCDate(date);
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1797
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1798
    return dateObject;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1801
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1802
 * 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
  1803
 * 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
  1804
 * does not parse any date information.
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
 * @param {Date} dateObject the date object to modify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1807
 * @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
  1808
 * @return {Date} the modified date object
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
SimileAjax.DateTime.setIso8601Time = function (dateObject, string) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1811
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1812
     *  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
  1813
     *  http://dojotoolkit.org/.
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1816
    var d = string.match(SimileAjax.DateTime._timeRegexp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1817
    if(!d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1818
        SimileAjax.Debug.warn("Invalid time string: " + string);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1819
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1820
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1821
    var hours = d[1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1822
    var mins = Number((d[3]) ? d[3] : 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1823
    var secs = (d[5]) ? d[5] : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1824
    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
  1825
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1826
    dateObject.setUTCHours(hours);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1827
    dateObject.setUTCMinutes(mins);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1828
    dateObject.setUTCSeconds(secs);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1829
    dateObject.setUTCMilliseconds(ms);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1830
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1831
    return dateObject;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1832
};
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
 * 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
  1836
 * @type Number
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
SimileAjax.DateTime.timezoneOffset = new Date().getTimezoneOffset();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1839
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1840
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1841
 * 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
  1842
 * 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
  1843
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1844
 * @param {Date} dateObject the date object to modify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1845
 * @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
  1846
 * @return {Date} the modified date object
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
SimileAjax.DateTime.setIso8601 = function (dateObject, string){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1849
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1850
     *  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
  1851
     *  http://dojotoolkit.org/.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1852
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1853
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1854
    var offset = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1855
    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
  1856
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1857
    SimileAjax.DateTime.setIso8601Date(dateObject, comps[0]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1858
    if (comps.length == 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1859
        // first strip timezone info from the end
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1860
        var d = comps[1].match(SimileAjax.DateTime._timezoneRegexp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1861
        if (d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1862
            if (d[0] == 'Z') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1863
                offset = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1864
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1865
                offset = (Number(d[3]) * 60) + Number(d[5]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1866
                offset *= ((d[2] == '-') ? 1 : -1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1867
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1868
            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
  1869
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1870
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1871
        SimileAjax.DateTime.setIso8601Time(dateObject, comps[1]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1872
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1873
    if (offset == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1874
        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
  1875
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1876
    dateObject.setTime(dateObject.getTime() + offset * 60000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1877
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1878
    return dateObject;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1879
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1880
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
 * 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
  1883
 * 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
  1884
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1885
 * @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
  1886
 * @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
  1887
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1888
SimileAjax.DateTime.parseIso8601DateTime = function (string) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1889
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1890
        return SimileAjax.DateTime.setIso8601(new Date(0), string);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1891
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1892
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1893
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1894
};
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1897
 * 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
  1898
 * 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
  1899
 * 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
  1900
 * simply returns the given date instead.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1901
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1902
 * @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
  1903
 * @return {Date} the date object
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
SimileAjax.DateTime.parseGregorianDateTime = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1906
    if (o == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1907
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1908
    } else if (o instanceof Date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1909
        return o;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1910
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1911
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1912
    var s = o.toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1913
    if (s.length > 0 && s.length < 8) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1914
        var space = s.indexOf(" ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1915
        if (space > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1916
            var year = parseInt(s.substr(0, space));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1917
            var suffix = s.substr(space + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1918
            if (suffix.toLowerCase() == "bc") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1919
                year = 1 - year;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1920
            }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  1921
        } else {
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1922
            var year = parseInt(s);
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
        var d = new Date(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1926
        d.setUTCFullYear(year);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1927
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1928
        return d;
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
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1932
        return new Date(Date.parse(s));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1933
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1934
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1935
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1938
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1939
 * 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
  1940
 * 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
  1941
 * timezone if specified.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1942
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1943
 * @param {Date} date the date object to round
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1944
 * @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
  1945
 *   interval, e.g. SimileAjax.DateTime.HOUR
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1946
 * @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
  1947
 * @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
  1948
 * @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
  1949
 *   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
  1950
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1951
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
  1952
    var timeShift = timeZone *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1953
        SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1954
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1955
    var date2 = new Date(date.getTime() + timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1956
    var clearInDay = function(d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1957
        d.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1958
        d.setUTCSeconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1959
        d.setUTCMinutes(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1960
        d.setUTCHours(0);
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
    var clearInYear = function(d) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1963
        clearInDay(d);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1964
        d.setUTCDate(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1965
        d.setUTCMonth(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1966
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1967
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1968
    switch(intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1969
    case SimileAjax.DateTime.MILLISECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1970
        var x = date2.getUTCMilliseconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1971
        date2.setUTCMilliseconds(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.SECOND:
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1976
        var x = date2.getUTCSeconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1977
        date2.setUTCSeconds(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1978
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1979
    case SimileAjax.DateTime.MINUTE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1980
        date2.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1981
        date2.setUTCSeconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1982
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1983
        var x = date2.getUTCMinutes();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1984
        date2.setTime(date2.getTime() -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1985
            (x % multiple) * SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.MINUTE]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1986
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1987
    case SimileAjax.DateTime.HOUR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1988
        date2.setUTCMilliseconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1989
        date2.setUTCSeconds(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1990
        date2.setUTCMinutes(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1991
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1992
        var x = date2.getUTCHours();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1993
        date2.setUTCHours(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1994
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1995
    case SimileAjax.DateTime.DAY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  1996
        clearInDay(date2);
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.WEEK:
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
        var d = (date2.getUTCDay() + 7 - firstDayOfWeek) % 7;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2001
        date2.setTime(date2.getTime() -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2002
            d * SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.DAY]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2003
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2004
    case SimileAjax.DateTime.MONTH:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2005
        clearInDay(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2006
        date2.setUTCDate(1);
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.getUTCMonth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2009
        date2.setUTCMonth(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.YEAR:
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2014
        var x = date2.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2015
        date2.setUTCFullYear(x - (x % multiple));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2016
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2017
    case SimileAjax.DateTime.DECADE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2018
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2019
        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 10) * 10);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2020
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2021
    case SimileAjax.DateTime.CENTURY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2022
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2023
        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 100) * 100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2024
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2025
    case SimileAjax.DateTime.MILLENNIUM:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2026
        clearInYear(date2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2027
        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 1000) * 1000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2028
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2029
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2030
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2031
    date.setTime(date2.getTime() - timeShift);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2034
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2035
 * 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
  2036
 * 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
  2037
 * timezone if specified.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2038
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2039
 * @param {Date} date the date object to round
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2040
 * @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
  2041
 *   interval, e.g. SimileAjax.DateTime.HOUR
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2042
 * @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
  2043
 * @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
  2044
 * @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
  2045
 *   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
  2046
 * @see SimileAjax.DateTime.roundDownToInterval
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2047
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2048
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
  2049
    var originalTime = date.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2050
    SimileAjax.DateTime.roundDownToInterval(date, intervalUnit, timeZone, multiple, firstDayOfWeek);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2051
    if (date.getTime() < originalTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2052
        date.setTime(date.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2053
            SimileAjax.DateTime.gregorianUnitLengths[intervalUnit] * multiple);
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2056
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2057
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2058
 * 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
  2059
 * consideration the timezone.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2060
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2061
 * @param {Date} date the date object to increment
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2062
 * @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
  2063
 *   interval, e.g. SimileAjax.DateTime.HOUR
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2064
 * @param {Number} timeZone the timezone offset in hours
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
SimileAjax.DateTime.incrementByInterval = function(date, intervalUnit, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2067
    timeZone = (typeof timeZone == 'undefined') ? 0 : timeZone;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2068
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2069
    var timeShift = timeZone *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2070
        SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2071
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2072
    var date2 = new Date(date.getTime() + timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2073
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2074
    switch(intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2075
    case SimileAjax.DateTime.MILLISECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2076
        date2.setTime(date2.getTime() + 1)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2077
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2078
    case SimileAjax.DateTime.SECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2079
        date2.setTime(date2.getTime() + 1000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2080
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2081
    case SimileAjax.DateTime.MINUTE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2082
        date2.setTime(date2.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2083
            SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.MINUTE]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2084
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2085
    case SimileAjax.DateTime.HOUR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2086
        date2.setTime(date2.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2087
            SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR]);
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.DAY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2090
        date2.setUTCDate(date2.getUTCDate() + 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.WEEK:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2093
        date2.setUTCDate(date2.getUTCDate() + 7);
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.MONTH:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2096
        date2.setUTCMonth(date2.getUTCMonth() + 1);
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.YEAR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2099
        date2.setUTCFullYear(date2.getUTCFullYear() + 1);
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.DECADE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2102
        date2.setUTCFullYear(date2.getUTCFullYear() + 10);
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
    case SimileAjax.DateTime.CENTURY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2105
        date2.setUTCFullYear(date2.getUTCFullYear() + 100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2106
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2107
    case SimileAjax.DateTime.MILLENNIUM:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2108
        date2.setUTCFullYear(date2.getUTCFullYear() + 1000);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2109
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2110
    }
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
    date.setTime(date2.getTime() - timeShift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2113
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2114
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
 * 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
  2117
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2118
 * @param {Date} date the starting date
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2119
 * @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
  2120
 * @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
  2121
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2122
SimileAjax.DateTime.removeTimeZoneOffset = function(date, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2123
    return new Date(date.getTime() +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2124
        timeZone * SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.HOUR]);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2127
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2128
 * Returns the timezone of the user's browser.
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
 * @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
  2131
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2132
SimileAjax.DateTime.getTimezone = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2133
    var d = new Date().getTimezoneOffset();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2134
    return d / -60;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2135
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2136
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2137
 *  String Utility Functions and Constants
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2138
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2139
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2140
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2141
String.prototype.trim = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2142
    return this.replace(/^\s+|\s+$/g, '');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2143
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2144
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2145
String.prototype.startsWith = function(prefix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2146
    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
  2147
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2148
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2149
String.prototype.endsWith = function(suffix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2150
    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
  2151
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2152
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2153
String.substitute = function(s, objects) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2154
    var result = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2155
    var start = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2156
    while (start < s.length - 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2157
        var percent = s.indexOf("%", start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2158
        if (percent < 0 || percent == s.length - 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2159
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2160
        } else if (percent > start && s.charAt(percent - 1) == "\\") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2161
            result += s.substring(start, percent - 1) + "%";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2162
            start = percent + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2163
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2164
            var n = parseInt(s.charAt(percent + 1));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2165
            if (isNaN(n) || n >= objects.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2166
                result += s.substring(start, percent + 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2167
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2168
                result += s.substring(start, percent) + objects[n].toString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2169
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2170
            start = percent + 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2171
        }
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
    if (start < s.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2175
        result += s.substring(start);
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
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2178
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2179
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2180
 *  HTML Utility Functions
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2181
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2182
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2184
SimileAjax.HTML = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2185
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2186
SimileAjax.HTML._e2uHash = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2187
(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2188
    var e2uHash = SimileAjax.HTML._e2uHash;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2189
    e2uHash['nbsp']= '\u00A0[space]';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2190
    e2uHash['iexcl']= '\u00A1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2191
    e2uHash['cent']= '\u00A2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2192
    e2uHash['pound']= '\u00A3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2193
    e2uHash['curren']= '\u00A4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2194
    e2uHash['yen']= '\u00A5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2195
    e2uHash['brvbar']= '\u00A6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2196
    e2uHash['sect']= '\u00A7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2197
    e2uHash['uml']= '\u00A8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2198
    e2uHash['copy']= '\u00A9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2199
    e2uHash['ordf']= '\u00AA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2200
    e2uHash['laquo']= '\u00AB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2201
    e2uHash['not']= '\u00AC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2202
    e2uHash['shy']= '\u00AD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2203
    e2uHash['reg']= '\u00AE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2204
    e2uHash['macr']= '\u00AF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2205
    e2uHash['deg']= '\u00B0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2206
    e2uHash['plusmn']= '\u00B1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2207
    e2uHash['sup2']= '\u00B2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2208
    e2uHash['sup3']= '\u00B3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2209
    e2uHash['acute']= '\u00B4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2210
    e2uHash['micro']= '\u00B5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2211
    e2uHash['para']= '\u00B6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2212
    e2uHash['middot']= '\u00B7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2213
    e2uHash['cedil']= '\u00B8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2214
    e2uHash['sup1']= '\u00B9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2215
    e2uHash['ordm']= '\u00BA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2216
    e2uHash['raquo']= '\u00BB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2217
    e2uHash['frac14']= '\u00BC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2218
    e2uHash['frac12']= '\u00BD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2219
    e2uHash['frac34']= '\u00BE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2220
    e2uHash['iquest']= '\u00BF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2221
    e2uHash['Agrave']= '\u00C0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2222
    e2uHash['Aacute']= '\u00C1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2223
    e2uHash['Acirc']= '\u00C2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2224
    e2uHash['Atilde']= '\u00C3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2225
    e2uHash['Auml']= '\u00C4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2226
    e2uHash['Aring']= '\u00C5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2227
    e2uHash['AElig']= '\u00C6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2228
    e2uHash['Ccedil']= '\u00C7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2229
    e2uHash['Egrave']= '\u00C8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2230
    e2uHash['Eacute']= '\u00C9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2231
    e2uHash['Ecirc']= '\u00CA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2232
    e2uHash['Euml']= '\u00CB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2233
    e2uHash['Igrave']= '\u00CC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2234
    e2uHash['Iacute']= '\u00CD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2235
    e2uHash['Icirc']= '\u00CE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2236
    e2uHash['Iuml']= '\u00CF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2237
    e2uHash['ETH']= '\u00D0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2238
    e2uHash['Ntilde']= '\u00D1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2239
    e2uHash['Ograve']= '\u00D2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2240
    e2uHash['Oacute']= '\u00D3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2241
    e2uHash['Ocirc']= '\u00D4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2242
    e2uHash['Otilde']= '\u00D5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2243
    e2uHash['Ouml']= '\u00D6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2244
    e2uHash['times']= '\u00D7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2245
    e2uHash['Oslash']= '\u00D8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2246
    e2uHash['Ugrave']= '\u00D9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2247
    e2uHash['Uacute']= '\u00DA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2248
    e2uHash['Ucirc']= '\u00DB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2249
    e2uHash['Uuml']= '\u00DC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2250
    e2uHash['Yacute']= '\u00DD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2251
    e2uHash['THORN']= '\u00DE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2252
    e2uHash['szlig']= '\u00DF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2253
    e2uHash['agrave']= '\u00E0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2254
    e2uHash['aacute']= '\u00E1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2255
    e2uHash['acirc']= '\u00E2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2256
    e2uHash['atilde']= '\u00E3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2257
    e2uHash['auml']= '\u00E4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2258
    e2uHash['aring']= '\u00E5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2259
    e2uHash['aelig']= '\u00E6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2260
    e2uHash['ccedil']= '\u00E7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2261
    e2uHash['egrave']= '\u00E8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2262
    e2uHash['eacute']= '\u00E9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2263
    e2uHash['ecirc']= '\u00EA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2264
    e2uHash['euml']= '\u00EB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2265
    e2uHash['igrave']= '\u00EC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2266
    e2uHash['iacute']= '\u00ED';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2267
    e2uHash['icirc']= '\u00EE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2268
    e2uHash['iuml']= '\u00EF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2269
    e2uHash['eth']= '\u00F0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2270
    e2uHash['ntilde']= '\u00F1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2271
    e2uHash['ograve']= '\u00F2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2272
    e2uHash['oacute']= '\u00F3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2273
    e2uHash['ocirc']= '\u00F4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2274
    e2uHash['otilde']= '\u00F5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2275
    e2uHash['ouml']= '\u00F6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2276
    e2uHash['divide']= '\u00F7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2277
    e2uHash['oslash']= '\u00F8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2278
    e2uHash['ugrave']= '\u00F9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2279
    e2uHash['uacute']= '\u00FA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2280
    e2uHash['ucirc']= '\u00FB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2281
    e2uHash['uuml']= '\u00FC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2282
    e2uHash['yacute']= '\u00FD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2283
    e2uHash['thorn']= '\u00FE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2284
    e2uHash['yuml']= '\u00FF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2285
    e2uHash['quot']= '\u0022';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2286
    e2uHash['amp']= '\u0026';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2287
    e2uHash['lt']= '\u003C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2288
    e2uHash['gt']= '\u003E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2289
    e2uHash['OElig']= '';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2290
    e2uHash['oelig']= '\u0153';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2291
    e2uHash['Scaron']= '\u0160';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2292
    e2uHash['scaron']= '\u0161';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2293
    e2uHash['Yuml']= '\u0178';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2294
    e2uHash['circ']= '\u02C6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2295
    e2uHash['tilde']= '\u02DC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2296
    e2uHash['ensp']= '\u2002';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2297
    e2uHash['emsp']= '\u2003';
5767
1d811df051c2 [packaging] MANIFEST.in cleanups, update js/css copyright, remove no more used files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2097
diff changeset
  2298
    e2uHash['thinsp']= '\u2010';
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2299
    e2uHash['zwnj']= '\u200C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2300
    e2uHash['zwj']= '\u200D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2301
    e2uHash['lrm']= '\u200E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2302
    e2uHash['rlm']= '\u200F';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2303
    e2uHash['ndash']= '\u2013';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2304
    e2uHash['mdash']= '\u2014';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2305
    e2uHash['lsquo']= '\u2018';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2306
    e2uHash['rsquo']= '\u2019';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2307
    e2uHash['sbquo']= '\u201A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2308
    e2uHash['ldquo']= '\u201C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2309
    e2uHash['rdquo']= '\u201D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2310
    e2uHash['bdquo']= '\u201E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2311
    e2uHash['dagger']= '\u2020';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2312
    e2uHash['Dagger']= '\u2021';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2313
    e2uHash['permil']= '\u2030';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2314
    e2uHash['lsaquo']= '\u2039';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2315
    e2uHash['rsaquo']= '\u203A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2316
    e2uHash['euro']= '\u20AC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2317
    e2uHash['fnof']= '\u0192';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2318
    e2uHash['Alpha']= '\u0391';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2319
    e2uHash['Beta']= '\u0392';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2320
    e2uHash['Gamma']= '\u0393';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2321
    e2uHash['Delta']= '\u0394';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2322
    e2uHash['Epsilon']= '\u0395';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2323
    e2uHash['Zeta']= '\u0396';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2324
    e2uHash['Eta']= '\u0397';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2325
    e2uHash['Theta']= '\u0398';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2326
    e2uHash['Iota']= '\u0399';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2327
    e2uHash['Kappa']= '\u039A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2328
    e2uHash['Lambda']= '\u039B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2329
    e2uHash['Mu']= '\u039C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2330
    e2uHash['Nu']= '\u039D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2331
    e2uHash['Xi']= '\u039E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2332
    e2uHash['Omicron']= '\u039F';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2333
    e2uHash['Pi']= '\u03A0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2334
    e2uHash['Rho']= '\u03A1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2335
    e2uHash['Sigma']= '\u03A3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2336
    e2uHash['Tau']= '\u03A4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2337
    e2uHash['Upsilon']= '\u03A5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2338
    e2uHash['Phi']= '\u03A6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2339
    e2uHash['Chi']= '\u03A7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2340
    e2uHash['Psi']= '\u03A8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2341
    e2uHash['Omega']= '\u03A9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2342
    e2uHash['alpha']= '\u03B1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2343
    e2uHash['beta']= '\u03B2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2344
    e2uHash['gamma']= '\u03B3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2345
    e2uHash['delta']= '\u03B4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2346
    e2uHash['epsilon']= '\u03B5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2347
    e2uHash['zeta']= '\u03B6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2348
    e2uHash['eta']= '\u03B7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2349
    e2uHash['theta']= '\u03B8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2350
    e2uHash['iota']= '\u03B9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2351
    e2uHash['kappa']= '\u03BA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2352
    e2uHash['lambda']= '\u03BB';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2353
    e2uHash['mu']= '\u03BC';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2354
    e2uHash['nu']= '\u03BD';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2355
    e2uHash['xi']= '\u03BE';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2356
    e2uHash['omicron']= '\u03BF';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2357
    e2uHash['pi']= '\u03C0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2358
    e2uHash['rho']= '\u03C1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2359
    e2uHash['sigmaf']= '\u03C2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2360
    e2uHash['sigma']= '\u03C3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2361
    e2uHash['tau']= '\u03C4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2362
    e2uHash['upsilon']= '\u03C5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2363
    e2uHash['phi']= '\u03C6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2364
    e2uHash['chi']= '\u03C7';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2365
    e2uHash['psi']= '\u03C8';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2366
    e2uHash['omega']= '\u03C9';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2367
    e2uHash['thetasym']= '\u03D1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2368
    e2uHash['upsih']= '\u03D2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2369
    e2uHash['piv']= '\u03D6';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2370
    e2uHash['bull']= '\u2022';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2371
    e2uHash['hellip']= '\u2026';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2372
    e2uHash['prime']= '\u2032';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2373
    e2uHash['Prime']= '\u2033';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2374
    e2uHash['oline']= '\u203E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2375
    e2uHash['frasl']= '\u2044';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2376
    e2uHash['weierp']= '\u2118';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2377
    e2uHash['image']= '\u2111';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2378
    e2uHash['real']= '\u211C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2379
    e2uHash['trade']= '\u2122';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2380
    e2uHash['alefsym']= '\u2135';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2381
    e2uHash['larr']= '\u2190';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2382
    e2uHash['uarr']= '\u2191';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2383
    e2uHash['rarr']= '\u2192';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2384
    e2uHash['darr']= '\u2193';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2385
    e2uHash['harr']= '\u2194';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2386
    e2uHash['crarr']= '\u21B5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2387
    e2uHash['lArr']= '\u21D0';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2388
    e2uHash['uArr']= '\u21D1';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2389
    e2uHash['rArr']= '\u21D2';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2390
    e2uHash['dArr']= '\u21D3';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2391
    e2uHash['hArr']= '\u21D4';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2392
    e2uHash['forall']= '\u2200';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2393
    e2uHash['part']= '\u2202';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2394
    e2uHash['exist']= '\u2203';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2395
    e2uHash['empty']= '\u2205';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2396
    e2uHash['nabla']= '\u2207';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2397
    e2uHash['isin']= '\u2208';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2398
    e2uHash['notin']= '\u2209';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2399
    e2uHash['ni']= '\u220B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2400
    e2uHash['prod']= '\u220F';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2401
    e2uHash['sum']= '\u2211';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2402
    e2uHash['minus']= '\u2212';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2403
    e2uHash['lowast']= '\u2217';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2404
    e2uHash['radic']= '\u221A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2405
    e2uHash['prop']= '\u221D';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2406
    e2uHash['infin']= '\u221E';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2407
    e2uHash['ang']= '\u2220';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2408
    e2uHash['and']= '\u2227';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2409
    e2uHash['or']= '\u2228';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2410
    e2uHash['cap']= '\u2229';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2411
    e2uHash['cup']= '\u222A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2412
    e2uHash['int']= '\u222B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2413
    e2uHash['there4']= '\u2234';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2414
    e2uHash['sim']= '\u223C';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2415
    e2uHash['cong']= '\u2245';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2416
    e2uHash['asymp']= '\u2248';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2417
    e2uHash['ne']= '\u2260';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2418
    e2uHash['equiv']= '\u2261';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2419
    e2uHash['le']= '\u2264';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2420
    e2uHash['ge']= '\u2265';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2421
    e2uHash['sub']= '\u2282';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2422
    e2uHash['sup']= '\u2283';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2423
    e2uHash['nsub']= '\u2284';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2424
    e2uHash['sube']= '\u2286';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2425
    e2uHash['supe']= '\u2287';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2426
    e2uHash['oplus']= '\u2295';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2427
    e2uHash['otimes']= '\u2297';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2428
    e2uHash['perp']= '\u22A5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2429
    e2uHash['sdot']= '\u22C5';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2430
    e2uHash['lceil']= '\u2308';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2431
    e2uHash['rceil']= '\u2309';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2432
    e2uHash['lfloor']= '\u230A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2433
    e2uHash['rfloor']= '\u230B';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2434
    e2uHash['lang']= '\u2329';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2435
    e2uHash['rang']= '\u232A';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2436
    e2uHash['loz']= '\u25CA';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2437
    e2uHash['spades']= '\u2660';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2438
    e2uHash['clubs']= '\u2663';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2439
    e2uHash['hearts']= '\u2665';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2440
    e2uHash['diams']= '\u2666';
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  2441
})();
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2442
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2443
SimileAjax.HTML.deEntify = function(s) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2444
    var e2uHash = SimileAjax.HTML._e2uHash;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2445
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2446
    var re = /&(\w+?);/;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2447
    while (re.test(s)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2448
        var m = s.match(re);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2449
        s = s.replace(re, e2uHash[m[1]]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2450
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2451
    return s;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2452
};/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2453
 * 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
  2454
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2455
 * @constructor
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2456
 * @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
  2457
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2458
SimileAjax.Set = function(a) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2459
    this._hash = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2460
    this._count = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2461
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2462
    if (a instanceof Array) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2463
        for (var i = 0; i < a.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2464
            this.add(a[i]);
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
    } else if (a instanceof SimileAjax.Set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2467
        this.addSet(a);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2468
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2469
}
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2472
 * 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
  2473
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2474
 * @param {Object} o the object to add
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2475
 * @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
  2476
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2477
SimileAjax.Set.prototype.add = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2478
    if (!(o in this._hash)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2479
        this._hash[o] = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2480
        this._count++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2481
        return true;
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
    return false;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2486
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2487
 * 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
  2488
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2489
 * @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
  2490
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2491
SimileAjax.Set.prototype.addSet = function(set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2492
    for (var o in set._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2493
        this.add(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2494
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2495
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2496
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
 * Removes the given element from this set
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2499
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2500
 * @param {Object} o the object to remove
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2501
 * @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
  2502
 *   false otherwise
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
SimileAjax.Set.prototype.remove = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2505
    if (o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2506
        delete this._hash[o];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2507
        this._count--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2508
        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2509
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2510
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2511
}
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2514
 * 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
  2515
 * given set
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
 * @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
  2518
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2519
SimileAjax.Set.prototype.removeSet = function(set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2520
    for (var o in set._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2521
        this.remove(o);
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
}
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2526
 * 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
  2527
 * 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
  2528
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2529
 * @param {SimileAjax.Set} set the set to intersect
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
SimileAjax.Set.prototype.retainSet = function(set) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2532
    for (var o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2533
        if (!set.contains(o)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2534
            delete this._hash[o];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2535
            this._count--;
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2538
}
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2541
 * 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
  2542
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2543
 * @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
  2544
 * @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
  2545
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2546
SimileAjax.Set.prototype.contains = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2547
    return (o in this._hash);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2550
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2551
 * Returns the number of elements in this set
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
 * @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
  2554
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2555
SimileAjax.Set.prototype.size = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2556
    return this._count;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2559
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2560
 * 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
  2561
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2562
 * @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
  2563
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2564
SimileAjax.Set.prototype.toArray = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2565
    var a = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2566
    for (var o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2567
        a.push(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2568
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2569
    return a;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2570
}
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2573
 * 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
  2574
 * 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
  2575
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2576
 * @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
  2577
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2578
SimileAjax.Set.prototype.visit = function(f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2579
    for (var o in this._hash) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2580
        if (f(o) == true) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2581
            break;
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
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2586
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2587
 * A sorted array data structure
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
 * @constructor
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2590
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2591
SimileAjax.SortedArray = function(compare, initialArray) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2592
    this._a = (initialArray instanceof Array) ? initialArray : [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2593
    this._compare = compare;
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
SimileAjax.SortedArray.prototype.add = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2597
    var sa = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2598
    var index = this.find(function(elmt2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2599
        return sa._compare(elmt2, 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
    if (index < this._a.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2603
        this._a.splice(index, 0, elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2604
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2605
        this._a.push(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2606
    }
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
SimileAjax.SortedArray.prototype.remove = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2610
    var sa = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2611
    var index = this.find(function(elmt2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2612
        return sa._compare(elmt2, elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2613
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2614
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2615
    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
  2616
        if (this._a[index] == elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2617
            this._a.splice(index, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2618
            return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2619
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2620
            index++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2621
        }
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
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2624
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2625
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2626
SimileAjax.SortedArray.prototype.removeAll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2627
    this._a = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2628
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2629
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2630
SimileAjax.SortedArray.prototype.elementAt = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2631
    return this._a[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2632
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2633
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2634
SimileAjax.SortedArray.prototype.length = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2635
    return this._a.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2636
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2637
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2638
SimileAjax.SortedArray.prototype.find = function(compare) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2639
    var a = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2640
    var b = this._a.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2641
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2642
    while (a < b) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2643
        var mid = Math.floor((a + b) / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2644
        var c = compare(this._a[mid]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2645
        if (mid == a) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2646
            return c < 0 ? a+1 : a;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2647
        } else if (c < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2648
            a = mid;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2649
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2650
            b = mid;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2651
        }
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
    return a;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2654
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2655
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2656
SimileAjax.SortedArray.prototype.getFirst = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2657
    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
  2658
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2659
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2660
SimileAjax.SortedArray.prototype.getLast = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2661
    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
  2662
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2663
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2664
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2665
 *  Event Index
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2666
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2667
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2668
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2669
SimileAjax.EventIndex = function(unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2670
    var eventIndex = this;
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._unit = (unit != null) ? unit : SimileAjax.NativeDateUnit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2673
    this._events = new SimileAjax.SortedArray(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2674
        function(event1, event2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2675
            return eventIndex._unit.compare(event1.getStart(), event2.getStart());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2676
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2677
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2678
    this._idToEvent = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2679
    this._indexed = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2680
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2681
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2682
SimileAjax.EventIndex.prototype.getUnit = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2683
    return this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2684
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2685
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2686
SimileAjax.EventIndex.prototype.getEvent = function(id) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2687
    return this._idToEvent[id];
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.add = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2691
    this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2692
    this._idToEvent[evt.getID()] = evt;
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.removeAll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2697
    this._events.removeAll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2698
    this._idToEvent = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2699
    this._indexed = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2700
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2701
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2702
SimileAjax.EventIndex.prototype.getCount = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2703
    return this._events.length();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2704
};
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
SimileAjax.EventIndex.prototype.getIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2707
    if (!this._indexed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2708
        this._index();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2709
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2710
    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
  2711
};
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
SimileAjax.EventIndex.prototype.getReverseIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2714
    if (!this._indexed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2715
        this._index();
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
    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
  2718
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2719
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2720
SimileAjax.EventIndex.prototype.getAllIterator = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2721
    return new SimileAjax.EventIndex._AllIterator(this._events);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2724
SimileAjax.EventIndex.prototype.getEarliestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2725
    var evt = this._events.getFirst();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2726
    return (evt == null) ? null : evt.getStart();
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
SimileAjax.EventIndex.prototype.getLatestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2730
    var evt = this._events.getLast();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2731
    if (evt == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2732
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2733
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2734
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2735
    if (!this._indexed) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2736
        this._index();
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
    var index = evt._earliestOverlapIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2740
    var date = this._events.elementAt(index).getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2741
    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
  2742
        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
  2743
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2744
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2745
    return date;
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
SimileAjax.EventIndex.prototype._index = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2749
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2750
     *  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
  2751
     *  event that overlaps with it, if any.
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 l = this._events.length();
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
        evt._earliestOverlapIndex = i;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2760
    var toIndex = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2761
    for (var i = 0; i < l; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2762
        var evt = this._events.elementAt(i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2763
        var end = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2764
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2765
        toIndex = Math.max(toIndex, i + 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2766
        while (toIndex < l) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2767
            var evt2 = this._events.elementAt(toIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2768
            var start2 = evt2.getStart();
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
            if (this._unit.compare(start2, end) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2771
                evt2._earliestOverlapIndex = i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2772
                toIndex++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2773
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2774
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2775
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2776
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2777
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2778
    this._indexed = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2779
};
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
SimileAjax.EventIndex._Iterator = function(events, startDate, endDate, unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2782
    this._events = events;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2783
    this._startDate = startDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2784
    this._endDate = endDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2785
    this._unit = unit;
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 = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2788
        return unit.compare(evt.getStart(), startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2789
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2790
    if (this._currentIndex - 1 >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2791
        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
  2792
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2793
    this._currentIndex--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2794
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2795
    this._maxIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2796
        return unit.compare(evt.getStart(), endDate);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2799
    this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2800
    this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2801
    this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2802
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2803
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2804
SimileAjax.EventIndex._Iterator.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2805
    hasNext: function() { return this._hasNext; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2806
    next: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2807
        if (this._hasNext) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2808
            var next = this._next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2809
            this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2810
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2811
            return next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2812
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2813
            return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2814
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2815
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2816
    _findNext: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2817
        var unit = this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2818
        while ((++this._currentIndex) < this._maxIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2819
            var evt = this._events.elementAt(this._currentIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2820
            if (unit.compare(evt.getStart(), this._endDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2821
                unit.compare(evt.getEnd(), this._startDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2822
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2823
                this._next = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2824
                this._hasNext = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2825
                return;
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
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2828
        this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2829
        this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2830
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2831
};
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
SimileAjax.EventIndex._ReverseIterator = function(events, startDate, endDate, unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2834
    this._events = events;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2835
    this._startDate = startDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2836
    this._endDate = endDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2837
    this._unit = unit;
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
    this._minIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2840
        return unit.compare(evt.getStart(), startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2841
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2842
    if (this._minIndex - 1 >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2843
        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
  2844
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2845
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2846
    this._maxIndex = events.find(function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2847
        return unit.compare(evt.getStart(), endDate);
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
    this._currentIndex = this._maxIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2851
    this._hasNext = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2852
    this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2853
    this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2854
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2855
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2856
SimileAjax.EventIndex._ReverseIterator.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2857
    hasNext: function() { return this._hasNext; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2858
    next: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2859
        if (this._hasNext) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2860
            var next = this._next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2861
            this._findNext();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2862
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2863
            return next;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2864
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2865
            return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2866
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2867
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2868
    _findNext: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2869
        var unit = this._unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2870
        while ((--this._currentIndex) >= this._minIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2871
            var evt = this._events.elementAt(this._currentIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2872
            if (unit.compare(evt.getStart(), this._endDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2873
                unit.compare(evt.getEnd(), this._startDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2874
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2875
                this._next = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2876
                this._hasNext = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2877
                return;
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
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2880
        this._next = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2881
        this._hasNext = false;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2885
SimileAjax.EventIndex._AllIterator = function(events) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2886
    this._events = events;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2887
    this._index = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2888
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2889
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2890
SimileAjax.EventIndex._AllIterator.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2891
    hasNext: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2892
        return this._index < this._events.length();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2893
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2894
    next: function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2895
        return this._index < this._events.length() ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2896
            this._events.elementAt(this._index++) : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2897
    }
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2898
};/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2899
 *  Default Unit
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2900
 *
1156
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 = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2904
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2905
SimileAjax.NativeDateUnit.makeDefaultValue = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2906
    return new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2907
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2908
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2909
SimileAjax.NativeDateUnit.cloneValue = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2910
    return new Date(v.getTime());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2911
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2912
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2913
SimileAjax.NativeDateUnit.getParser = function(format) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2914
    if (typeof format == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2915
        format = format.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2916
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2917
    return (format == "iso8601" || format == "iso 8601") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2918
        SimileAjax.DateTime.parseIso8601DateTime : 
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2919
        SimileAjax.DateTime.parseGregorianDateTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2920
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2921
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2922
SimileAjax.NativeDateUnit.parseFromObject = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2923
    return SimileAjax.DateTime.parseGregorianDateTime(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2924
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2925
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2926
SimileAjax.NativeDateUnit.toNumber = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2927
    return v.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2928
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2929
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2930
SimileAjax.NativeDateUnit.fromNumber = function(n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2931
    return new Date(n);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2932
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2933
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2934
SimileAjax.NativeDateUnit.compare = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2935
    var n1, n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2936
    if (typeof v1 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2937
        n1 = v1.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2938
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2939
        n1 = Number(v1);
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
    if (typeof v2 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2942
        n2 = v2.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2943
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2944
        n2 = Number(v2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2945
    }
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
    return n1 - n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2948
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2949
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2950
SimileAjax.NativeDateUnit.earlier = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2951
    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
  2952
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2953
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2954
SimileAjax.NativeDateUnit.later = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2955
    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
  2956
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2957
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2958
SimileAjax.NativeDateUnit.change = function(v, n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2959
    return new Date(v.getTime() + n);
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2962
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2963
 *  General, miscellaneous SimileAjax stuff
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  2964
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2967
SimileAjax.ListenerQueue = function(wildcardHandlerName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2968
    this._listeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2969
    this._wildcardHandlerName = wildcardHandlerName;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2970
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2971
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2972
SimileAjax.ListenerQueue.prototype.add = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2973
    this._listeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2974
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2975
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2976
SimileAjax.ListenerQueue.prototype.remove = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2977
    var listeners = this._listeners;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2978
    for (var i = 0; i < listeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2979
        if (listeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2980
            listeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2981
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2982
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2983
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2984
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2985
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2986
SimileAjax.ListenerQueue.prototype.fire = function(handlerName, args) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2987
    var listeners = [].concat(this._listeners);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2988
    for (var i = 0; i < listeners.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2989
        var listener = listeners[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2990
        if (handlerName in listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2991
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2992
                listener[handlerName].apply(listener, args);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2993
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2994
                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
  2995
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2996
        } else if (this._wildcardHandlerName != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2997
            this._wildcardHandlerName in listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2998
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  2999
                listener[this._wildcardHandlerName].apply(listener, [ handlerName ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3000
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3001
                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
  3002
            }
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3005
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3006
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3007
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3008
 *  History
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3009
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3010
 *  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
  3011
 *  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
  3012
 *  Forward buttons.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3013
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3014
 *  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
  3015
 *  must have 4 fields:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3016
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3017
 *      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
  3018
 *      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
  3019
 *      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
  3020
 *      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
  3021
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3022
 *  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
  3023
 *  configure this behavior by setting
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3024
 *      SimileAjax.History.maxHistoryLength
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3025
 *  to a different number.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3026
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3027
 *  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
  3028
 *  onload events.
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3029
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3032
SimileAjax.History = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3033
    maxHistoryLength:       10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3034
    historyFile:            "__history__.html",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3035
    enabled:               true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3036
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3037
    _initialized:           false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3038
    _listeners:             new SimileAjax.ListenerQueue(),
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
    _actions:               [],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3041
    _baseIndex:             0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3042
    _currentIndex:          0,
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
    _plainDocumentTitle:    document.title
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3045
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3046
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3047
SimileAjax.History.formatHistoryEntryTitle = function(actionLabel) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3048
    return SimileAjax.History._plainDocumentTitle + " {" + actionLabel + "}";
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3051
SimileAjax.History.initialize = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3052
    if (SimileAjax.History._initialized) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3053
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3054
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3055
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3056
    if (SimileAjax.History.enabled) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3057
        var iframe = document.createElement("iframe");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3058
        iframe.id = "simile-ajax-history";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3059
        iframe.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3060
        iframe.style.width = "10px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3061
        iframe.style.height = "10px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3062
        iframe.style.top = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3063
        iframe.style.left = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3064
        iframe.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3065
        iframe.src = SimileAjax.History.historyFile + "?0";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3066
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3067
        document.body.appendChild(iframe);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3068
        SimileAjax.DOM.registerEvent(iframe, "load", SimileAjax.History._handleIFrameOnLoad);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3069
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3070
        SimileAjax.History._iframe = iframe;
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._initialized = true;
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.addListener = 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.add(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.removeListener = function(listener) {
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.remove(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3085
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3086
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3087
SimileAjax.History.addAction = function(action) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3088
    SimileAjax.History.initialize();
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
    SimileAjax.History._listeners.fire("onBeforePerform", [ action ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3091
    window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3092
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3093
            action.perform();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3094
            SimileAjax.History._listeners.fire("onAfterPerform", [ action ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3095
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3096
            if (SimileAjax.History.enabled) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3097
                SimileAjax.History._actions = SimileAjax.History._actions.slice(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3098
                    0, SimileAjax.History._currentIndex - SimileAjax.History._baseIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3099
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3100
                SimileAjax.History._actions.push(action);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3101
                SimileAjax.History._currentIndex++;
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
                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
  3104
                if (diff > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3105
                    SimileAjax.History._actions = SimileAjax.History._actions.slice(diff);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3106
                    SimileAjax.History._baseIndex += diff;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3109
                try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3110
                    SimileAjax.History._iframe.contentWindow.location.search =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3111
                        "?" + SimileAjax.History._currentIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3112
                } catch (e) {
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
                     *  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
  3115
                     *  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
  3116
                     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3117
                    var title = SimileAjax.History.formatHistoryEntryTitle(action.label);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3118
                    document.title = title;
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
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3122
            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
  3123
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3124
    }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3125
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3126
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3127
SimileAjax.History.addLengthyAction = function(perform, undo, label) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3128
    SimileAjax.History.addAction({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3129
        perform:    perform,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3130
        undo:       undo,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3131
        label:      label,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3132
        uiLayer:    SimileAjax.WindowManager.getBaseLayer(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3133
        lengthy:    true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3134
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3135
};
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
SimileAjax.History._handleIFrameOnLoad = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3138
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3139
     *  This function is invoked when the user herself
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3140
     *  navigates backward or forward. We need to adjust
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3141
     *  the application's state accordingly.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3142
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3143
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3144
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3145
        var q = SimileAjax.History._iframe.contentWindow.location.search;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3146
        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
  3147
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3148
        var finishUp = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3149
            var diff = c - SimileAjax.History._currentIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3150
            SimileAjax.History._currentIndex += diff;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3151
            SimileAjax.History._baseIndex += diff;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3152
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3153
            SimileAjax.History._iframe.contentWindow.location.search = "?" + c;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3154
        };
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
        if (c < SimileAjax.History._currentIndex) { // need to undo
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3157
            SimileAjax.History._listeners.fire("onBeforeUndoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3158
            window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3159
                while (SimileAjax.History._currentIndex > c &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3160
                       SimileAjax.History._currentIndex > SimileAjax.History._baseIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3161
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3162
                    SimileAjax.History._currentIndex--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3163
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3164
                    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
  3165
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3166
                    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3167
                        action.undo();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3168
                    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3169
                        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
  3170
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3171
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3172
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3173
                SimileAjax.History._listeners.fire("onAfterUndoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3174
                finishUp();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3175
            }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3176
        } 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
  3177
            SimileAjax.History._listeners.fire("onBeforeRedoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3178
            window.setTimeout(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3179
                while (SimileAjax.History._currentIndex < c &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3180
                       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
  3181
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3182
                    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
  3183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3184
                    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3185
                        action.perform();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3186
                    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3187
                        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
  3188
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3189
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3190
                    SimileAjax.History._currentIndex++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3191
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3192
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3193
                SimileAjax.History._listeners.fire("onAfterRedoSeveral", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3194
                finishUp();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3195
            }, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3196
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3197
            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
  3198
            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
  3199
                SimileAjax.History.formatHistoryEntryTitle(SimileAjax.History._actions[index].label) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3200
                SimileAjax.History._plainDocumentTitle;
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
            SimileAjax.History._iframe.contentWindow.document.title = title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3203
            document.title = title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3204
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3205
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3206
        // silent
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3207
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3208
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3209
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3210
SimileAjax.History.getNextUndoAction = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3211
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3212
        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
  3213
        return SimileAjax.History._actions[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3214
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3215
        return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3216
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3217
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3218
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3219
SimileAjax.History.getNextRedoAction = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3220
    try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3221
        var index = SimileAjax.History._currentIndex - SimileAjax.History._baseIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3222
        return SimileAjax.History._actions[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3223
    } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3224
        return null;
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3228
 * @fileOverview UI layers and window-wide dragging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3229
 * @name SimileAjax.WindowManager
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3230
 */
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
/**
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3233
 *  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
  3234
 *  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
  3235
 *  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
  3236
 *  implementation.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3237
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3238
SimileAjax.WindowManager = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3239
    _initialized:       false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3240
    _listeners:         [],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3241
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3242
    _draggedElement:                null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3243
    _draggedElementCallback:        null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3244
    _dropTargetHighlightElement:    null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3245
    _lastCoords:                    null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3246
    _ghostCoords:                   null,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3247
    _draggingMode:                  "",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3248
    _dragging:                      false,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3249
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3250
    _layers:            []
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3253
SimileAjax.WindowManager.initialize = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3254
    if (SimileAjax.WindowManager._initialized) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3255
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3256
    }
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.DOM.registerEvent(document.body, "mousedown", SimileAjax.WindowManager._onBodyMouseDown);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3259
    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
  3260
    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
  3261
    SimileAjax.DOM.registerEvent(document, "keydown",       SimileAjax.WindowManager._onBodyKeyDown);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3262
    SimileAjax.DOM.registerEvent(document, "keyup",         SimileAjax.WindowManager._onBodyKeyUp);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3263
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3264
    SimileAjax.WindowManager._layers.push({index: 0});
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
    SimileAjax.WindowManager._historyListener = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3267
        onBeforeUndoSeveral:    function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3268
        onAfterUndoSeveral:     function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3269
        onBeforeUndo:           function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3270
        onAfterUndo:            function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3271
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3272
        onBeforeRedoSeveral:    function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3273
        onAfterRedoSeveral:     function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3274
        onBeforeRedo:           function() {},
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3275
        onAfterRedo:            function() {}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3276
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3277
    SimileAjax.History.addListener(SimileAjax.WindowManager._historyListener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3278
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3279
    SimileAjax.WindowManager._initialized = true;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3282
SimileAjax.WindowManager.getBaseLayer = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3283
    SimileAjax.WindowManager.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3284
    return SimileAjax.WindowManager._layers[0];
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3287
SimileAjax.WindowManager.getHighestLayer = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3288
    SimileAjax.WindowManager.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3289
    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
  3290
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3291
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3292
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
  3293
    SimileAjax.WindowManager.registerEvent(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3294
        elmt,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3295
        eventName,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3296
        function(elmt2, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3297
            return obj[handlerName].call(obj, elmt2, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3298
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3299
        layer
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3303
SimileAjax.WindowManager.registerEvent = function(elmt, eventName, handler, layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3304
    if (layer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3305
        layer = SimileAjax.WindowManager.getHighestLayer();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3306
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3307
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3308
    var handler2 = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3309
        if (SimileAjax.WindowManager._canProcessEventAtLayer(layer)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3310
            SimileAjax.WindowManager._popToLayer(layer.index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3311
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3312
                handler(elmt, evt, target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3313
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3314
                SimileAjax.Debug.exception(e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3315
            }
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
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3318
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3319
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3320
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3321
    SimileAjax.DOM.registerEvent(elmt, eventName, handler2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3322
};
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
SimileAjax.WindowManager.pushLayer = function(f, ephemeral, elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3325
    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
  3326
    SimileAjax.WindowManager._layers.push(layer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3327
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3328
    return layer;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3329
};
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
SimileAjax.WindowManager.popLayer = function(layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3332
    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
  3333
        if (SimileAjax.WindowManager._layers[i] == layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3334
            SimileAjax.WindowManager._popToLayer(i - 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3335
            break;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3339
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3340
SimileAjax.WindowManager.popAllLayers = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3341
    SimileAjax.WindowManager._popToLayer(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3342
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3343
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3344
SimileAjax.WindowManager.registerForDragging = function(elmt, callback, layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3345
    SimileAjax.WindowManager.registerEvent(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3346
        elmt,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3347
        "mousedown",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3348
        function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3349
            SimileAjax.WindowManager._handleMouseDown(elmt, evt, callback);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3350
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3351
        layer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3352
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3353
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3354
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3355
SimileAjax.WindowManager._popToLayer = function(level) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3356
    while (level+1 < SimileAjax.WindowManager._layers.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3357
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3358
            var layer = SimileAjax.WindowManager._layers.pop();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3359
            if (layer.onPop != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3360
                layer.onPop();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3361
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3362
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3363
        }
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3366
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3367
SimileAjax.WindowManager._canProcessEventAtLayer = function(layer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3368
    if (layer.index == (SimileAjax.WindowManager._layers.length - 1)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3369
        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3370
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3371
    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
  3372
        if (!SimileAjax.WindowManager._layers[i].ephemeral) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3373
            return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3374
        }
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
    return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3377
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3378
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3379
SimileAjax.WindowManager.cancelPopups = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3380
    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
  3381
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3382
    var i = SimileAjax.WindowManager._layers.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3383
    while (i > 0 && SimileAjax.WindowManager._layers[i].ephemeral) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3384
        var layer = SimileAjax.WindowManager._layers[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3385
        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
  3386
            var elmt = layer.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3387
            var elmtCoords = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3388
            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
  3389
                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
  3390
                break;
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
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3393
        i--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3394
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3395
    SimileAjax.WindowManager._popToLayer(i);
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._onBodyMouseDown = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3399
    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
  3400
        SimileAjax.WindowManager.cancelPopups(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3401
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3404
SimileAjax.WindowManager._handleMouseDown = function(elmt, evt, callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3405
    SimileAjax.WindowManager._draggedElement = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3406
    SimileAjax.WindowManager._draggedElementCallback = callback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3407
    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
  3408
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3409
    SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3410
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3411
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3412
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3413
SimileAjax.WindowManager._onBodyKeyDown = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3414
    if (SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3415
        if (evt.keyCode == 27) { // esc
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3416
            SimileAjax.WindowManager._cancelDragging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3417
        } 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
  3418
            SimileAjax.WindowManager._draggingMode = "copy";
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
            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
  3421
            img.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3422
            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
  3423
            img.style.top = (SimileAjax.WindowManager._ghostCoords.top) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3424
            document.body.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3425
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3426
            SimileAjax.WindowManager._draggingModeIndicatorElmt = img;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3427
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3428
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3429
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3430
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3431
SimileAjax.WindowManager._onBodyKeyUp = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3432
    if (SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3433
        if (evt.keyCode == 17 || evt.keyCode == 16) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3434
            SimileAjax.WindowManager._draggingMode = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3435
            if (SimileAjax.WindowManager._draggingModeIndicatorElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3436
                document.body.removeChild(SimileAjax.WindowManager._draggingModeIndicatorElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3437
                SimileAjax.WindowManager._draggingModeIndicatorElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3438
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3439
        }
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3442
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3443
SimileAjax.WindowManager._onBodyMouseMove = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3444
    if (SimileAjax.WindowManager._draggedElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3445
        var callback = SimileAjax.WindowManager._draggedElementCallback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3446
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3447
        var lastCoords = SimileAjax.WindowManager._lastCoords;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3448
        var diffX = evt.clientX - lastCoords.x;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3449
        var diffY = evt.clientY - lastCoords.y;
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
        if (!SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3452
            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
  3453
                try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3454
                    if ("onDragStart" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3455
                        callback.onDragStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3456
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3457
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3458
                    if ("ghost" in callback && callback.ghost) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3459
                        var draggedElmt = SimileAjax.WindowManager._draggedElement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3460
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3461
                        SimileAjax.WindowManager._ghostCoords = SimileAjax.DOM.getPageCoordinates(draggedElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3462
                        SimileAjax.WindowManager._ghostCoords.left += diffX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3463
                        SimileAjax.WindowManager._ghostCoords.top += diffY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3464
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3465
                        var ghostElmt = draggedElmt.cloneNode(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3466
                        ghostElmt.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3467
                        ghostElmt.style.left = SimileAjax.WindowManager._ghostCoords.left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3468
                        ghostElmt.style.top = SimileAjax.WindowManager._ghostCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3469
                        ghostElmt.style.zIndex = 1000;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3470
                        SimileAjax.Graphics.setOpacity(ghostElmt, 50);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3471
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3472
                        document.body.appendChild(ghostElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3473
                        callback._ghostElmt = ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3474
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3475
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3476
                    SimileAjax.WindowManager._dragging = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3477
                    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
  3478
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3479
                    document.body.focus();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3480
                } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3481
                    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
  3482
                    SimileAjax.WindowManager._cancelDragging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3483
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3484
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3485
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3486
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3487
                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
  3488
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3489
                if ("onDragBy" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3490
                    callback.onDragBy(diffX, diffY);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3491
                }
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
                if ("_ghostElmt" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3494
                    var ghostElmt = callback._ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3495
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3496
                    SimileAjax.WindowManager._ghostCoords.left += diffX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3497
                    SimileAjax.WindowManager._ghostCoords.top += diffY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3498
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3499
                    ghostElmt.style.left = SimileAjax.WindowManager._ghostCoords.left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3500
                    ghostElmt.style.top = SimileAjax.WindowManager._ghostCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3501
                    if (SimileAjax.WindowManager._draggingModeIndicatorElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3502
                        var indicatorElmt = SimileAjax.WindowManager._draggingModeIndicatorElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3503
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3504
                        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
  3505
                        indicatorElmt.style.top = SimileAjax.WindowManager._ghostCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3506
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3507
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3508
                    if ("droppable" in callback && callback.droppable) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3509
                        var coords = SimileAjax.DOM.getEventPageCoordinates(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3510
                        var target = SimileAjax.DOM.hittest(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3511
                            coords.x, coords.y,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3512
                            [   SimileAjax.WindowManager._ghostElmt,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3513
                                SimileAjax.WindowManager._dropTargetHighlightElement
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3514
                            ]
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
                        target = SimileAjax.WindowManager._findDropTarget(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3517
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3518
                        if (target != SimileAjax.WindowManager._potentialDropTarget) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3519
                            if (SimileAjax.WindowManager._dropTargetHighlightElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3520
                                document.body.removeChild(SimileAjax.WindowManager._dropTargetHighlightElement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3521
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3522
                                SimileAjax.WindowManager._dropTargetHighlightElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3523
                                SimileAjax.WindowManager._potentialDropTarget = null;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3526
                            var droppable = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3527
                            if (target != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3528
                                if ((!("canDropOn" in callback) || callback.canDropOn(target)) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3529
                                    (!("canDrop" in target) || target.canDrop(SimileAjax.WindowManager._draggedElement))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3530
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3531
                                    droppable = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3532
                                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3533
                            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3534
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3535
                            if (droppable) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3536
                                var border = 4;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3537
                                var targetCoords = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3538
                                var highlight = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3539
                                highlight.style.border = border + "px solid yellow";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3540
                                highlight.style.backgroundColor = "yellow";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3541
                                highlight.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3542
                                highlight.style.left = targetCoords.left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3543
                                highlight.style.top = targetCoords.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3544
                                highlight.style.width = (target.offsetWidth - border * 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3545
                                highlight.style.height = (target.offsetHeight - border * 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3546
                                SimileAjax.Graphics.setOpacity(highlight, 30);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3547
                                document.body.appendChild(highlight);
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
                                SimileAjax.WindowManager._potentialDropTarget = target;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3550
                                SimileAjax.WindowManager._dropTargetHighlightElement = highlight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3551
                            }
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
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3556
                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
  3557
                SimileAjax.WindowManager._cancelDragging();
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3561
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3562
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3563
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3564
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3565
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3566
SimileAjax.WindowManager._onBodyMouseUp = function(elmt, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3567
    if (SimileAjax.WindowManager._draggedElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3568
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3569
            if (SimileAjax.WindowManager._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3570
                var callback = SimileAjax.WindowManager._draggedElementCallback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3571
                if ("onDragEnd" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3572
                    callback.onDragEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3573
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3574
                if ("droppable" in callback && callback.droppable) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3575
                    var dropped = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3576
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3577
                    var target = SimileAjax.WindowManager._potentialDropTarget;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3578
                    if (target != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3579
                        if ((!("canDropOn" in callback) || callback.canDropOn(target)) &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3580
                            (!("canDrop" in target) || target.canDrop(SimileAjax.WindowManager._draggedElement))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3581
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3582
                            if ("onDropOn" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3583
                                callback.onDropOn(target);
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
                            target.ondrop(SimileAjax.WindowManager._draggedElement, SimileAjax.WindowManager._draggingMode);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3586
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3587
                            dropped = true;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3591
                    if (!dropped) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3592
                        // TODO: do holywood explosion here
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
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3595
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3596
        } finally {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3597
            SimileAjax.WindowManager._cancelDragging();
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3600
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3601
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3602
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3603
};
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
SimileAjax.WindowManager._cancelDragging = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3606
    var callback = SimileAjax.WindowManager._draggedElementCallback;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3607
    if ("_ghostElmt" in callback) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3608
        var ghostElmt = callback._ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3609
        document.body.removeChild(ghostElmt);
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
        delete callback._ghostElmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3612
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3613
    if (SimileAjax.WindowManager._dropTargetHighlightElement != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3614
        document.body.removeChild(SimileAjax.WindowManager._dropTargetHighlightElement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3615
        SimileAjax.WindowManager._dropTargetHighlightElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3616
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3617
    if (SimileAjax.WindowManager._draggingModeIndicatorElmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3618
        document.body.removeChild(SimileAjax.WindowManager._draggingModeIndicatorElmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3619
        SimileAjax.WindowManager._draggingModeIndicatorElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3620
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3621
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3622
    SimileAjax.WindowManager._draggedElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3623
    SimileAjax.WindowManager._draggedElementCallback = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3624
    SimileAjax.WindowManager._potentialDropTarget = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3625
    SimileAjax.WindowManager._dropTargetHighlightElement = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3626
    SimileAjax.WindowManager._lastCoords = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3627
    SimileAjax.WindowManager._ghostCoords = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3628
    SimileAjax.WindowManager._draggingMode = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3629
    SimileAjax.WindowManager._dragging = false;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3632
SimileAjax.WindowManager._findDropTarget = function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3633
    while (elmt != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3634
        if ("ondrop" in elmt && (typeof elmt.ondrop) == "function") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3635
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3636
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3637
        elmt = elmt.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3638
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3639
    return elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3640
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3641
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3642
 *  Timeline API
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3643
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3644
 *  This file will load all the Javascript files
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3645
 *  necessary to make the standard timeline work.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3646
 *  It also detects the default locale.
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
 *  To run from the MIT copy of Timeline:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3649
 *  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
  3650
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3651
 *    <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
  3652
 *     type="text/javascript"></script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3653
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3654
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3655
 * 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
  3656
 *   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
  3657
 *      timeline_libraries.zip or timeline_source.zip
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3658
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3659
 *   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
  3660
 *        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
  3661
 *        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
  3662
 *            Include trailing slash
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3663
 *        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
  3664
 *                                               // timeline_libraries.zip since only the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3665
 *                                               // bundled libraries are included
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3666
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3667
 * eg your html page would include
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3668
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3669
 *   <script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3670
 *     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
  3671
 *     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
  3672
 *     var Timeline_parameters='bundle=true';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3673
 *   </script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3674
 *   <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
  3675
 *     type="text/javascript">
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3676
 *   </script>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3677
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3678
 * SCRIPT PARAMETERS
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3679
 * 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
  3680
 * 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
  3681
 * 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
  3682
 *     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
  3683
 *     <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
  3684
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3685
 * Parameters
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3686
 *   timeline-use-local-resources --
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3687
 *   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
  3688
 *   locales --
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3689
 *   defaultLocale --
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3690
 *   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
  3691
 *                  by browser's and server's locale settings.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3692
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3693
 * DEBUGGING
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3694
 * 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
  3695
 * To use the unbundled Timeline and Ajax libraries
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3696
 * Change
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3697
 *   <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
  3698
 * To
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3699
 *   <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
  3700
 *   <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
  3701
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3702
 * 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
  3703
 * 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
  3704
 *
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3705
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3706
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3707
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3708
(function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3709
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3710
    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
  3711
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3712
    var useLocalResources = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3713
    if (document.location.search.length > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3714
        var params = document.location.search.substr(1).split("&");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3715
        for (var i = 0; i < params.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3716
            if (params[i] == "timeline-use-local-resources") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3717
                useLocalResources = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3718
            }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3722
    var loadMe = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3723
        if ("Timeline" in window) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3724
            return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3725
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3726
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3727
        window.Timeline = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3728
        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
  3729
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3730
        var bundle = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3731
        var javascriptFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3732
            "timeline.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3733
            "band.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3734
            "themes.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3735
            "ethers.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3736
            "ether-painters.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3737
            "event-utils.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3738
            "labellers.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3739
            "sources.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3740
            "original-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3741
            "detailed-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3742
            "overview-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3743
            "compact-painter.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3744
            "decorators.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3745
            "units.js"
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 cssFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3748
            "timeline.css",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3749
            "ethers.css",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3750
            "events.css"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3751
        ];
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
        var localizedJavascriptFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3754
            "timeline.js",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3755
            "labellers.js"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3756
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3757
        var localizedCssFiles = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3758
        ];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3759
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3760
        // 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
  3761
        var supportedLocales = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3762
            "cs",       // Czech
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3763
            "de",       // German
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3764
            "en",       // English
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3765
            "es",       // Spanish
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3766
            "fr",       // French
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3767
            "it",       // Italian
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3768
            "nl",       // Dutch (The Netherlands)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3769
            "ru",       // Russian
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3770
            "se",       // Swedish
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3771
            "tr",       // Turkish
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3772
            "vi",       // Vietnamese
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3773
            "zh"        // Chinese
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3776
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3777
            var desiredLocales = [ "en" ],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3778
                defaultServerLocale = "en",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3779
                forceLocale = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3780
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3781
            var parseURLParameters = function(parameters) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3782
                var params = parameters.split("&");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3783
                for (var p = 0; p < params.length; p++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3784
                    var pair = params[p].split("=");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3785
                    if (pair[0] == "locales") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3786
                        desiredLocales = desiredLocales.concat(pair[1].split(","));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3787
                    } else if (pair[0] == "defaultLocale") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3788
                        defaultServerLocale = pair[1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3789
                    } else if (pair[0] == "forceLocale") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3790
                        forceLocale = pair[1];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3791
                        desiredLocales = desiredLocales.concat(pair[1].split(","));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3792
                    } else if (pair[0] == "bundle") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3793
                        bundle = pair[1] != "false";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3794
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3795
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3796
            };
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
            (function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3799
                if (typeof Timeline_urlPrefix == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3800
                    Timeline.urlPrefix = Timeline_urlPrefix;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3801
                    if (typeof Timeline_parameters == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3802
                        parseURLParameters(Timeline_parameters);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3803
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3804
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3805
                    var heads = document.documentElement.getElementsByTagName("head");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3806
                    for (var h = 0; h < heads.length; h++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3807
                        var scripts = heads[h].getElementsByTagName("script");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3808
                        for (var s = 0; s < scripts.length; s++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3809
                            var url = scripts[s].src;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3810
                            var i = url.indexOf("timeline-api.js");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3811
                            if (i >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3812
                                Timeline.urlPrefix = url.substr(0, i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3813
                                var q = url.indexOf("?");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3814
                                if (q > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3815
                                    parseURLParameters(url.substr(q + 1));
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
                                return;
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
                        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3820
                    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3821
                    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
  3822
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3823
            })();
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
            var includeJavascriptFiles = function(urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3826
                SimileAjax.includeJavascriptFiles(document, urlPrefix, filenames);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3827
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3828
            var includeCssFiles = function(urlPrefix, filenames) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3829
                SimileAjax.includeCssFiles(document, urlPrefix, filenames);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3830
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3831
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3832
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3833
             *  Include non-localized files
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3834
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3835
            if (bundle) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3836
                includeJavascriptFiles(Timeline.urlPrefix, [ "timeline-bundle.js" ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3837
                includeCssFiles(Timeline.urlPrefix, [ "timeline-bundle.css" ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3838
            } else {
2097
400bdbcc5699 [javascript] timeline is already bundled, don't try to include dynamically other js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1156
diff changeset
  3839
                // XXX adim includeJavascriptFiles(Timeline.urlPrefix + "scripts/", javascriptFiles);
400bdbcc5699 [javascript] timeline is already bundled, don't try to include dynamically other js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1156
diff changeset
  3840
                // XXX adim includeCssFiles(Timeline.urlPrefix + "styles/", cssFiles);
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3841
            }
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
            /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3844
             *  Include localized files
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3845
             */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3846
            var loadLocale = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3847
            loadLocale[defaultServerLocale] = 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
            var tryExactLocale = function(locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3850
                for (var l = 0; l < supportedLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3851
                    if (locale == supportedLocales[l]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3852
                        loadLocale[locale] = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3853
                        return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3854
                    }
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
                return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3857
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3858
            var tryLocale = function(locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3859
                if (tryExactLocale(locale)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3860
                    return locale;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3863
                var dash = locale.indexOf("-");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3864
                if (dash > 0 && tryExactLocale(locale.substr(0, dash))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3865
                    return locale.substr(0, dash);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3866
                }
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
                return null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3869
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3870
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3871
            for (var l = 0; l < desiredLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3872
                tryLocale(desiredLocales[l]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3873
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3874
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3875
            var defaultClientLocale = defaultServerLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3876
            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
  3877
            for (var l = 0; l < defaultClientLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3878
                var locale = tryLocale(defaultClientLocales[l]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3879
                if (locale != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3880
                    defaultClientLocale = locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3881
                    break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3882
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3883
            }
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
            for (var l = 0; l < supportedLocales.length; l++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3886
                var locale = supportedLocales[l];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3887
                if (loadLocale[locale]) {
2097
400bdbcc5699 [javascript] timeline is already bundled, don't try to include dynamically other js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1156
diff changeset
  3888
                    // XXX adim includeJavascriptFiles(Timeline.urlPrefix + "scripts/l10n/" + locale + "/", localizedJavascriptFiles);
400bdbcc5699 [javascript] timeline is already bundled, don't try to include dynamically other js files
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1156
diff changeset
  3889
                    // XXX adim includeCssFiles(Timeline.urlPrefix + "styles/l10n/" + locale + "/", localizedCssFiles);
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3890
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3891
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3892
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3893
            if (forceLocale == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3894
              Timeline.serverLocale = defaultServerLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3895
              Timeline.clientLocale = defaultClientLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3896
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3897
              Timeline.serverLocale = forceLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3898
              Timeline.clientLocale = forceLocale;
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
        } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3901
            alert(e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3902
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3903
    };
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
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3906
     *  Load SimileAjax if it's not already loaded
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3907
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3908
    if (typeof SimileAjax == "undefined") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3909
        window.SimileAjax_onLoad = loadMe;
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 url = useLocalResources ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3912
            "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
  3913
            "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
  3914
        if (typeof Timeline_ajax_url == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3915
           url = Timeline_ajax_url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3916
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3917
        var createScriptElement = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3918
            var script = document.createElement("script");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3919
            script.type = "text/javascript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3920
            script.language = "JavaScript";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3921
            script.src = url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3922
            document.getElementsByTagName("head")[0].appendChild(script);
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
        if (document.body == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3925
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3926
                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
  3927
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3928
                createScriptElement();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3929
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3930
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3931
            createScriptElement();
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3934
        loadMe();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3935
    }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
  3936
})();
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3937
/*
1156
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
 * Coding standards:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3940
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3941
 * We aim towards Douglas Crockford's Javascript conventions.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3942
 * See:  http://javascript.crockford.com/code.html
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3943
 * 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
  3944
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3945
 * 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
  3946
 * support libraries became widely used or available.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3947
 * 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
  3948
 * 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
  3949
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3950
 * 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
  3951
 * class variables.
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
 * 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
  3954
 * which enforce privacy in objects.
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
 * 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
  3957
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3958
 *
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3959
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3963
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3964
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3965
 *  Timeline VERSION
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3966
 *
1156
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
// 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
  3969
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
  3970
Timeline.ajax_lib_version = SimileAjax.version;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3971
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
  3972
 // cf method Timeline.writeVersion
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3973
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3974
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3975
 *  Timeline
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  3976
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3977
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3978
Timeline.strings = {}; // localization string tables
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3979
Timeline.HORIZONTAL = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3980
Timeline.VERTICAL = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3981
Timeline._defaultTheme = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3982
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3983
Timeline.getDefaultLocale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3984
    return Timeline.clientLocale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3985
};
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
Timeline.create = function(elmt, bandInfos, orientation, unit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3988
    if (Timeline.timelines == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3989
        Timeline.timelines = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3990
        // 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
  3991
        // 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
  3992
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3993
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3994
    var timelineID = Timeline.timelines.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3995
    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
  3996
    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
  3997
      timelineID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3998
    Timeline.timelines[timelineID] = new_tl;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  3999
    return new_tl;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4002
Timeline.createBandInfo = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4003
    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
  4004
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4005
    var eventSource = ("eventSource" in params) ? params.eventSource : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4006
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4007
    var etherParams = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4008
        interval:           SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4009
        pixelsPerInterval: params.intervalPixels,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4010
	theme: theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4011
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4012
    if ('startsOn' in params || 'endsOn' in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4013
	if ('startsOn' in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4014
	    etherParams.startsOn = params.startsOn;
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
	if ('endsOn' in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4017
	    etherParams.endsOn = params.endsOn;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4018
	}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4019
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4020
	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
  4021
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4022
    var ether = new Timeline.LinearEther(etherParams);
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
    var etherPainter = new Timeline.GregorianEtherPainter({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4025
        unit:       params.intervalUnit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4026
        multiple:   ("multiple" in params) ? params.multiple : 1,
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
        align:      ("align" in params) ? params.align : undefined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4029
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4030
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4031
    var eventPainterParams = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4032
        showText:   ("showEventText" in params) ? params.showEventText : true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4033
        theme:      theme
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
    // pass in custom parameters for the event painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4036
    if ("eventPainterParams" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4037
        for (var prop in params.eventPainterParams) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4038
            eventPainterParams[prop] = params.eventPainterParams[prop];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4039
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4040
    }
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
    if ("trackHeight" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4043
        eventPainterParams.trackHeight = params.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4044
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4045
    if ("trackGap" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4046
        eventPainterParams.trackGap = params.trackGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4047
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4048
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4049
    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
  4050
    var eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4051
    if ("eventPainter" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4052
        eventPainter = new params.eventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4053
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4054
        switch (layout) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4055
            case "overview" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4056
                eventPainter = new Timeline.OverviewEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4057
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4058
            case "detailed" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4059
                eventPainter = new Timeline.DetailedEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4060
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4061
            default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4062
                eventPainter = new Timeline.OriginalEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4063
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4064
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4065
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4066
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4067
        width:          params.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4068
        eventSource:    eventSource,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4069
        timeZone:       ("timeZone" in params) ? params.timeZone : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4070
        ether:          ether,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4071
        etherPainter:   etherPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4072
        eventPainter:   eventPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4073
        theme:          theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4074
        zoomIndex:      ("zoomIndex" in params) ? params.zoomIndex : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4075
        zoomSteps:      ("zoomSteps" in params) ? params.zoomSteps : null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4076
    };
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4079
Timeline.createHotZoneBandInfo = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4080
    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
  4081
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4082
    var eventSource = ("eventSource" in params) ? params.eventSource : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4083
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4084
    var ether = new Timeline.HotZoneEther({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4085
        centersOn:          ("date" in params) ? params.date : new Date(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4086
        interval:           SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4087
        pixelsPerInterval:  params.intervalPixels,
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
    });
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
    var etherPainter = new Timeline.HotZoneGregorianEtherPainter({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4093
        unit:       params.intervalUnit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4094
        zones:      params.zones,
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
        align:      ("align" in params) ? params.align : undefined
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4097
    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4098
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4099
    var eventPainterParams = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4100
        showText:   ("showEventText" in params) ? params.showEventText : true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4101
        theme:      theme
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
    // pass in custom parameters for the event painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4104
    if ("eventPainterParams" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4105
        for (var prop in params.eventPainterParams) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4106
            eventPainterParams[prop] = params.eventPainterParams[prop];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4107
        }
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
    if ("trackHeight" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4110
        eventPainterParams.trackHeight = params.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4111
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4112
    if ("trackGap" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4113
        eventPainterParams.trackGap = params.trackGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4114
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4115
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4116
    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
  4117
    var eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4118
    if ("eventPainter" in params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4119
        eventPainter = new params.eventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4120
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4121
        switch (layout) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4122
            case "overview" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4123
                eventPainter = new Timeline.OverviewEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4124
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4125
            case "detailed" :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4126
                eventPainter = new Timeline.DetailedEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4127
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4128
            default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4129
                eventPainter = new Timeline.OriginalEventPainter(eventPainterParams);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4130
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4131
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4132
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4133
        width:          params.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4134
        eventSource:    eventSource,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4135
        timeZone:       ("timeZone" in params) ? params.timeZone : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4136
        ether:          ether,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4137
        etherPainter:   etherPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4138
        eventPainter:   eventPainter,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4139
        theme:          theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4140
        zoomIndex:      ("zoomIndex" in params) ? params.zoomIndex : 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4141
        zoomSteps:      ("zoomSteps" in params) ? params.zoomSteps : null
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
};
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
Timeline.getDefaultTheme = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4146
    if (Timeline._defaultTheme == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4147
        Timeline._defaultTheme = Timeline.ClassicTheme.create(Timeline.getDefaultLocale());
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
    return Timeline._defaultTheme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4150
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4151
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4152
Timeline.setDefaultTheme = function(theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4153
    Timeline._defaultTheme = theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4154
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4155
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4156
Timeline.loadXML = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4157
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4158
        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
  4159
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4160
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4161
        var xml = xmlhttp.responseXML;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4162
        if (!xml.documentElement && xmlhttp.responseStream) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4163
            xml.load(xmlhttp.responseStream);
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
        f(xml, url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4166
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4167
    SimileAjax.XmlHttp.get(url, fError, fDone);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4170
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4171
Timeline.loadJSON = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4172
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4173
        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
  4174
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4175
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4176
        f(eval('(' + xmlhttp.responseText + ')'), url);
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
    SimileAjax.XmlHttp.get(url, fError, fDone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4179
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4180
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4181
Timeline.getTimelineFromID = function(timelineID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4182
    return Timeline.timelines[timelineID];
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
// 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
  4186
Timeline.writeVersion = function(el_id) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4187
  document.getElementById(el_id).innerHTML = this.display_version;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4191
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  4192
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4193
 *  Timeline Implementation object
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  4194
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4195
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4196
Timeline._Impl = function(elmt, bandInfos, orientation, unit, timelineID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4197
    SimileAjax.WindowManager.initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4198
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4199
    this._containerDiv = elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4200
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4201
    this._bandInfos = bandInfos;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4202
    this._orientation = orientation == null ? Timeline.HORIZONTAL : orientation;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4203
    this._unit = (unit != null) ? unit : SimileAjax.NativeDateUnit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4204
    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
  4205
                           // functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4206
    this._autoResizing = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4207
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4208
    // 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
  4209
    this.autoWidth = bandInfos && bandInfos[0] && bandInfos[0].theme &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4210
                     bandInfos[0].theme.autoWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4211
    this.autoWidthAnimationTime = bandInfos && bandInfos[0] && bandInfos[0].theme &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4212
                     bandInfos[0].theme.autoWidthAnimationTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4213
    this.timelineID = timelineID; // also public attribute
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4214
    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
  4215
                     bandInfos[0].theme.timeline_start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4216
    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
  4217
                     bandInfos[0].theme.timeline_stop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4218
    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
  4219
    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
  4220
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4221
    this._initialize();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4222
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4223
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
// Public functions used by client sw
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4226
//
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4227
Timeline._Impl.prototype.dispose = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4228
    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
  4229
        this._bands[i].dispose();
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
    this._bands = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4232
    this._bandInfos = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4233
    this._containerDiv.innerHTML = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4234
    // remove from array of Timelines
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4235
    Timeline.timelines[this.timelineID] = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4236
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4237
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4238
Timeline._Impl.prototype.getBandCount = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4239
    return this._bands.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4240
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4241
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4242
Timeline._Impl.prototype.getBand = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4243
    return this._bands[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4244
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4245
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4246
Timeline._Impl.prototype.finishedEventLoading = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4247
    // 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
  4248
    // Only used if the client has set autoWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4249
    // 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
  4250
    // need be.
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._starting = false;
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.layout = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4256
    // called by client when browser is resized
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4257
    this._autoWidthCheck(true);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4258
    this._distributeWidths();
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.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4262
    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
  4263
        this._bands[i].paint();
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4266
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4267
Timeline._Impl.prototype.getDocument = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4268
    return this._containerDiv.ownerDocument;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4269
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4270
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4271
Timeline._Impl.prototype.addDiv = function(div) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4272
    this._containerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4273
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4274
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4275
Timeline._Impl.prototype.removeDiv = function(div) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4276
    this._containerDiv.removeChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4277
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4278
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4279
Timeline._Impl.prototype.isHorizontal = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4280
    return this._orientation == Timeline.HORIZONTAL;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4281
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4282
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4283
Timeline._Impl.prototype.isVertical = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4284
    return this._orientation == Timeline.VERTICAL;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4287
Timeline._Impl.prototype.getPixelLength = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4288
    return this._orientation == Timeline.HORIZONTAL ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4289
        this._containerDiv.offsetWidth : this._containerDiv.offsetHeight;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4292
Timeline._Impl.prototype.getPixelWidth = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4293
    return this._orientation == Timeline.VERTICAL ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4294
        this._containerDiv.offsetWidth : this._containerDiv.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4295
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4296
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4297
Timeline._Impl.prototype.getUnit = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4298
    return this._unit;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4301
Timeline._Impl.prototype.getWidthStyle = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4302
    // 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
  4303
    return this._orientation == Timeline.HORIZONTAL ? 'height' : 'width';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4304
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4305
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4306
Timeline._Impl.prototype.loadXML = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4307
    var tl = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4308
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4309
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4310
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4311
        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
  4312
        tl.hideLoadingMessage();
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
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4315
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4316
            var xml = xmlhttp.responseXML;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4317
            if (!xml.documentElement && xmlhttp.responseStream) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4318
                xml.load(xmlhttp.responseStream);
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
            f(xml, url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4321
        } finally {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4322
            tl.hideLoadingMessage();
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
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4325
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4326
    this.showLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4327
    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
  4328
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4329
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4330
Timeline._Impl.prototype.loadJSON = function(url, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4331
    var tl = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4332
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4333
    var fError = function(statusText, status, xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4334
        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
  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
    var fDone = function(xmlhttp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4338
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4339
            f(eval('(' + xmlhttp.responseText + ')'), url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4340
        } finally {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4341
            tl.hideLoadingMessage();
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
    this.showLoadingMessage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4346
    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
  4347
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4348
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4349
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
// Private functions used by Timeline object functions
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4352
//
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4353
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4354
Timeline._Impl.prototype._autoWidthScrollListener = function(band) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4355
    band.getTimeline()._autoWidthCheck(false);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4356
};
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
// 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
  4359
Timeline._Impl.prototype._autoWidthCheck = function(okToShrink) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4360
    var timeline = this; // this Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4361
    var immediateChange = timeline._starting;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4362
    var newWidth = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4363
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4364
    function changeTimelineWidth() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4365
        var widthStyle = timeline.getWidthStyle();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4366
        if (immediateChange) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4367
            timeline._containerDiv.style[widthStyle] = newWidth + 'px';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4368
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4369
        	  // animate change
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4370
        	  timeline._autoResizing = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4371
        	  var animateParam ={};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4372
        	  animateParam[widthStyle] = newWidth + 'px';
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
        	  SimileAjax.jQuery(timeline._containerDiv).animate(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4375
        	      animateParam, timeline.autoWidthAnimationTime,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4376
        	      'linear', function(){timeline._autoResizing = false;});
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4379
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4380
    function checkTimelineWidth() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4381
        var targetWidth = 0; // the new desired width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4382
        var currentWidth = timeline.getPixelWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4383
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4384
        if (timeline._autoResizing) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4385
        	return; // early return
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
        // compute targetWidth
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4389
        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
  4390
            timeline._bands[i].checkAutoWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4391
            targetWidth += timeline._bandInfos[i].width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4392
        }
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
        if (targetWidth > currentWidth || okToShrink) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4395
            // yes, let's change the size
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4396
            newWidth = targetWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4397
            changeTimelineWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4398
            timeline._distributeWidths();
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4402
    // function's mainline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4403
    if (!timeline.autoWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4404
        return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4405
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4406
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4407
    checkTimelineWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4408
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4409
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4410
Timeline._Impl.prototype._initialize = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4411
    var containerDiv = this._containerDiv;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4412
    var doc = containerDiv.ownerDocument;
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
    containerDiv.className =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4415
        containerDiv.className.split(" ").concat("timeline-container").join(" ");
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
	 * 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
  4419
	 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4420
	var orientation = (this.isHorizontal()) ? 'horizontal' : 'vertical'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4421
	containerDiv.className +=' timeline-'+orientation;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4424
    while (containerDiv.firstChild) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4425
        containerDiv.removeChild(containerDiv.firstChild);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4426
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4427
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4428
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4429
     *  inserting copyright and link to simile
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
    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
  4432
    elmtCopyright.className = "timeline-copyright";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4433
    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
  4434
    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
  4435
    containerDiv.appendChild(elmtCopyright);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4436
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4437
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4438
     *  creating bands
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4439
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4440
    this._bands = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4441
    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
  4442
        var bandInfo = this._bandInfos[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4443
        var bandClass = bandInfo.bandClass || Timeline._Band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4444
        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
  4445
        this._bands.push(band);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4446
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4447
    this._distributeWidths();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4448
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4449
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4450
     *  sync'ing bands
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4451
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4452
    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
  4453
        var bandInfo = this._bandInfos[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4454
        if ("syncWith" in bandInfo) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4455
            this._bands[i].setSyncWithBand(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4456
                this._bands[bandInfo.syncWith],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4457
                ("highlight" in bandInfo) ? bandInfo.highlight : false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4458
            );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4459
        }
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
    if (this.autoWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4464
        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
  4465
            this._bands[i].addOnScrollListener(this._autoWidthScrollListener);
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4468
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4469
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
     *  creating loading UI
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4472
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4473
    var message = SimileAjax.Graphics.createMessageBubble(doc);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4474
    message.containerDiv.className = "timeline-message-container";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4475
    containerDiv.appendChild(message.containerDiv);
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
    message.contentDiv.className = "timeline-message";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4478
    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
  4479
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4480
    this.showLoadingMessage = function() { message.containerDiv.style.display = "block"; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4481
    this.hideLoadingMessage = function() { message.containerDiv.style.display = "none"; };
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4484
Timeline._Impl.prototype._distributeWidths = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4485
    var length = this.getPixelLength();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4486
    var width = this.getPixelWidth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4487
    var cumulativeWidth = 0;
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
    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
  4490
        var band = this._bands[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4491
        var bandInfos = this._bandInfos[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4492
        var widthString = bandInfos.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4493
        var bandWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4494
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4495
        if (typeof widthString == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4496
          var x =  widthString.indexOf("%");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4497
          if (x > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4498
              var percent = parseInt(widthString.substr(0, x));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4499
              bandWidth = Math.round(percent * width / 100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4500
          } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4501
              bandWidth = parseInt(widthString);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4502
          }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4503
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4504
        	// was given an integer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4505
        	bandWidth = widthString;
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
        band.setBandShiftAndWidth(cumulativeWidth, bandWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4509
        band.setViewLength(length);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4510
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4511
        cumulativeWidth += bandWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4512
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4513
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4514
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4515
Timeline._Impl.prototype.shiftOK = function(index, shift) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4516
    // Returns true if the proposed shift is ok
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4517
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4518
    // Positive shift means going back in time
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4519
    var going_back = shift > 0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4520
        going_forward = shift < 0;
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
    // Is there an edge?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4523
    if ((going_back    && this.timeline_start == null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4524
        (going_forward && this.timeline_stop  == null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4525
        (shift == 0)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4526
        return (true);  // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4527
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4528
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4529
    // 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
  4530
    // 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
  4531
    // 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
  4532
    // 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
  4533
    // as the bands adjust.)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4534
    var secondary_shift = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4535
    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
  4536
       secondary_shift = this._bands[i].busy();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4537
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4538
    if (secondary_shift) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4539
        return(true); // 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
    // 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
  4543
    if ((going_back    && this.timeline_at_start) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4544
        (going_forward && this.timeline_at_stop)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4545
        return (false);  // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4546
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4547
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4548
    // Need to check all the bands
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4549
    var ok = false; // return value
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4550
    // 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
  4551
    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
  4552
       var band = this._bands[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4553
       if (going_back) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4554
           ok = (i == index ? band.getMinVisibleDateAfterDelta(shift) : band.getMinVisibleDate())
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4555
                >= this.timeline_start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4556
       } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4557
           ok = (i == index ? band.getMaxVisibleDateAfterDelta(shift) : band.getMaxVisibleDate())
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4558
                <= this.timeline_stop;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4559
       }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4560
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4561
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4562
    // process results
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4563
    if (going_back) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4564
       this.timeline_at_start = !ok;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4565
       this.timeline_at_stop = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4566
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4567
       this.timeline_at_stop = !ok;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4568
       this.timeline_at_start = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4569
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4570
    // 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
  4571
    // edge of the Timeline. Eg jitter the Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4572
    //if (!ok) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4573
        //alert(going_back ? "At beginning" : "At end");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4574
    //}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4575
    return (ok);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4576
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4577
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4578
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
  4579
  var matcher = new RegExp("^timeline-band-([0-9]+)$");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4580
  var bandIndex = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4581
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4582
  var result = matcher.exec(target.id);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4583
  if (result) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4584
    bandIndex = parseInt(result[1]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4585
  }
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
  if (bandIndex != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4588
    this._bands[bandIndex].zoom(zoomIn, x, y, target);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4591
  this.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4592
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4593
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  4594
/*
1156
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
 * Coding standards:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4597
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4598
 * We aim towards Douglas Crockford's Javascript conventions.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4599
 * See:  http://javascript.crockford.com/code.html
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4600
 * 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
  4601
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4602
 * 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
  4603
 * support libraries became widely used or available.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4604
 * 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
  4605
 * 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
  4606
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4607
 * 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
  4608
 * class variables.
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
 * 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
  4611
 * which enforce privacy in objects.
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
 * 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
  4614
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4615
 *
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  4616
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4620
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  4621
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4622
 *  Band
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  4623
 *
1156
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
Timeline._Band = function(timeline, bandInfo, index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4626
    // hack for easier subclassing
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4627
    if (timeline !== undefined) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4628
        this.initialize(timeline, bandInfo, index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4629
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4630
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4631
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4632
Timeline._Band.prototype.initialize = function(timeline, bandInfo, index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4633
    // Set up the band's object
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
    // 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
  4636
    // bandInfo.width is an integer
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4637
    if (timeline.autoWidth && typeof bandInfo.width == 'string') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4638
        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
  4639
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4640
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4641
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4642
    this._bandInfo = bandInfo;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4643
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4644
    this._index = index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4645
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4646
    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
  4647
    this._timeZone = ("timeZone" in bandInfo) ? bandInfo.timeZone : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4648
    this._labeller = ("labeller" in bandInfo) ? bandInfo.labeller :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4649
        (("createLabeller" in timeline.getUnit()) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4650
            timeline.getUnit().createLabeller(this._locale, this._timeZone) :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4651
            new Timeline.GregorianDateLabeller(this._locale, this._timeZone));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4652
    this._theme = bandInfo.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4653
    this._zoomIndex = ("zoomIndex" in bandInfo) ? bandInfo.zoomIndex : 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4654
    this._zoomSteps = ("zoomSteps" in bandInfo) ? bandInfo.zoomSteps : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4655
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4656
    this._dragging = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4657
    this._changing = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4658
    this._originalScrollSpeed = 5; // pixels
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4659
    this._scrollSpeed = this._originalScrollSpeed;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4660
    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
  4661
    this._onScrollListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4662
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4663
    var b = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4664
    this._syncWithBand = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4665
    this._syncWithBandHandler = function(band) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4666
        b._onHighlightBandScroll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4667
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4668
    this._selectorListener = function(band) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4669
        b._onHighlightBandScroll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4670
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4671
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
     *  Install a textbox to capture keyboard events
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4674
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4675
    var inputDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4676
    inputDiv.className = "timeline-band-input";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4677
    this._timeline.addDiv(inputDiv);
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
    this._keyboardInput = document.createElement("input");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4680
    this._keyboardInput.type = "text";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4681
    inputDiv.appendChild(this._keyboardInput);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4682
    SimileAjax.DOM.registerEventWithObject(this._keyboardInput, "keydown", this, "_onKeyDown");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4683
    SimileAjax.DOM.registerEventWithObject(this._keyboardInput, "keyup", this, "_onKeyUp");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4684
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4685
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4686
     *  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
  4687
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4688
    this._div = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4689
    this._div.id = "timeline-band-" + index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4690
    this._div.className = "timeline-band timeline-band-" + index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4691
    this._timeline.addDiv(this._div);
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
    SimileAjax.DOM.registerEventWithObject(this._div, "mousedown", this, "_onMouseDown");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4694
    SimileAjax.DOM.registerEventWithObject(this._div, "mousemove", this, "_onMouseMove");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4695
    SimileAjax.DOM.registerEventWithObject(this._div, "mouseup", this, "_onMouseUp");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4696
    SimileAjax.DOM.registerEventWithObject(this._div, "mouseout", this, "_onMouseOut");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4697
    SimileAjax.DOM.registerEventWithObject(this._div, "dblclick", this, "_onDblClick");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4698
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4699
    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
  4700
    if (mouseWheel === 'zoom' || mouseWheel === 'scroll' || this._zoomSteps) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4701
        // capture mouse scroll
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4702
        if (SimileAjax.Platform.browser.isFirefox) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4703
            SimileAjax.DOM.registerEventWithObject(this._div, "DOMMouseScroll", this, "_onMouseScroll");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4704
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4705
            SimileAjax.DOM.registerEventWithObject(this._div, "mousewheel", this, "_onMouseScroll");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4706
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4707
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4708
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
     *  The inner div that contains layers
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4711
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4712
    this._innerDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4713
    this._innerDiv.className = "timeline-band-inner";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4714
    this._div.appendChild(this._innerDiv);
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
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4717
     *  Initialize parts of the band
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._ether = bandInfo.ether;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4720
    bandInfo.ether.initialize(this, timeline);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4721
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4722
    this._etherPainter = bandInfo.etherPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4723
    bandInfo.etherPainter.initialize(this, timeline);
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 = bandInfo.eventSource;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4726
    if (this._eventSource) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4727
        this._eventListener = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4728
            onAddMany: function() { b._onAddMany(); },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4729
            onClear:   function() { b._onClear(); }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4730
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4731
        this._eventSource.addListener(this._eventListener);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4734
    this._eventPainter = bandInfo.eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4735
    this._eventTracksNeeded = 0;   // set by painter via updateEventTrackInfo
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4736
    this._eventTrackIncrement = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4737
    bandInfo.eventPainter.initialize(this, timeline);
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
    this._decorators = ("decorators" in bandInfo) ? bandInfo.decorators : [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4740
    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
  4741
        this._decorators[i].initialize(this, timeline);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4742
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4745
Timeline._Band.SCROLL_MULTIPLES = 5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4746
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4747
Timeline._Band.prototype.dispose = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4748
    this.closeBubble();
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
    if (this._eventSource) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4751
        this._eventSource.removeListener(this._eventListener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4752
        this._eventListener = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4753
        this._eventSource = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4754
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4755
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4756
    this._timeline = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4757
    this._bandInfo = 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._labeller = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4760
    this._ether = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4761
    this._etherPainter = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4762
    this._eventPainter = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4763
    this._decorators = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4764
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4765
    this._onScrollListeners = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4766
    this._syncWithBandHandler = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4767
    this._selectorListener = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4768
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4769
    this._div = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4770
    this._innerDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4771
    this._keyboardInput = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4772
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4773
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4774
Timeline._Band.prototype.addOnScrollListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4775
    this._onScrollListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4776
};
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
Timeline._Band.prototype.removeOnScrollListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4779
    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
  4780
        if (this._onScrollListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4781
            this._onScrollListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4782
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4783
        }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4787
Timeline._Band.prototype.setSyncWithBand = function(band, highlight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4788
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4789
        this._syncWithBand.removeOnScrollListener(this._syncWithBandHandler);
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
    this._syncWithBand = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4793
    this._syncWithBand.addOnScrollListener(this._syncWithBandHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4794
    this._highlight = highlight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4795
    this._positionHighlight();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4796
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4797
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4798
Timeline._Band.prototype.getLocale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4799
    return this._locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4800
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4801
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4802
Timeline._Band.prototype.getTimeZone = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4803
    return this._timeZone;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4804
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4805
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4806
Timeline._Band.prototype.getLabeller = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4807
    return this._labeller;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4808
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4809
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4810
Timeline._Band.prototype.getIndex = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4811
    return this._index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4812
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4813
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4814
Timeline._Band.prototype.getEther = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4815
    return this._ether;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4816
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4817
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4818
Timeline._Band.prototype.getEtherPainter = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4819
    return this._etherPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4820
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4821
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4822
Timeline._Band.prototype.getEventSource = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4823
    return this._eventSource;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4824
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4825
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4826
Timeline._Band.prototype.getEventPainter = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4827
    return this._eventPainter;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4828
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4829
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4830
Timeline._Band.prototype.getTimeline = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4831
    return this._timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4832
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4833
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4834
// Autowidth support
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4835
Timeline._Band.prototype.updateEventTrackInfo = function(tracks, increment) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4836
    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
  4837
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4838
    if (tracks > this._eventTracksNeeded) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4839
        this._eventTracksNeeded = tracks;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4840
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4843
// Autowidth support
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4844
Timeline._Band.prototype.checkAutoWidth = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4845
    // 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
  4846
    // then: a) updates the band's bandInfo.width
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
    // desiredWidth for the band is
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4849
    //   (number of tracks + margin) * track increment
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4850
    if (! this._timeline.autoWidth) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4851
      return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4852
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4853
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4854
    var overviewBand = this._eventPainter.getType() == 'overview';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4855
    var margin = overviewBand ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4856
       this._theme.event.overviewTrack.autoWidthMargin :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4857
       this._theme.event.track.autoWidthMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4858
    var desiredWidth = Math.ceil((this._eventTracksNeeded + margin) *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4859
                       this._eventTrackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4860
    // add offset amount (additional margin)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4861
    desiredWidth += overviewBand ? this._theme.event.overviewTrack.offset :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4862
                                   this._theme.event.track.offset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4863
    var bandInfo = this._bandInfo;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4864
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4865
    if (desiredWidth != bandInfo.width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4866
        bandInfo.width = desiredWidth;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4869
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4870
Timeline._Band.prototype.layout = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4871
    this.paint();
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.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4875
    this._etherPainter.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4876
    this._paintDecorators();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4877
    this._paintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4878
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4879
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4880
Timeline._Band.prototype.softLayout = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4881
    this.softPaint();
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.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4885
    this._etherPainter.softPaint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4886
    this._softPaintDecorators();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4887
    this._softPaintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4888
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4889
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4890
Timeline._Band.prototype.setBandShiftAndWidth = function(shift, width) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4891
    var inputDiv = this._keyboardInput.parentNode;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4892
    var middle = shift + Math.floor(width / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4893
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4894
        this._div.style.top = shift + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4895
        this._div.style.height = 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.top = middle + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4898
        inputDiv.style.left = "-1em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4899
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4900
        this._div.style.left = shift + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4901
        this._div.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4902
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4903
        inputDiv.style.left = middle + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4904
        inputDiv.style.top = "-1em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4905
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4906
};
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
Timeline._Band.prototype.getViewWidth = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4909
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4910
        return this._div.offsetHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4911
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4912
        return this._div.offsetWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4913
    }
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.setViewLength = function(length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4917
    this._viewLength = length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4918
    this._recenterDiv();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4919
    this._onChanging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4920
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4921
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4922
Timeline._Band.prototype.getViewLength = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4923
    return this._viewLength;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4924
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4925
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4926
Timeline._Band.prototype.getTotalViewLength = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4927
    return Timeline._Band.SCROLL_MULTIPLES * this._viewLength;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4928
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4929
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4930
Timeline._Band.prototype.getViewOffset = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4931
    return this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4932
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4933
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4934
Timeline._Band.prototype.getMinDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4935
    return this._ether.pixelOffsetToDate(this._viewOffset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4936
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4937
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4938
Timeline._Band.prototype.getMaxDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4939
    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
  4940
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4941
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4942
Timeline._Band.prototype.getMinVisibleDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4943
    return this._ether.pixelOffsetToDate(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4944
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4945
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4946
Timeline._Band.prototype.getMinVisibleDateAfterDelta = function(delta) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4947
    return this._ether.pixelOffsetToDate(delta);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4950
Timeline._Band.prototype.getMaxVisibleDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4951
    // Max date currently visible on band
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4952
    return this._ether.pixelOffsetToDate(this._viewLength);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4955
Timeline._Band.prototype.getMaxVisibleDateAfterDelta = function(delta) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4956
    // 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
  4957
    return this._ether.pixelOffsetToDate(this._viewLength + delta);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4958
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4959
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4960
Timeline._Band.prototype.getCenterVisibleDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4961
    return this._ether.pixelOffsetToDate(this._viewLength / 2);
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.setMinVisibleDate = 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._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.setMaxVisibleDate = 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 - 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.setCenterVisibleDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4977
    if (!this._changing) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4978
        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
  4979
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4980
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4981
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4982
Timeline._Band.prototype.dateToPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4983
    return this._ether.dateToPixelOffset(date) - this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4984
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4985
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4986
Timeline._Band.prototype.pixelOffsetToDate = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4987
    return this._ether.pixelOffsetToDate(pixels + this._viewOffset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4988
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4989
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4990
Timeline._Band.prototype.getViewOrthogonalOffset = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4991
    return this._viewOrthogonalOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4992
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4993
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4994
Timeline._Band.prototype.setViewOrthogonalOffset = function(offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4995
    this._viewOrthogonalOffset = Math.max(0, offset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4996
};
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
Timeline._Band.prototype.createLayerDiv = function(zIndex, className) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  4999
    var div = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5000
    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
  5001
    div.style.zIndex = zIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5002
    this._innerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5003
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5004
    var innerDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5005
    innerDiv.className = "timeline-band-layer-inner";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5006
    if (SimileAjax.Platform.browser.isIE) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5007
        innerDiv.style.cursor = "move";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5008
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5009
        innerDiv.style.cursor = "-moz-grab";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5010
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5011
    div.appendChild(innerDiv);
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
    return innerDiv;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5014
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5015
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5016
Timeline._Band.prototype.removeLayerDiv = function(div) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5017
    this._innerDiv.removeChild(div.parentNode);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5018
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5019
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5020
Timeline._Band.prototype.scrollToCenter = function(date, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5021
    var pixelOffset = this._ether.dateToPixelOffset(date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5022
    if (pixelOffset < -this._viewLength / 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5023
        this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset + this._viewLength));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5024
    } else if (pixelOffset > 3 * this._viewLength / 2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5025
        this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset - this._viewLength));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5026
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5027
    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
  5028
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5029
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5030
Timeline._Band.prototype.showBubbleForEvent = function(eventID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5031
    var evt = this.getEventSource().getEvent(eventID);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5032
    if (evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5033
        var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5034
        this.scrollToCenter(evt.getStart(), function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5035
            self._eventPainter.showBubble(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5036
        });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5037
    }
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
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
  5041
  if (!this._zoomSteps) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5042
    // zoom disabled
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5043
    return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5044
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5045
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5046
  // shift the x value by our offset
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5047
  x += this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5048
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5049
  var zoomDate = this._ether.pixelOffsetToDate(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5050
  var netIntervalChange = this._ether.zoom(zoomIn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5051
  this._etherPainter.zoom(netIntervalChange);
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
  // shift our zoom date to the far left
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5054
  this._moveEther(Math.round(-this._ether.dateToPixelOffset(zoomDate)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5055
  // 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
  5056
  this._moveEther(x);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5057
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5058
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5059
Timeline._Band.prototype._onMouseDown = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5060
    this.closeBubble();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5061
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5062
    this._dragging = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5063
    this._dragX = evt.clientX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5064
    this._dragY = evt.clientY;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5067
Timeline._Band.prototype._onMouseMove = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5068
    if (this._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5069
        var diffX = evt.clientX - this._dragX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5070
        var diffY = evt.clientY - this._dragY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5071
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5072
        this._dragX = evt.clientX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5073
        this._dragY = evt.clientY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5074
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5075
        if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5076
            this._moveEther(diffX, diffY);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5077
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5078
            this._moveEther(diffY, diffX);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5079
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5080
        this._positionHighlight();
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5084
Timeline._Band.prototype._onMouseUp = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5085
    this._dragging = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5086
    this._keyboardInput.focus();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5087
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5088
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5089
Timeline._Band.prototype._onMouseOut = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5090
    var coords = SimileAjax.DOM.getEventRelativeCoordinates(evt, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5091
    coords.x += this._viewOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5092
    if (coords.x < 0 || coords.x > innerFrame.offsetWidth ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5093
        coords.y < 0 || coords.y > innerFrame.offsetHeight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5094
        this._dragging = false;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5097
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5098
Timeline._Band.prototype._onMouseScroll = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5099
  var now = new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5100
  now = now.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5101
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5102
  if (!this._lastScrollTime || ((now - this._lastScrollTime) > 50)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5103
    // 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
  5104
    this._lastScrollTime = now;
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
    var delta = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5107
    if (evt.wheelDelta) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5108
      delta = evt.wheelDelta/120;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5109
    } else if (evt.detail) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5110
      delta = -evt.detail/3;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5111
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5112
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5113
    // either scroll or zoom
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5114
    var mouseWheel = this._theme.mouseWheel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5115
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5116
    if (this._zoomSteps || mouseWheel === 'zoom') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5117
      var loc = SimileAjax.DOM.getEventRelativeCoordinates(evt, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5118
      if (delta != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5119
        var zoomIn;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5120
        if (delta > 0)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5121
          zoomIn = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5122
        if (delta < 0)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5123
          zoomIn = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5124
        // 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
  5125
        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
  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
    else if (mouseWheel === 'scroll') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5129
    	var move_amt = 50 * (delta < 0 ? -1 : 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5130
      this._moveEther(move_amt);
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
  }
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 bubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5135
  if (evt.stopPropagation) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5136
    evt.stopPropagation();
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.cancelBubble = true;
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
  // prevent the default action
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5141
  if (evt.preventDefault) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5142
    evt.preventDefault();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5143
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5144
  evt.returnValue = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5145
};
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
Timeline._Band.prototype._onDblClick = function(innerFrame, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5148
    var coords = SimileAjax.DOM.getEventRelativeCoordinates(evt, innerFrame);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5149
    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
  5150
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5151
    this._autoScroll(-distance);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5152
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5153
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5154
Timeline._Band.prototype._onKeyDown = function(keyboardInput, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5155
    if (!this._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5156
        switch (evt.keyCode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5157
        case 27: // ESC
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5158
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5159
        case 37: // left arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5160
        case 38: // up arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5161
            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
  5162
            this._moveEther(this._scrollSpeed);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5163
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5164
        case 39: // right arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5165
        case 40: // down arrow
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5166
            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
  5167
            this._moveEther(this._scrollSpeed);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5168
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5169
        default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5170
            return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5171
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5172
        this.closeBubble();
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
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5175
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5176
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5177
    return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5178
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5179
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5180
Timeline._Band.prototype._onKeyUp = function(keyboardInput, evt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5181
    if (!this._dragging) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5182
        this._scrollSpeed = this._originalScrollSpeed;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5183
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5184
        switch (evt.keyCode) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5185
        case 35: // end
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5186
            this.setCenterVisibleDate(this._eventSource.getLatestDate());
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 36: // home
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5189
            this.setCenterVisibleDate(this._eventSource.getEarliestDate());
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
        case 33: // page up
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5192
            this._autoScroll(this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5193
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5194
        case 34: // page down
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5195
            this._autoScroll(-this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5196
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5197
        default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5198
            return true;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5201
        this.closeBubble();
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
        SimileAjax.DOM.cancelEvent(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5204
        return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5205
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5206
    return true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5207
};
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
Timeline._Band.prototype._autoScroll = function(distance, f) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5210
    var b = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5211
    var a = SimileAjax.Graphics.createAnimation(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5212
        function(abs, diff) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5213
            b._moveEther(diff);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5214
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5215
        0,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5216
        distance,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5217
        1000,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5218
        f
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5219
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5220
    a.run();
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5223
Timeline._Band.prototype._moveEther = function(shift, orthogonalShift) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5224
    if (orthogonalShift === undefined) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5225
        orthogonalShift = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5226
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5227
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5228
    this.closeBubble();
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
    // A positive shift means back in time
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5231
    // 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
  5232
    if (!this._timeline.shiftOK(this._index, shift)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5233
        return; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5234
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5235
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5236
    this._viewOffset += shift;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5237
    this._viewOrthogonalOffset = Math.min(0, this._viewOrthogonalOffset + orthogonalShift);
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
    this._ether.shiftPixels(-shift);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5240
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5241
        this._div.style.left = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5242
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5243
        this._div.style.top = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5244
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5245
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5246
    if (this._viewOffset > -this._viewLength * 0.5 ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5247
        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
  5248
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5249
        this._recenterDiv();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5250
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5251
        this.softLayout();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5252
    }
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._onChanging();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5255
}
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
Timeline._Band.prototype._onChanging = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5258
    this._changing = true;
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
    this._fireOnScroll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5261
    this._setSyncWithBandDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5262
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5263
    this._changing = false;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5266
Timeline._Band.prototype.busy = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5267
    // Is this band busy changing other bands?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5268
    return(this._changing);
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._fireOnScroll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5272
    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
  5273
        this._onScrollListeners[i](this);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5274
    }
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
Timeline._Band.prototype._setSyncWithBandDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5278
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5279
        var centerDate = this._ether.pixelOffsetToDate(this.getViewLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5280
        this._syncWithBand.setCenterVisibleDate(centerDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5281
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5284
Timeline._Band.prototype._onHighlightBandScroll = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5285
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5286
        var centerDate = this._syncWithBand.getCenterVisibleDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5287
        var centerPixelOffset = this._ether.dateToPixelOffset(centerDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5288
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5289
        this._moveEther(Math.round(this._viewLength / 2 - centerPixelOffset));
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
        if (this._highlight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5292
            this._etherPainter.setHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5293
                this._syncWithBand.getMinVisibleDate(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5294
                this._syncWithBand.getMaxVisibleDate());
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5298
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5299
Timeline._Band.prototype._onAddMany = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5300
    this._paintEvents();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5301
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5302
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5303
Timeline._Band.prototype._onClear = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5304
    this._paintEvents();
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5307
Timeline._Band.prototype._positionHighlight = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5308
    if (this._syncWithBand) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5309
        var startDate = this._syncWithBand.getMinVisibleDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5310
        var endDate = this._syncWithBand.getMaxVisibleDate();
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
        if (this._highlight) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5313
            this._etherPainter.setHighlight(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5314
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5315
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5316
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5317
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5318
Timeline._Band.prototype._recenterDiv = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5319
    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
  5320
    if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5321
        this._div.style.left = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5322
        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
  5323
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5324
        this._div.style.top = this._viewOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5325
        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
  5326
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5327
    this.layout();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5328
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5329
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5330
Timeline._Band.prototype._paintEvents = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5331
    this._eventPainter.paint();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5332
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5333
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5334
Timeline._Band.prototype._softPaintEvents = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5335
    this._eventPainter.softPaint();
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._paintDecorators = 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].paint();
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._softPaintDecorators = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5345
    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
  5346
        this._decorators[i].softPaint();
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
};
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
Timeline._Band.prototype.closeBubble = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5351
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5352
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5353
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5354
 *  Classic Theme
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5355
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5356
 */
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5359
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5360
Timeline.ClassicTheme = new Object();
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
Timeline.ClassicTheme.implementations = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5363
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5364
Timeline.ClassicTheme.create = function(locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5365
    if (locale == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5366
        locale = Timeline.getDefaultLocale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5367
    }
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
    var f = Timeline.ClassicTheme.implementations[locale];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5370
    if (f == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5371
        f = Timeline.ClassicTheme._Impl;
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
    return new f();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5374
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5375
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5376
Timeline.ClassicTheme._Impl = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5377
    this.firstDayOfWeek = 0; // Sunday
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5378
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5379
    // 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
  5380
    //       The comments indicate settings controlled by CSS, not
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5381
    //       lines to be un-commented.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5382
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5383
    //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5384
    // Attributes autoWidth, autoWidthAnimationTime, timeline_start
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5385
    // 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
  5386
    // 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
  5387
    // band by using different themes for the bands.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5388
    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
  5389
                            // 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
  5390
                            // 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
  5391
    this.autoWidthAnimationTime = 500; // mSec
5767
1d811df051c2 [packaging] MANIFEST.in cleanups, update js/css copyright, remove no more used files
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2097
diff changeset
  5392
    this.timeline_start = null; // Setting a date, eg new Date(Date.UTC(2010,0,17,20,00,00,0)) will prevent the
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5393
                                // 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
  5394
    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
  5395
                                // to be moved to anytime after this date.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5396
    this.ether = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5397
        backgroundColors: [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5398
        //    "#EEE",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5399
        //    "#DDD",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5400
        //    "#CCC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5401
        //    "#AAA"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5402
        ],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5403
     //   highlightColor:     "white",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5404
        highlightOpacity:   50,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5405
        interval: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5406
            line: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5407
                show:       true,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5408
                opacity:    25
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5409
               // color:      "#aaa",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5410
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5411
            weekend: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5412
                opacity:    30
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5413
              //  color:      "#FFFFE0",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5414
            },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5415
            marker: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5416
                hAlign:     "Bottom",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5417
                vAlign:     "Right"
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
                hBottomStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5420
                    elmt.className = "timeline-ether-marker-bottom";
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
                hBottomEmphasizedStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5423
                    elmt.className = "timeline-ether-marker-bottom-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
                hTopStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5426
                    elmt.className = "timeline-ether-marker-top";
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
                hTopEmphasizedStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5429
                    elmt.className = "timeline-ether-marker-top-emphasized";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5430
                },
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5433
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
                                  vRightStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5436
                    elmt.className = "timeline-ether-marker-right";
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
                vRightEmphasizedStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5439
                    elmt.className = "timeline-ether-marker-right-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
                vLeftStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5442
                    elmt.className = "timeline-ether-marker-left";
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
                vLeftEmphasizedStyler:function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5445
                    elmt.className = "timeline-ether-marker-left-emphasized";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5446
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5447
                */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5448
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5449
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5450
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5451
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5452
    this.event = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5453
        track: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5454
                   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
  5455
                               //     height if you change the tape height.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5456
                      gap:  2, // px. Gap between tracks
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5457
                   offset:  2, // px. top margin above tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5458
          autoWidthMargin:  1.5
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5459
          /* 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
  5460
             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
  5461
             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
  5462
             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
  5463
             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
  5464
             Timeline.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5465
          */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5466
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5467
        overviewTrack: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5468
                  offset: 20, // px -- top margin above tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5469
              tickHeight:  6, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5470
                  height:  2, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5471
                     gap:  1, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5472
         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
  5473
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5474
        tape: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5475
            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
  5476
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5477
        instant: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5478
                           icon: Timeline.urlPrefix + "images/dull-blue-circle.png",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5479
                                 // 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
  5480
                      iconWidth: 10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5481
                     iconHeight: 10,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5482
               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
  5483
            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
  5484
                                     // events. This attribute is the margin between the
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5485
                                     // 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
  5486
                                     // case.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5487
    //        color:             "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5488
    //        impreciseColor:    "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5489
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5490
        duration: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5491
            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
  5492
      //      color:            "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5493
      //      impreciseColor:   "#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
        label: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5496
            backgroundOpacity: 50,// only used in detailed painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5497
               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
  5498
      //      backgroundColor:   "white",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5499
      //      lineColor:         "#58A0DC",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5500
        },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5501
        highlightColors: [  // Use with getEventPainter().setHighlightMatcher
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5502
                            // See webapp/examples/examples.js
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5503
            "#FFFF00",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5504
            "#FFC000",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5505
            "#FF0000",
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5506
            "#0000FF"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5507
        ],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5508
        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
  5509
        bubble: {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5510
            width:          250, // px
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5511
            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
  5512
                                 // scrollbar will be added for taller bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5513
            titleStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5514
                elmt.className = "timeline-event-bubble-title";
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
            bodyStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5517
                elmt.className = "timeline-event-bubble-body";
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
            imageStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5520
                elmt.className = "timeline-event-bubble-image";
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
            wikiStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5523
                elmt.className = "timeline-event-bubble-wiki";
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
            timeStyler: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5526
                elmt.className = "timeline-event-bubble-time";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5527
            }
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
    this.mouseWheel = 'scroll'; // 'default', 'zoom', 'scroll'
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5532
};/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5533
 *  An "ether" is a object that maps date/time to pixel coordinates.
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5534
 *
1156
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5537
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5538
 *  Linear Ether
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5539
 *
1156
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 = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5543
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5544
    this._interval = params.interval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5545
    this._pixelsPerInterval = params.pixelsPerInterval;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5548
Timeline.LinearEther.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5549
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5550
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5551
    this._unit = timeline.getUnit();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5552
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5553
    if ("startsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5554
        this._start = this._unit.parseFromObject(this._params.startsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5555
    } else if ("endsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5556
        this._start = this._unit.parseFromObject(this._params.endsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5557
        this.shiftPixels(-this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5558
    } else if ("centersOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5559
        this._start = this._unit.parseFromObject(this._params.centersOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5560
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5561
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5562
        this._start = this._unit.makeDefaultValue();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5563
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5566
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5567
Timeline.LinearEther.prototype.setDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5568
    this._start = this._unit.cloneValue(date);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5571
Timeline.LinearEther.prototype.shiftPixels = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5572
    var numeric = this._interval * pixels / this._pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5573
    this._start = this._unit.change(this._start, numeric);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5576
Timeline.LinearEther.prototype.dateToPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5577
    var numeric = this._unit.compare(date, this._start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5578
    return this._pixelsPerInterval * numeric / this._interval;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5581
Timeline.LinearEther.prototype.pixelOffsetToDate = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5582
    var numeric = pixels * this._interval / this._pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5583
    return this._unit.change(this._start, numeric);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5586
Timeline.LinearEther.prototype.zoom = function(zoomIn) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5587
  var netIntervalChange = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5588
  var currentZoomIndex = this._band._zoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5589
  var newZoomIndex = currentZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5590
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5591
  if (zoomIn && (currentZoomIndex > 0)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5592
    newZoomIndex = currentZoomIndex - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5593
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5594
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5595
  if (!zoomIn && (currentZoomIndex < (this._band._zoomSteps.length - 1))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5596
    newZoomIndex = currentZoomIndex + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5597
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5598
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5599
  this._band._zoomIndex = newZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5600
  this._interval =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5601
    SimileAjax.DateTime.gregorianUnitLengths[this._band._zoomSteps[newZoomIndex].unit];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5602
  this._pixelsPerInterval = this._band._zoomSteps[newZoomIndex].pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5603
  netIntervalChange = this._band._zoomSteps[newZoomIndex].unit -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5604
    this._band._zoomSteps[currentZoomIndex].unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5605
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5606
  return netIntervalChange;
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5610
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5611
 *  Hot Zone Ether
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5612
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5613
 */
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
Timeline.HotZoneEther = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5616
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5617
    this._interval = params.interval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5618
    this._pixelsPerInterval = params.pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5619
    this._theme = params.theme;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5622
Timeline.HotZoneEther.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5623
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5624
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5625
    this._unit = timeline.getUnit();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5626
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5627
    this._zones = [{
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5628
        startTime:  Number.NEGATIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5629
        endTime:    Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5630
        magnify:    1
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
    var params = this._params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5633
    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
  5634
        var zone = params.zones[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5635
        var zoneStart = this._unit.parseFromObject(zone.start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5636
        var zoneEnd =   this._unit.parseFromObject(zone.end);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5637
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5638
        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
  5639
            var zone2 = this._zones[j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5640
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5641
            if (this._unit.compare(zoneStart, zone2.endTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5642
                if (this._unit.compare(zoneStart, zone2.startTime) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5643
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5644
                        startTime:   zone2.startTime,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5645
                        endTime:     zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5646
                        magnify:     zone2.magnify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5647
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5648
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5649
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5650
                    zone2.startTime = zoneStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5651
                }
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
                if (this._unit.compare(zoneEnd, zone2.endTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5654
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5655
                        startTime:  zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5656
                        endTime:    zoneEnd,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5657
                        magnify:    zone.magnify * zone2.magnify
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5658
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5659
                    j++;
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
                    zone2.startTime = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5662
                    zoneStart = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5663
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5664
                    zone2.magnify *= zone.magnify;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5665
                    zoneStart = zone2.endTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5666
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5667
            } // else, try the next existing zone
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5668
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5669
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5670
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5671
    if ("startsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5672
        this._start = this._unit.parseFromObject(this._params.startsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5673
    } else if ("endsOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5674
        this._start = this._unit.parseFromObject(this._params.endsOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5675
        this.shiftPixels(-this._timeline.getPixelLength());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5676
    } else if ("centersOn" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5677
        this._start = this._unit.parseFromObject(this._params.centersOn);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5678
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5679
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5680
        this._start = this._unit.makeDefaultValue();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5681
        this.shiftPixels(-this._timeline.getPixelLength() / 2);
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5684
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5685
Timeline.HotZoneEther.prototype.setDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5686
    this._start = this._unit.cloneValue(date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5687
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5688
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5689
Timeline.HotZoneEther.prototype.shiftPixels = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5690
    this._start = this.pixelOffsetToDate(pixels);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5691
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5692
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5693
Timeline.HotZoneEther.prototype.dateToPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5694
    return this._dateDiffToPixelOffset(this._start, date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5695
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5696
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5697
Timeline.HotZoneEther.prototype.pixelOffsetToDate = function(pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5698
    return this._pixelOffsetToDate(pixels, this._start);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5701
Timeline.HotZoneEther.prototype.zoom = function(zoomIn) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5702
  var netIntervalChange = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5703
  var currentZoomIndex = this._band._zoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5704
  var newZoomIndex = currentZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5705
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5706
  if (zoomIn && (currentZoomIndex > 0)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5707
    newZoomIndex = currentZoomIndex - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5708
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5709
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5710
  if (!zoomIn && (currentZoomIndex < (this._band._zoomSteps.length - 1))) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5711
    newZoomIndex = currentZoomIndex + 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5712
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5713
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5714
  this._band._zoomIndex = newZoomIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5715
  this._interval =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5716
    SimileAjax.DateTime.gregorianUnitLengths[this._band._zoomSteps[newZoomIndex].unit];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5717
  this._pixelsPerInterval = this._band._zoomSteps[newZoomIndex].pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5718
  netIntervalChange = this._band._zoomSteps[newZoomIndex].unit -
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5719
    this._band._zoomSteps[currentZoomIndex].unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5720
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5721
  return netIntervalChange;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5724
Timeline.HotZoneEther.prototype._dateDiffToPixelOffset = function(fromDate, toDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5725
    var scale = this._getScale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5726
    var fromTime = fromDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5727
    var toTime = toDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5728
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5729
    var pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5730
    if (this._unit.compare(fromTime, toTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5731
        var z = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5732
        while (z < this._zones.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5733
            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
  5734
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5735
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5736
            z++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5737
        }
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
        while (this._unit.compare(fromTime, toTime) < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5740
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5741
            var toTime2 = this._unit.earlier(toTime, zone.endTime);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5742
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5743
            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
  5744
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5745
            fromTime = toTime2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5746
            z++;
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5749
        var z = this._zones.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5750
        while (z >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5751
            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
  5752
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5753
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5754
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5755
        }
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
        while (this._unit.compare(fromTime, toTime) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5758
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5759
            var toTime2 = this._unit.later(toTime, zone.startTime);
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
            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
  5762
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5763
            fromTime = toTime2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5764
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5765
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5766
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5767
    return pixels;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5768
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5769
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5770
Timeline.HotZoneEther.prototype._pixelOffsetToDate = function(pixels, fromDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5771
    var scale = this._getScale();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5772
    var time = fromDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5773
    if (pixels > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5774
        var z = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5775
        while (z < this._zones.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5776
            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
  5777
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5778
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5779
            z++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5780
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5781
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5782
        while (pixels > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5783
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5784
            var scale2 = scale / zone.magnify;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5785
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5786
            if (zone.endTime == Number.POSITIVE_INFINITY) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5787
                time = this._unit.change(time, pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5788
                pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5789
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5790
                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
  5791
                if (pixels2 > pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5792
                    time = this._unit.change(time, pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5793
                    pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5794
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5795
                    time = zone.endTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5796
                    pixels -= pixels2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5797
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5798
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5799
            z++;
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5802
        var z = this._zones.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5803
        while (z >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5804
            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
  5805
                break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5806
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5807
            z--;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5810
        pixels = -pixels;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5811
        while (pixels > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5812
            var zone = this._zones[z];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5813
            var scale2 = scale / zone.magnify;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5814
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5815
            if (zone.startTime == Number.NEGATIVE_INFINITY) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5816
                time = this._unit.change(time, -pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5817
                pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5818
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5819
                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
  5820
                if (pixels2 > pixels) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5821
                    time = this._unit.change(time, -pixels * scale2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5822
                    pixels = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5823
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5824
                    time = zone.startTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5825
                    pixels -= pixels2;
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
            z--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5829
        }
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
    return time;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5832
};
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
Timeline.HotZoneEther.prototype._getScale = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5835
    return this._interval / this._pixelsPerInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5836
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5837
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5838
 *  Gregorian Ether Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5839
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5840
 */
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
Timeline.GregorianEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5843
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5844
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5845
    this._unit = params.unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5846
    this._multiple = ("multiple" in params) ? params.multiple : 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5847
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5848
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5849
Timeline.GregorianEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5850
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5851
    this._timeline = timeline;
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._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5854
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5855
    this._backgroundLayer.className = 'timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5856
  //  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
  5857
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5858
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5859
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5860
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5861
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5862
    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
  5863
        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
  5864
    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
  5865
        this._theme.ether.interval.line.show;
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
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5868
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5869
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5870
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5871
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5872
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5873
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5874
Timeline.GregorianEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5875
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5876
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5877
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5878
Timeline.GregorianEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5879
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5880
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5881
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5882
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5883
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5884
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5885
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5886
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5887
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5888
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5889
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5890
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5891
    this._lineLayer.style.display = "none";
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
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5894
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5895
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5896
    var timeZone = this._band.getTimeZone();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5897
    var labeller = this._band.getLabeller();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5898
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5899
    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
  5900
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5901
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5902
    var incrementDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5903
        for (var i = 0; i < p._multiple; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5904
            SimileAjax.DateTime.incrementByInterval(date, p._unit);
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
    };
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
    while (minDate.getTime() < maxDate.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5909
        this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5910
            minDate, labeller, this._unit, this._markerLayer, this._lineLayer);
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
        incrementDate(minDate);
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
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5915
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5916
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5917
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5918
Timeline.GregorianEtherPainter.prototype.softPaint = function() {
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
Timeline.GregorianEtherPainter.prototype.zoom = function(netIntervalChange) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5922
  if (netIntervalChange != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5923
    this._unit += netIntervalChange;
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5928
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5929
 *  Hot Zone Gregorian Ether Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  5930
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5931
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5932
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5933
Timeline.HotZoneGregorianEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5934
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5935
    this._theme = params.theme;
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
    this._zones = [{
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5938
        startTime:  Number.NEGATIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5939
        endTime:    Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5940
        unit:       params.unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5941
        multiple:   1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5942
    }];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5943
    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
  5944
        var zone = params.zones[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5945
        var zoneStart = SimileAjax.DateTime.parseGregorianDateTime(zone.start).getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5946
        var zoneEnd = SimileAjax.DateTime.parseGregorianDateTime(zone.end).getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5947
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5948
        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
  5949
            var zone2 = this._zones[j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5950
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5951
            if (zoneStart < zone2.endTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5952
                if (zoneStart > zone2.startTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5953
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5954
                        startTime:   zone2.startTime,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5955
                        endTime:     zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5956
                        unit:        zone2.unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5957
                        multiple:    zone2.multiple
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5958
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5959
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5960
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5961
                    zone2.startTime = zoneStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5962
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5963
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5964
                if (zoneEnd < zone2.endTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5965
                    this._zones.splice(j, 0, {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5966
                        startTime:  zoneStart,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5967
                        endTime:    zoneEnd,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5968
                        unit:       zone.unit,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5969
                        multiple:   (zone.multiple) ? zone.multiple : 1
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5970
                    });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5971
                    j++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5972
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5973
                    zone2.startTime = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5974
                    zoneStart = zoneEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5975
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5976
                    zone2.multiple = zone.multiple;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5977
                    zone2.unit = zone.unit;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5978
                    zoneStart = zone2.endTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5979
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5980
            } // else, try the next existing zone
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5981
        }
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5984
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5985
Timeline.HotZoneGregorianEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5986
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5987
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5988
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5989
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5990
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5991
    this._backgroundLayer.className ='timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5992
    //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
  5993
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5994
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5995
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5996
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  5997
    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
  5998
        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
  5999
    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
  6000
        this._theme.ether.interval.line.show;
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
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6003
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6004
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6005
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6006
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6007
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6008
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6009
Timeline.HotZoneGregorianEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6010
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6011
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6012
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6013
Timeline.HotZoneGregorianEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6014
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6015
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6016
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6017
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6018
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6019
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6020
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6021
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6022
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6023
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6024
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6025
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6026
    this._lineLayer.style.display = "none";
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 minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6029
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6030
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6031
    var timeZone = this._band.getTimeZone();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6032
    var labeller = this._band.getLabeller();
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
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6035
    var incrementDate = function(date, zone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6036
        for (var i = 0; i < zone.multiple; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6037
            SimileAjax.DateTime.incrementByInterval(date, zone.unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6038
        }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6041
    var zStart = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6042
    while (zStart < this._zones.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6043
        if (minDate.getTime() < this._zones[zStart].endTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6044
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6045
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6046
        zStart++;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6047
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6048
    var zEnd = this._zones.length - 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6049
    while (zEnd >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6050
        if (maxDate.getTime() > this._zones[zEnd].startTime) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6051
            break;
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
        zEnd--;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6054
    }
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
    for (var z = zStart; z <= zEnd; z++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6057
        var zone = this._zones[z];
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
        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
  6060
        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
  6061
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6062
        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
  6063
        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
  6064
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6065
        while (minDate2.getTime() < maxDate2.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6066
            this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6067
                minDate2, labeller, zone.unit, this._markerLayer, this._lineLayer);
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
            incrementDate(minDate2, zone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6070
        }
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
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6073
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6074
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6075
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6076
Timeline.HotZoneGregorianEtherPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6077
};
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
Timeline.HotZoneGregorianEtherPainter.prototype.zoom = function(netIntervalChange) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6080
  if (netIntervalChange != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6081
    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
  6082
      if (this._zones[i]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6083
        this._zones[i].unit += netIntervalChange;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6084
      }
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6089
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6090
 *  Year Count Ether Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6091
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6092
 */
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
Timeline.YearCountEtherPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6095
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6096
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6097
    this._startDate = SimileAjax.DateTime.parseGregorianDateTime(params.startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6098
    this._multiple = ("multiple" in params) ? params.multiple : 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6099
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6100
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6101
Timeline.YearCountEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6102
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6103
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6104
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6105
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6106
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6107
    this._backgroundLayer.className = 'timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6108
   // 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
  6109
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6110
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6111
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6112
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6113
    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
  6114
        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
  6115
    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
  6116
        this._theme.ether.interval.line.show;
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
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6119
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6121
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6122
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6123
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6124
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6125
Timeline.YearCountEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6126
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6127
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6128
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6129
Timeline.YearCountEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6130
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6131
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6132
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6133
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6134
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6135
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6136
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6137
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6138
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6139
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6140
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6141
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6142
    this._lineLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6143
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6144
    var minDate = new Date(this._startDate.getTime());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6145
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6146
    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
  6147
    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
  6148
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6149
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6150
    var incrementDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6151
        for (var i = 0; i < p._multiple; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6152
            SimileAjax.DateTime.incrementByInterval(date, SimileAjax.DateTime.YEAR);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6153
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6154
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6155
    var labeller = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6156
        labelInterval: function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6157
            var diff = date.getUTCFullYear() - p._startDate.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6158
            return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6159
                text: diff,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6160
                emphasized: diff == 0
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6161
            };
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
    };
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
    while (minDate.getTime() < maxDate.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6166
        this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6167
            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
  6168
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6169
        incrementDate(minDate);
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
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6172
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6173
};
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
Timeline.YearCountEtherPainter.prototype.softPaint = function() {
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6178
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6179
 *  Quarterly Ether Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6180
 *
1156
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 = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6184
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6185
    this._theme = params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6186
    this._startDate = SimileAjax.DateTime.parseGregorianDateTime(params.startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6187
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6188
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6189
Timeline.QuarterlyEtherPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6190
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6191
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6192
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6193
    this._backgroundLayer = band.createLayerDiv(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6194
    this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6195
    this._backgroundLayer.className = 'timeline-ether-bg';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6196
 //   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
  6197
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6198
    this._markerLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6199
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6200
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6201
    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
  6202
        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
  6203
    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
  6204
        this._theme.ether.interval.line.show;
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
    this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6207
        this._timeline, this._band, this._theme, align, showLine);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6208
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6209
    this._highlight = new Timeline.EtherHighlight(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6210
        this._timeline, this._band, this._theme, this._backgroundLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6211
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6212
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6213
Timeline.QuarterlyEtherPainter.prototype.setHighlight = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6214
    this._highlight.position(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6215
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6216
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6217
Timeline.QuarterlyEtherPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6218
    if (this._markerLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6219
        this._band.removeLayerDiv(this._markerLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6220
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6221
    this._markerLayer = this._band.createLayerDiv(100);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6222
    this._markerLayer.setAttribute("name", "ether-markers"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6223
    this._markerLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6224
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6225
    if (this._lineLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6226
        this._band.removeLayerDiv(this._lineLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6227
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6228
    this._lineLayer = this._band.createLayerDiv(1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6229
    this._lineLayer.setAttribute("name", "ether-lines"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6230
    this._lineLayer.style.display = "none";
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 minDate = new Date(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6233
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6234
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6235
    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
  6236
    minDate.setUTCMonth(this._startDate.getUTCMonth());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6237
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6238
    var p = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6239
    var incrementDate = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6240
        date.setUTCMonth(date.getUTCMonth() + 3);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6241
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6242
    var labeller = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6243
        labelInterval: function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6244
            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
  6245
            if (quarters != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6246
                return { text: "Q" + (quarters + 1), emphasized: false };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6247
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6248
                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
  6249
            }
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
    };
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
    while (minDate.getTime() < maxDate.getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6254
        this._intervalMarkerLayout.createIntervalMarker(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6255
            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
  6256
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6257
        incrementDate(minDate);
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
    this._markerLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6260
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6261
};
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
Timeline.QuarterlyEtherPainter.prototype.softPaint = function() {
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6266
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6267
 *  Ether Interval Marker Layout
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6268
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6269
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6270
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6271
Timeline.EtherIntervalMarkerLayout = function(timeline, band, theme, align, showLine) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6272
    var horizontal = timeline.isHorizontal();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6273
    if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6274
        if (align == "Top") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6275
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6276
                div.style.left = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6277
                div.style.top = "0px";
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
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6281
                div.style.left = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6282
                div.style.bottom = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6283
            };
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
        if (align == "Left") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6287
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6288
                div.style.top = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6289
                div.style.left = "0px";
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
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6292
            this.positionDiv = function(div, offset) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6293
                div.style.top = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6294
                div.style.right = "0px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6295
            };
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6298
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6299
    var markerTheme = theme.ether.interval.marker;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6300
    var lineTheme = theme.ether.interval.line;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6301
    var weekendTheme = theme.ether.interval.weekend;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6302
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6303
    var stylePrefix = (horizontal ? "h" : "v") + align;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6304
    var labelStyler = markerTheme[stylePrefix + "Styler"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6305
    var emphasizedLabelStyler = markerTheme[stylePrefix + "EmphasizedStyler"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6306
    var day = SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.DAY];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6307
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6308
    this.createIntervalMarker = function(date, labeller, unit, markerDiv, lineDiv) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6309
        var offset = Math.round(band.dateToPixelOffset(date));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6310
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6311
        if (showLine && unit != SimileAjax.DateTime.WEEK) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6312
            var divLine = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6313
            divLine.className = "timeline-ether-lines";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6314
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6315
            if (lineTheme.opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6316
                SimileAjax.Graphics.setOpacity(divLine, lineTheme.opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6317
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6318
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6319
            if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6320
				//divLine.className += " timeline-ether-lines-vertical";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6321
				divLine.style.left = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6322
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6323
				//divLine.className += " timeline-ether-lines-horizontal";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6324
                divLine.style.top = offset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6325
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6326
            lineDiv.appendChild(divLine);
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
        if (unit == SimileAjax.DateTime.WEEK) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6329
            var firstDayOfWeek = theme.firstDayOfWeek;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6330
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6331
            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
  6332
            var monday = new Date(saturday.getTime() + 2 * day);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6333
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6334
            var saturdayPixel = Math.round(band.dateToPixelOffset(saturday));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6335
            var mondayPixel = Math.round(band.dateToPixelOffset(monday));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6336
            var length = Math.max(1, mondayPixel - saturdayPixel);
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
            var divWeekend = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6339
			divWeekend.className = 'timeline-ether-weekends'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6340
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6341
            if (weekendTheme.opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6342
                SimileAjax.Graphics.setOpacity(divWeekend, weekendTheme.opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6343
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6344
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6345
            if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6346
                divWeekend.style.left = saturdayPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6347
                divWeekend.style.width = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6348
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6349
                divWeekend.style.top = saturdayPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6350
                divWeekend.style.height = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6351
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6352
            lineDiv.appendChild(divWeekend);
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
        var label = labeller.labelInterval(date, unit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6356
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6357
        var div = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6358
        div.innerHTML = label.text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6359
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6360
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
		div.className = 'timeline-date-label'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6363
		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
  6364
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6365
        this.positionDiv(div, offset);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6366
        markerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6367
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6368
        return div;
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6372
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6373
 *  Ether Highlight Layout
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6374
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6375
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6376
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6377
Timeline.EtherHighlight = function(timeline, band, theme, backgroundLayer) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6378
    var horizontal = timeline.isHorizontal();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6379
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6380
    this._highlightDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6381
    this._createHighlightDiv = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6382
        if (this._highlightDiv == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6383
            this._highlightDiv = timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6384
            this._highlightDiv.setAttribute("name", "ether-highlight"); // for debugging
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6385
            this._highlightDiv.className = 'timeline-ether-highlight'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6386
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6387
            var opacity = theme.ether.highlightOpacity;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6388
            if (opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6389
                SimileAjax.Graphics.setOpacity(this._highlightDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6390
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6391
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6392
            backgroundLayer.appendChild(this._highlightDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6393
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6394
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6395
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6396
    this.position = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6397
        this._createHighlightDiv();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6398
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6399
        var startPixel = Math.round(band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6400
        var endPixel = Math.round(band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6401
        var length = Math.max(endPixel - startPixel, 3);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6402
        if (horizontal) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6403
            this._highlightDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6404
            this._highlightDiv.style.width = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6405
            this._highlightDiv.style.height = (band.getViewWidth() - 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6406
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6407
            this._highlightDiv.style.top = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6408
            this._highlightDiv.style.height = length + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6409
            this._highlightDiv.style.width = (band.getViewWidth() - 4) + "px";
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6412
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6413
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6414
 *  Event Utils
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6415
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6416
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6417
Timeline.EventUtils = {};
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
Timeline.EventUtils.getNewEventID = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6420
    // global across page
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6421
    if (this._lastEventID == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6422
        this._lastEventID = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6423
    }
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
    this._lastEventID += 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6426
    return "e" + this._lastEventID;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6427
};
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
Timeline.EventUtils.decodeEventElID = function(elementID) {
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6430
    /*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6431
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6432
     * 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
  6433
     * tape div or icon img).
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
     * Returns {band: <bandObj>, evt: <eventObj>}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6436
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6437
     * 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
  6438
     * 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
  6439
     * elements on the Timeline--
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6440
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6441
     * element id format for labels, icons, tapes:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6442
     *   labels: label-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6443
     *    icons: icon-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6444
     *    tapes: tape1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6445
     *           tape2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6446
     *           // some events have more than one tape
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6447
     *    highlight: highlight1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6448
     *               highlight2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6449
     *           // 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
  6450
     * 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
  6451
     *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6452
     * 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
  6453
     * by using Timeline.getTimeline, Timeline.getBand, or
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6454
     * 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
  6455
     *
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6456
     *
1156
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 parts = elementID.split('-');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6460
    if (parts[1] != 'tl') {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6461
        alert("Internal Timeline problem 101, please consult support");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6462
        return {band: null, evt: null}; // early return
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6463
    }
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
    var timeline = Timeline.getTimelineFromID(parts[2]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6466
    var band = timeline.getBand(parts[3]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6467
    var evt = band.getEventSource.getEvent(parts[4]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6468
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6469
    return {band: band, evt: evt};
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6472
Timeline.EventUtils.encodeEventElID = function(timeline, band, elType, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6473
    // 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
  6474
    return elType + "-tl-" + timeline.timelineID +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6475
       "-" + band.getIndex() + "-" + evt.getID();
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6476
};/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6477
 *  Gregorian Date Labeller
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6478
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6481
Timeline.GregorianDateLabeller = function(locale, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6482
    this._locale = locale;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6483
    this._timeZone = timeZone;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6484
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6485
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6486
Timeline.GregorianDateLabeller.monthNames = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6487
Timeline.GregorianDateLabeller.dayNames = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6488
Timeline.GregorianDateLabeller.labelIntervalFunctions = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6489
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6490
Timeline.GregorianDateLabeller.getMonthName = function(month, locale) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6491
    return Timeline.GregorianDateLabeller.monthNames[locale][month];
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6494
Timeline.GregorianDateLabeller.prototype.labelInterval = function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6495
    var f = Timeline.GregorianDateLabeller.labelIntervalFunctions[this._locale];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6496
    if (f == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6497
        f = Timeline.GregorianDateLabeller.prototype.defaultLabelInterval;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6498
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6499
    return f.call(this, date, intervalUnit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6500
};
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
Timeline.GregorianDateLabeller.prototype.labelPrecise = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6503
    return SimileAjax.DateTime.removeTimeZoneOffset(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6504
        date,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6505
        this._timeZone //+ (new Date().getTimezoneOffset() / 60)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6506
    ).toUTCString();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6507
};
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
Timeline.GregorianDateLabeller.prototype.defaultLabelInterval = function(date, intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6510
    var text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6511
    var emphasized = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6512
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6513
    date = SimileAjax.DateTime.removeTimeZoneOffset(date, this._timeZone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6514
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6515
    switch(intervalUnit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6516
    case SimileAjax.DateTime.MILLISECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6517
        text = date.getUTCMilliseconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6518
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6519
    case SimileAjax.DateTime.SECOND:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6520
        text = date.getUTCSeconds();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6521
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6522
    case SimileAjax.DateTime.MINUTE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6523
        var m = date.getUTCMinutes();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6524
        if (m == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6525
            text = date.getUTCHours() + ":00";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6526
            emphasized = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6527
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6528
            text = m;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6529
        }
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.HOUR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6532
        text = date.getUTCHours() + "hr";
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.DAY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6535
        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
  6536
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6537
    case SimileAjax.DateTime.WEEK:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6538
        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
  6539
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6540
    case SimileAjax.DateTime.MONTH:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6541
        var m = date.getUTCMonth();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6542
        if (m != 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6543
            text = Timeline.GregorianDateLabeller.getMonthName(m, this._locale);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6544
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6545
        } // else, fall through
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6546
    case SimileAjax.DateTime.YEAR:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6547
    case SimileAjax.DateTime.DECADE:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6548
    case SimileAjax.DateTime.CENTURY:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6549
    case SimileAjax.DateTime.MILLENNIUM:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6550
        var y = date.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6551
        if (y > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6552
            text = date.getUTCFullYear();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6553
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6554
            text = (1 - y) + "BC";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6555
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6556
        emphasized =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6557
            (intervalUnit == SimileAjax.DateTime.MONTH) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6558
            (intervalUnit == SimileAjax.DateTime.DECADE && y % 100 == 0) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6559
            (intervalUnit == SimileAjax.DateTime.CENTURY && y % 1000 == 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6560
        break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6561
    default:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6562
        text = date.toUTCString();
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
    return { text: text, emphasized: emphasized };
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6567
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6568
 *  Default Event Source
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  6569
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6573
Timeline.DefaultEventSource = function(eventIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6574
    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
  6575
    this._listeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6576
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6577
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6578
Timeline.DefaultEventSource.prototype.addListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6579
    this._listeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6580
};
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
Timeline.DefaultEventSource.prototype.removeListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6583
    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
  6584
        if (this._listeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6585
            this._listeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6586
            break;
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6589
};
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
Timeline.DefaultEventSource.prototype.loadXML = function(xml, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6592
    var base = this._getBaseURL(url);
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 wikiURL = xml.documentElement.getAttribute("wiki-url");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6595
    var wikiSection = xml.documentElement.getAttribute("wiki-section");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6596
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6597
    var dateTimeFormat = xml.documentElement.getAttribute("date-time-format");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6598
    var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6599
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6600
    var node = xml.documentElement.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6601
    var added = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6602
    while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6603
        if (node.nodeType == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6604
            var description = "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6605
            if (node.firstChild != null && node.firstChild.nodeType == 3) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6606
                description = node.firstChild.nodeValue;
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
            // 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
  6609
            var instant = (node.getAttribute("isDuration")    === null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6610
                           node.getAttribute("durationEvent") === null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6611
                          node.getAttribute("isDuration") == "false" ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6612
                          node.getAttribute("durationEvent") == "false";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6613
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6614
            var evt = new Timeline.DefaultEventSource.Event( {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6615
                          id: node.getAttribute("id"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6616
                       start: parseDateTimeFunction(node.getAttribute("start")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6617
                         end: parseDateTimeFunction(node.getAttribute("end")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6618
                 latestStart: parseDateTimeFunction(node.getAttribute("latestStart")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6619
                 earliestEnd: parseDateTimeFunction(node.getAttribute("earliestEnd")),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6620
                     instant: instant,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6621
                        text: node.getAttribute("title"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6622
                 description: description,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6623
                       image: this._resolveRelativeURL(node.getAttribute("image"), base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6624
                        link: this._resolveRelativeURL(node.getAttribute("link") , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6625
                        icon: this._resolveRelativeURL(node.getAttribute("icon") , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6626
                       color: node.getAttribute("color"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6627
                   textColor: node.getAttribute("textColor"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6628
                   hoverText: node.getAttribute("hoverText"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6629
                   classname: node.getAttribute("classname"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6630
                   tapeImage: node.getAttribute("tapeImage"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6631
                  tapeRepeat: node.getAttribute("tapeRepeat"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6632
                     caption: node.getAttribute("caption"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6633
                     eventID: node.getAttribute("eventID"),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6634
                    trackNum: node.getAttribute("trackNum")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6635
            });
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
            evt._node = node;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6638
            evt.getProperty = function(name) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6639
                return this._node.getAttribute(name);
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
            evt.setWikiInfo(wikiURL, wikiSection);
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
            this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6644
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6645
            added = true;
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
        node = node.nextSibling;
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
    if (added) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6651
        this._fire("onAddMany", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6652
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6653
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6654
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6655
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6656
Timeline.DefaultEventSource.prototype.loadJSON = function(data, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6657
    var base = this._getBaseURL(url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6658
    var added = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6659
    if (data && data.events){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6660
        var wikiURL = ("wikiURL" in data) ? data.wikiURL : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6661
        var wikiSection = ("wikiSection" in data) ? data.wikiSection : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6662
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6663
        var dateTimeFormat = ("dateTimeFormat" in data) ? data.dateTimeFormat : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6664
        var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6665
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6666
        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
  6667
            var event = data.events[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6668
            // Fixing issue 33:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6669
            // 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
  6670
            // 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
  6671
            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
  6672
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6673
            var evt = new Timeline.DefaultEventSource.Event({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6674
                          id: ("id" in event) ? event.id : undefined,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6675
                       start: parseDateTimeFunction(event.start),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6676
                         end: parseDateTimeFunction(event.end),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6677
                 latestStart: parseDateTimeFunction(event.latestStart),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6678
                 earliestEnd: parseDateTimeFunction(event.earliestEnd),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6679
                     instant: instant,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6680
                        text: event.title,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6681
                 description: event.description,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6682
                       image: this._resolveRelativeURL(event.image, base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6683
                        link: this._resolveRelativeURL(event.link , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6684
                        icon: this._resolveRelativeURL(event.icon , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6685
                       color: event.color,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6686
                   textColor: event.textColor,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6687
                   hoverText: event.hoverText,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6688
                   classname: event.classname,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6689
                   tapeImage: event.tapeImage,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6690
                  tapeRepeat: event.tapeRepeat,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6691
                     caption: event.caption,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6692
                     eventID: event.eventID,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6693
                    trackNum: event.trackNum
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
            evt._obj = event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6696
            evt.getProperty = function(name) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6697
                return this._obj[name];
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
            evt.setWikiInfo(wikiURL, wikiSection);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6700
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6701
            this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6702
            added = true;
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
    if (added) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6707
        this._fire("onAddMany", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6708
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6709
};
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
/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6712
 *  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
  6713
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6714
Timeline.DefaultEventSource.prototype.loadSPARQL = function(xml, url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6715
    var base = this._getBaseURL(url);
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
    var dateTimeFormat = 'iso8601';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6718
    var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6719
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6720
    if (xml == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6721
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6722
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6723
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
     *  Find <results> tag
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6726
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6727
    var node = xml.documentElement.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6728
    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
  6729
        node = node.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6730
    }
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
    var wikiURL = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6733
    var wikiSection = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6734
    if (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6735
        wikiURL = node.getAttribute("wiki-url");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6736
        wikiSection = node.getAttribute("wiki-section");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6737
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6738
        node = node.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6739
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6740
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6741
    var added = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6742
    while (node != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6743
        if (node.nodeType == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6744
            var bindings = { };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6745
            var binding = node.firstChild;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6746
            while (binding != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6747
                if (binding.nodeType == 1 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6748
                    binding.firstChild != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6749
                    binding.firstChild.nodeType == 1 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6750
                    binding.firstChild.firstChild != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6751
                    binding.firstChild.firstChild.nodeType == 3) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6752
                    bindings[binding.getAttribute('name')] = binding.firstChild.firstChild.nodeValue;
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
                binding = binding.nextSibling;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6755
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6756
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6757
            if (bindings["start"] == null && bindings["date"] != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6758
                bindings["start"] = bindings["date"];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6759
            }
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
            // 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
  6762
            var instant = (bindings["isDuration"]    === null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6763
                           bindings["durationEvent"] === null) ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6764
                          bindings["isDuration"] == "false" ||
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6765
                          bindings["durationEvent"] == "false";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6766
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6767
            var evt = new Timeline.DefaultEventSource.Event({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6768
                          id: bindings["id"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6769
                       start: parseDateTimeFunction(bindings["start"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6770
                         end: parseDateTimeFunction(bindings["end"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6771
                 latestStart: parseDateTimeFunction(bindings["latestStart"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6772
                 earliestEnd: parseDateTimeFunction(bindings["earliestEnd"]),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6773
                     instant: instant, // instant
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6774
                        text: bindings["title"], // text
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6775
                 description: bindings["description"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6776
                       image: this._resolveRelativeURL(bindings["image"], base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6777
                        link: this._resolveRelativeURL(bindings["link"] , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6778
                        icon: this._resolveRelativeURL(bindings["icon"] , base),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6779
                       color: bindings["color"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6780
                   textColor: bindings["textColor"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6781
                   hoverText: bindings["hoverText"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6782
                     caption: bindings["caption"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6783
                   classname: bindings["classname"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6784
                   tapeImage: bindings["tapeImage"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6785
                  tapeRepeat: bindings["tapeRepeat"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6786
                     eventID: bindings["eventID"],
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6787
                    trackNum: bindings["trackNum"]
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
            evt._bindings = bindings;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6790
            evt.getProperty = function(name) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6791
                return this._bindings[name];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6792
            };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6793
            evt.setWikiInfo(wikiURL, wikiSection);
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
            this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6796
            added = true;
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
        node = node.nextSibling;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6801
    if (added) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6802
        this._fire("onAddMany", []);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6806
Timeline.DefaultEventSource.prototype.add = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6807
    this._events.add(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6808
    this._fire("onAddOne", [evt]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6809
};
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
Timeline.DefaultEventSource.prototype.addMany = function(events) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6812
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6813
        this._events.add(events[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6814
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6815
    this._fire("onAddMany", []);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6818
Timeline.DefaultEventSource.prototype.clear = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6819
    this._events.removeAll();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6820
    this._fire("onClear", []);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6821
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6822
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6823
Timeline.DefaultEventSource.prototype.getEvent = function(id) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6824
    return this._events.getEvent(id);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6825
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6826
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6827
Timeline.DefaultEventSource.prototype.getEventIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6828
    return this._events.getIterator(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6829
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6830
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6831
Timeline.DefaultEventSource.prototype.getEventReverseIterator = function(startDate, endDate) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6832
    return this._events.getReverseIterator(startDate, endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6833
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6834
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6835
Timeline.DefaultEventSource.prototype.getAllEventIterator = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6836
    return this._events.getAllIterator();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6837
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6838
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6839
Timeline.DefaultEventSource.prototype.getCount = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6840
    return this._events.getCount();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6841
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6842
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6843
Timeline.DefaultEventSource.prototype.getEarliestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6844
    return this._events.getEarliestDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6845
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6846
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6847
Timeline.DefaultEventSource.prototype.getLatestDate = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6848
    return this._events.getLatestDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6849
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6850
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6851
Timeline.DefaultEventSource.prototype._fire = function(handlerName, args) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6852
    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
  6853
        var listener = this._listeners[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6854
        if (handlerName in listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6855
            try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6856
                listener[handlerName].apply(listener, args);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6857
            } catch (e) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6858
                SimileAjax.Debug.exception(e);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6859
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6860
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6861
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6862
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6863
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6864
Timeline.DefaultEventSource.prototype._getBaseURL = function(url) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6865
    if (url.indexOf("://") < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6866
        var url2 = this._getBaseURL(document.location.href);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6867
        if (url.substr(0,1) == "/") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6868
            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
  6869
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6870
            url = url2 + url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6871
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6872
    }
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
    var i = url.lastIndexOf("/");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6875
    if (i < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6876
        return "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6877
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6878
        return url.substr(0, i+1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6879
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6880
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6881
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6882
Timeline.DefaultEventSource.prototype._resolveRelativeURL = function(url, base) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6883
    if (url == null || url == "") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6884
        return url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6885
    } else if (url.indexOf("://") > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6886
        return url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6887
    } else if (url.substr(0,1) == "/") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6888
        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
  6889
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6890
        return base + url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6891
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6892
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6893
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6894
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6895
Timeline.DefaultEventSource.Event = function(args) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6896
  //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6897
  // Attention developers!
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6898
  // 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
  6899
  // all three load functions: loadXML, loadSPARCL, loadJSON.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6900
  // Thanks!
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6901
  //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6902
  // 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
  6903
  //   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
  6904
  //                    Timeline library clients should use eventID
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6905
  //   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
  6906
  //                    custom fillInfoBubble
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6907
  //   start
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6908
  //   end
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6909
  //   latestStart
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6910
  //   earliestEnd
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6911
  //   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
  6912
  //   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
  6913
  //   description  -- used in bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6914
  //   image        -- used in bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6915
  //   link         -- used in bubbles
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6916
  //   icon         -- on the Timeline
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6917
  //   color        -- Timeline label and tape color
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6918
  //   textColor    -- Timeline label color, overrides color attribute
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6919
  //   hoverText    -- deprecated, here for backwards compatibility.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6920
  //                   Superceeded by caption
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6921
  //   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
  6922
  //   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
  6923
  //   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
  6924
  //   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
  6925
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6926
  function cleanArg(arg) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6927
      // clean up an arg
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6928
      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
  6929
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6930
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6931
  var id = args.id ? args.id.trim() : "";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6932
  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
  6933
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6934
  this._instant = args.instant || (args.end == null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6935
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6936
  this._start = args.start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6937
  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
  6938
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6939
  this._latestStart = (args.latestStart != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6940
                       args.latestStart : (args.instant ? this._end : this._start);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6941
  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
  6942
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6943
  // 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
  6944
  // when painting
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6945
  var err=[];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6946
  if (this._start > this._latestStart) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6947
          this._latestStart = this._start;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6948
          err.push("start is > latestStart");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6949
  if (this._start > 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("start is > earliestEnd");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6952
  if (this._start > 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("start is > end");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6955
  if (this._latestStart > this._earliestEnd) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6956
          this._earliestEnd = this._latestStart;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6957
          err.push("latestStart is > earliestEnd");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6958
  if (this._latestStart > this._end) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6959
          this._end = this._earliestEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6960
          err.push("latestStart is > end");}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6961
  if (this._earliestEnd > this._end) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6962
          this._end = this._earliestEnd;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6963
          err.push("earliestEnd is > end");}
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._eventID = cleanArg('eventID');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6966
  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
  6967
  if (err.length > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6968
          this._text += " PROBLEM: " + err.join(", ");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6969
  }
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._description = SimileAjax.HTML.deEntify(args.description);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6972
  this._image = cleanArg('image');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6973
  this._link =  cleanArg('link');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6974
  this._title = cleanArg('hoverText');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6975
  this._title = cleanArg('caption');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6976
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6977
  this._icon = cleanArg('icon');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6978
  this._color = cleanArg('color');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6979
  this._textColor = cleanArg('textColor');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6980
  this._classname = cleanArg('classname');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6981
  this._tapeImage = cleanArg('tapeImage');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6982
  this._tapeRepeat = cleanArg('tapeRepeat');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6983
  this._trackNum = cleanArg('trackNum');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6984
  if (this._trackNum != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6985
      this._trackNum = parseInt(this._trackNum);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6986
  }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6987
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6988
  this._wikiURL = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6989
  this._wikiSection = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6990
};
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
Timeline.DefaultEventSource.Event.prototype = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6993
    getID:          function() { return this._id; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6994
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6995
    isInstant:      function() { return this._instant; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6996
    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
  6997
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6998
    getStart:       function() { return this._start; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  6999
    getEnd:         function() { return this._end; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7000
    getLatestStart: function() { return this._latestStart; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7001
    getEarliestEnd: function() { return this._earliestEnd; },
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
    getEventID:     function() { return this._eventID; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7004
    getText:        function() { return this._text; }, // title
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7005
    getDescription: function() { return this._description; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7006
    getImage:       function() { return this._image; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7007
    getLink:        function() { return this._link; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7008
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7009
    getIcon:        function() { return this._icon; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7010
    getColor:       function() { return this._color; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7011
    getTextColor:   function() { return this._textColor; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7012
    getClassName:   function() { return this._classname; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7013
    getTapeImage:   function() { return this._tapeImage; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7014
    getTapeRepeat:  function() { return this._tapeRepeat; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7015
    getTrackNum:    function() { return this._trackNum; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7016
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7017
    getProperty:    function(name) { return null; },
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
    getWikiURL:     function() { return this._wikiURL; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7020
    getWikiSection: function() { return this._wikiSection; },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7021
    setWikiInfo: function(wikiURL, wikiSection) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7022
        this._wikiURL = wikiURL;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7023
        this._wikiSection = wikiSection;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7024
    },
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
    fillDescription: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7027
        elmt.innerHTML = this._description;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7028
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7029
    fillWikiInfo: function(elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7030
        // Many bubbles will not support a wiki link.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7031
        //
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7032
        // 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
  7033
        // enough parameters for one, then create it.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7034
        elmt.style.display = "none"; // default
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7035
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7036
        if (this._wikiURL == null || this._wikiSection == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7037
          return; // EARLY RETURN
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
        // 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
  7041
        var wikiID = this.getProperty("wikiID");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7042
        if (wikiID == null || wikiID.length == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7043
            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
  7044
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7045
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7046
        if (wikiID == null || wikiID.length == 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7047
          return; // No wikiID. Thus EARLY RETURN
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7048
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7049
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7050
        // ready to go...
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7051
        elmt.style.display = "inline";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7052
        wikiID = wikiID.replace(/\s/g, "_");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7053
        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
  7054
        var a = document.createElement("a");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7055
        a.href = url;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7056
        a.target = "new";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7057
        a.innerHTML = Timeline.strings[Timeline.clientLocale].wikiLinkLabel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7058
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7059
        elmt.appendChild(document.createTextNode("["));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7060
        elmt.appendChild(a);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7061
        elmt.appendChild(document.createTextNode("]"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7062
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7063
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7064
    fillTime: function(elmt, labeller) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7065
        if (this._instant) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7066
            if (this.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7067
                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
  7068
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7069
                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
  7070
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7071
                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
  7072
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7073
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7074
            if (this.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7075
                elmt.appendChild(elmt.ownerDocument.createTextNode(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7076
                    labeller.labelPrecise(this._start) + " ~ " + labeller.labelPrecise(this._latestStart)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7077
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7078
                elmt.appendChild(elmt.ownerDocument.createTextNode(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7079
                    labeller.labelPrecise(this._earliestEnd) + " ~ " + labeller.labelPrecise(this._end)));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7080
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7081
                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
  7082
                elmt.appendChild(elmt.ownerDocument.createElement("br"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7083
                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
  7084
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7085
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7086
    },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7087
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7088
    fillInfoBubble: function(elmt, theme, labeller) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7089
        var doc = elmt.ownerDocument;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7090
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7091
        var title = this.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7092
        var link = this.getLink();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7093
        var image = this.getImage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7094
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7095
        if (image != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7096
            var img = doc.createElement("img");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7097
            img.src = image;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7098
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7099
            theme.event.bubble.imageStyler(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7100
            elmt.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7101
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7102
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7103
        var divTitle = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7104
        var textTitle = doc.createTextNode(title);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7105
        if (link != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7106
            var a = doc.createElement("a");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7107
            a.href = link;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7108
            a.appendChild(textTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7109
            divTitle.appendChild(a);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7110
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7111
            divTitle.appendChild(textTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7112
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7113
        theme.event.bubble.titleStyler(divTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7114
        elmt.appendChild(divTitle);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7115
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7116
        var divBody = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7117
        this.fillDescription(divBody);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7118
        theme.event.bubble.bodyStyler(divBody);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7119
        elmt.appendChild(divBody);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7121
        var divTime = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7122
        this.fillTime(divTime, labeller);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7123
        theme.event.bubble.timeStyler(divTime);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7124
        elmt.appendChild(divTime);
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
        var divWiki = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7127
        this.fillWikiInfo(divWiki);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7128
        theme.event.bubble.wikiStyler(divWiki);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7129
        elmt.appendChild(divWiki);
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  7134
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7135
 *  Original Event Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  7136
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7137
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7138
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  7139
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7140
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7141
 * 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
  7142
 * 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
  7143
 * 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
  7144
 * specific event.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7145
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7146
 * 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
  7147
 * events' elements on the Timeline--
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7148
 *
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7149
 * element id format for labels, icons, tapes:
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7150
 *   labels: label-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7151
 *    icons: icon-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7152
 *    tapes: tape1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7153
 *           tape2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7154
 *           // some events have more than one tape
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7155
 *    highlight: highlight1-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7156
 *               highlight2-tl-<timelineID>-<band_index>-<evt.id>
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7157
 *           // 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
  7158
 * 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
  7159
 * by using Timeline.EventUtils.decodeEventElID
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7160
 *
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  7161
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7162
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7163
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7164
/*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7165
 *    eventPaintListener functions receive calls about painting.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7166
 *    function(band, op, evt, els)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7167
 *       context: 'this' will be an OriginalEventPainter object.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7168
 *                It has properties and methods for obtaining
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7169
 *                the relevant band, timeline, etc
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7170
 *       band = the band being painted
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7171
 *       op = 'paintStarting' // the painter is about to remove
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7172
 *            all previously painted events, if any. It will
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7173
 *            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
  7174
 *            pass the filter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7175
 *            evt = null, els = null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7176
 *       op = 'paintEnded' // the painter has finished painting
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7177
 *            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
  7178
 *            evt = null, els = null
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7179
 *       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
  7180
 *            evt = event just painted
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7181
 *            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
  7182
 *                  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
  7183
 *                  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
  7184
 *                  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
  7185
 *                  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
  7186
 *      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
  7187
 *      or passed the filter.
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7190
Timeline.OriginalEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7191
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7192
    this._onSelectListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7193
    this._eventPaintListeners = [];
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
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7196
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7197
    this._frc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7198
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7199
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7200
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7201
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7202
Timeline.OriginalEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7203
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7204
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7205
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7206
    this._backLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7207
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7208
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7209
    this._highlightLayer = null;
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
    this._eventIdToElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7212
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7213
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7214
Timeline.OriginalEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7215
    return 'original';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7216
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7217
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7218
Timeline.OriginalEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7219
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7220
};
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
Timeline.OriginalEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7223
    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
  7224
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7225
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7226
            break;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7230
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7231
Timeline.OriginalEventPainter.prototype.addEventPaintListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7232
    this._eventPaintListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7233
};
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
Timeline.OriginalEventPainter.prototype.removeEventPaintListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7236
    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
  7237
        if (this._eventPaintListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7238
            this._eventPaintListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7239
            break;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7243
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7244
Timeline.OriginalEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7245
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7246
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7247
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7248
Timeline.OriginalEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7249
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7250
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7251
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7252
Timeline.OriginalEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7253
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7254
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7255
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7256
Timeline.OriginalEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7257
    this._highlightMatcher = highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7258
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7259
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7260
Timeline.OriginalEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7261
    // 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
  7262
    // visible on screen and some extra.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7263
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7264
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7265
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7266
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7267
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7268
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7269
    this._fireEventPaintListeners('paintStarting', null, null);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7270
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7271
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7272
    var metrics = this._computeMetrics();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7273
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7274
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7275
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7276
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7277
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7278
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7279
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7280
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7281
        function(evt) { return -1; };
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
    var iterator = eventSource.getEventReverseIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7284
    while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7285
        var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7286
        if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7287
            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
  7288
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7289
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7290
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7291
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7292
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7293
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7294
    // 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
  7295
    this._band.updateEventTrackInfo(this._tracks.length, metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7296
    this._fireEventPaintListeners('paintEnded', null, null);
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
    this._setOrthogonalOffset(metrics);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7299
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7300
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7301
Timeline.OriginalEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7302
    this._setOrthogonalOffset(this._computeMetrics());
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7305
Timeline.OriginalEventPainter.prototype._setOrthogonalOffset = function(metrics) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7306
    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
  7307
    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
  7308
    var orthogonalOffset = Math.max(minOrthogonalOffset, this._band.getViewOrthogonalOffset());
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
    this._highlightLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7311
        this._lineLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7312
            this._eventLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7313
                orthogonalOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7314
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7315
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7316
Timeline.OriginalEventPainter.prototype._computeMetrics = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7317
     var eventTheme = this._params.theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7318
     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
  7319
                         this._frc.getLineHeight());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7320
     var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7321
            trackOffset: eventTheme.track.offset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7322
            trackHeight: trackHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7323
               trackGap: eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7324
         trackIncrement: trackHeight + eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7325
                   icon: eventTheme.instant.icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7326
              iconWidth: eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7327
             iconHeight: eventTheme.instant.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7328
             labelWidth: eventTheme.label.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7329
           maxLabelChar: eventTheme.label.maxLabelChar,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7330
    impreciseIconMargin: eventTheme.instant.impreciseIconMargin
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7331
     };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7332
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7333
     return metrics;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7336
Timeline.OriginalEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7337
    // 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
  7338
    // Prepare blank layers for painting.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7339
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7340
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7341
    if (this._backLayer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7342
        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
  7343
        this._backLayer.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7344
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7345
        var eventLabelPrototype = document.createElement("span");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7346
        eventLabelPrototype.className = "timeline-event-label";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7347
        this._backLayer.appendChild(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7348
        this._frc = SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
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._frc.update();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7351
    this._tracks = [];
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._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7354
        band.removeLayerDiv(this._highlightLayer);
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._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7357
    this._highlightLayer.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._lineLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7360
        band.removeLayerDiv(this._lineLayer);
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._lineLayer = band.createLayerDiv(110, "timeline-band-lines");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7363
    this._lineLayer.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
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7366
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7367
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7368
    this._eventLayer = band.createLayerDiv(115, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7369
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7370
};
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
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
  7373
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7374
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7375
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7376
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7377
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7378
};
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
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
  7381
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7382
        this.paintImpreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7383
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7384
        this.paintPreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7385
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7386
}
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
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
  7389
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7390
        this.paintImpreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7391
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7392
        this.paintPreciseDurationEvent(evt, metrics, theme, highlightIndex);
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
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7395
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7396
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
  7397
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7398
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7399
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7400
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7401
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7402
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7403
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7404
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7405
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7406
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7407
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7408
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7409
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7410
    var rightEdge = labelRight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7411
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7412
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7413
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7414
        metrics.trackOffset + track * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7415
        metrics.trackHeight / 2 - labelSize.height / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7416
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7417
    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
  7418
    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
  7419
        labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7420
    var els = [iconElmtData.elmt, labelElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7421
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7422
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7423
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7424
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7425
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7426
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7427
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7428
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7429
    var hDiv = this._createHighlightDiv(highlightIndex, iconElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7430
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7431
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7432
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7433
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7434
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7435
    this._tracks[track] = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7436
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7437
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7438
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
  7439
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7440
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7441
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7442
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7443
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7444
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7445
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7446
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7447
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7448
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7449
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7450
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7451
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7452
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7453
    var labelRight = labelLeft + labelSize.width;
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 rightEdge = Math.max(labelRight, endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7456
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7457
    var tapeHeight = theme.event.tape.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7458
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7459
        metrics.trackOffset + track * metrics.trackIncrement + tapeHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7460
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7461
    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
  7462
    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
  7463
                        labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7464
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7465
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7466
    color = color != null ? color : theme.event.instant.impreciseColor;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7467
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7468
    var tapeElmtData = this._paintEventTape(evt, track, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7469
        color, theme.event.instant.impreciseOpacity, metrics, theme, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7470
    var els = [iconElmtData.elmt, labelElmtData.elmt, tapeElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7471
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7472
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7473
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7474
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7475
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7476
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7477
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7478
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7479
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7480
    var hDiv = this._createHighlightDiv(highlightIndex, iconElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7481
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7482
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7483
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7484
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7485
    this._tracks[track] = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7486
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7487
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7488
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
  7489
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7490
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7491
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7492
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7493
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7494
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7495
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7496
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7497
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7498
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7499
    var labelLeft = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7500
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7501
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7502
    var rightEdge = Math.max(labelRight, endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7503
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7504
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7505
        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
  7506
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7507
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7508
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7509
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7510
    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
  7511
    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
  7512
      labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7513
    var els = [tapeElmtData.elmt, labelElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7514
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7515
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7516
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7517
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7518
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7519
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7520
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7521
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7522
    var hDiv = this._createHighlightDiv(highlightIndex, tapeElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7523
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7524
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7525
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7526
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7527
    this._tracks[track] = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7528
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7529
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7530
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
  7531
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7532
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7533
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7534
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7535
    var latestStartDate = evt.getLatestStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7536
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7537
    var earliestEndDate = evt.getEarliestEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7538
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7539
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7540
    var latestStartPixel = Math.round(this._band.dateToPixelOffset(latestStartDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7541
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7542
    var earliestEndPixel = Math.round(this._band.dateToPixelOffset(earliestEndDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7543
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7544
    var labelDivClassName = this._getLabelDivClassName(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7545
    var labelSize = this._frc.computeSize(text, labelDivClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7546
    var labelLeft = latestStartPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7547
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7548
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7549
    var rightEdge = Math.max(labelRight, endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7550
    var track = this._findFreeTrack(evt, rightEdge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7551
    var labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7552
        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
  7553
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7554
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7555
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7556
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7557
    // Imprecise events can have two event tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7558
    // 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
  7559
    var impreciseTapeElmtData = this._paintEventTape(evt, track, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7560
        theme.event.duration.impreciseColor,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7561
        theme.event.duration.impreciseOpacity, metrics, theme, 0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7562
    // The precise dates tape, regular (100%) opacity
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7563
    var tapeElmtData = this._paintEventTape(evt, track, latestStartPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7564
        earliestEndPixel, color, 100, metrics, theme, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7565
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7566
    var labelElmtData = this._paintEventLabel(evt, text, labelLeft, labelTop,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7567
        labelSize.width, labelSize.height, theme, labelDivClassName, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7568
    var els = [impreciseTapeElmtData.elmt, tapeElmtData.elmt, labelElmtData.elmt];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7569
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7570
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7571
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7572
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7573
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7574
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7575
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7576
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7577
    var hDiv = this._createHighlightDiv(highlightIndex, tapeElmtData, theme, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7578
    if (hDiv != null) {els.push(hDiv);}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7579
    this._fireEventPaintListeners('paintedEvent', evt, els);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7580
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7581
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7582
    this._tracks[track] = startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7583
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7584
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7585
Timeline.OriginalEventPainter.prototype._encodeEventElID = function(elType, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7586
    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
  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
Timeline.OriginalEventPainter.prototype._findFreeTrack = function(event, rightEdge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7590
    var trackAttribute = event.getTrackNum();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7591
    if (trackAttribute != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7592
        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
  7593
    }
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
    // normal case: find an open track
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7596
    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
  7597
        var t = this._tracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7598
        if (t > rightEdge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7599
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7600
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7601
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7602
    return i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7603
};
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
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
  7606
    // 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
  7607
    // 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
  7608
    var icon = evt.getIcon();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7609
    icon = icon != null ? icon : metrics.icon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7610
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7611
    var top; // top of the icon
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7612
    if (tapeHeight > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7613
        top = metrics.trackOffset + iconTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7614
              tapeHeight + metrics.impreciseIconMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7615
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7616
        var middle = metrics.trackOffset + iconTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7617
                     metrics.trackHeight / 2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7618
        top = Math.round(middle - metrics.iconHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7619
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7620
    var img = SimileAjax.Graphics.createTranslucentImage(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7621
    var iconDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7622
    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
  7623
    iconDiv.id = this._encodeEventElID('icon', evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7624
    iconDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7625
    iconDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7626
    iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7627
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7628
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7629
        iconDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7630
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7631
    this._eventLayer.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7632
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7633
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7634
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7635
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7636
        width:  metrics.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7637
        height: metrics.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7638
        elmt:   iconDiv
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7641
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7642
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
  7643
    height, theme, labelDivClassName, highlightIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7644
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7645
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7646
    var labelDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7647
    labelDiv.className = labelDivClassName;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7648
    labelDiv.id = this._encodeEventElID('label', evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7649
    labelDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7650
    labelDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7651
    labelDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7652
    labelDiv.innerHTML = text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7653
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7654
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7655
        labelDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7656
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7657
    var color = evt.getTextColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7658
    if (color == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7659
        color = evt.getColor();
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
    if (color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7662
        labelDiv.style.color = color;
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
    if (theme.event.highlightLabelBackground && highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7665
        labelDiv.style.background = this._getHighlightColor(highlightIndex, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7666
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7667
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7668
    this._eventLayer.appendChild(labelDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7669
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7670
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7671
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7672
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7673
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7674
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7675
        elmt:   labelDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7676
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7677
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7678
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7679
Timeline.OriginalEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7680
    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
  7681
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7682
    var tapeWidth = endPixel - startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7683
    var tapeHeight = theme.event.tape.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7684
    var top = metrics.trackOffset + iconTrack * metrics.trackIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7685
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7686
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7687
    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
  7688
    tapeDiv.id = this._encodeEventElID('tape' + tape_index, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7689
    tapeDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7690
    tapeDiv.style.width = tapeWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7691
    tapeDiv.style.height = tapeHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7692
    tapeDiv.style.top = top + "px";
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
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7695
        tapeDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7696
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7697
    if(color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7698
        tapeDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7699
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7700
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7701
    var backgroundImage = evt.getTapeImage();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7702
    var backgroundRepeat = evt.getTapeRepeat();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7703
    backgroundRepeat = backgroundRepeat != null ? backgroundRepeat : 'repeat';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7704
    if(backgroundImage != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7705
      tapeDiv.style.backgroundImage = "url(" + backgroundImage + ")";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7706
      tapeDiv.style.backgroundRepeat = backgroundRepeat;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7707
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7708
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7709
    SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7710
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7711
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7712
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7713
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7714
        left:   startPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7715
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7716
        width:  tapeWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7717
        height: tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7718
        elmt:   tapeDiv
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
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7721
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7722
Timeline.OriginalEventPainter.prototype._getLabelDivClassName = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7723
    return this._getElClassName('timeline-event-label', evt, 'label');
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7726
Timeline.OriginalEventPainter.prototype._getElClassName = function(elClassName, evt, prefix) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7727
    // 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
  7728
    var evt_classname = evt.getClassName(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7729
        pieces = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7730
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7731
    if (evt_classname) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7732
      if (prefix) {pieces.push(prefix + '-' + evt_classname + ' ');}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7733
      pieces.push(evt_classname + ' ');
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7734
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7735
    pieces.push(elClassName);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7736
    return(pieces.join(''));
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7739
Timeline.OriginalEventPainter.prototype._getHighlightColor = function(highlightIndex, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7740
    var highlightColors = theme.event.highlightColors;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7741
    return highlightColors[Math.min(highlightIndex, highlightColors.length - 1)];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7742
};
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
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
  7745
    var div = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7746
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7747
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7748
        var color = this._getHighlightColor(highlightIndex, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7749
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7750
        div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7751
        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
  7752
        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
  7753
                                                           // highlight divs for tapes + icons
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7754
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7755
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7756
        div.style.left =    (dimensions.left - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7757
        div.style.width =   (dimensions.width + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7758
        div.style.top =     (dimensions.top - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7759
        div.style.height =  (dimensions.height + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7760
        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7761
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7762
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7763
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7764
    return div;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7765
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7766
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7767
Timeline.OriginalEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7768
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7769
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7770
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7771
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7772
        evt
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
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7775
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7776
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7777
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7778
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7779
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7780
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7781
Timeline.OriginalEventPainter.prototype._onClickDurationEvent = function(target, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7782
    if ("pageX" in domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7783
        var x = domEvt.pageX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7784
        var y = domEvt.pageY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7785
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7786
        var c = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7787
        var x = domEvt.offsetX + c.left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7788
        var y = domEvt.offsetY + c.top;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7789
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7790
    this._showBubble(x, y, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7791
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7792
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7793
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7794
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7795
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7796
};
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
Timeline.OriginalEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7799
    var elmt = this._eventIdToElmt[evt.getID()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7800
    if (elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7801
        var c = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7802
        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
  7803
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7806
Timeline.OriginalEventPainter.prototype._showBubble = function(x, y, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7807
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7808
    var themeBubble = this._params.theme.event.bubble;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7809
    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
  7810
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7811
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7812
    SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7813
        themeBubble.width, null, themeBubble.maxHeight);
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._fireOnSelect = function(eventID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7817
    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
  7818
        this._onSelectListeners[i](eventID);
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
Timeline.OriginalEventPainter.prototype._fireEventPaintListeners = function(op, evt, els) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7823
    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
  7824
        this._eventPaintListeners[i](this._band, op, evt, els);
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
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  7827
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7828
 *  Detailed Event Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  7829
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7830
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7831
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7832
// Note: a number of features from original-painter
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7833
//       are not yet implemented in detailed painter.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7834
//       Eg classname, id attributes for icons, labels, tapes
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7835
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7836
Timeline.DetailedEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7837
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7838
    this._onSelectListeners = [];
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
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7841
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7842
    this._frc = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7843
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7844
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7845
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7846
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7847
Timeline.DetailedEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7848
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7849
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7850
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7851
    this._backLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7852
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7853
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7854
    this._highlightLayer = null;
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
    this._eventIdToElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7857
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7858
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7859
Timeline.DetailedEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7860
    return 'detailed';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7861
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7862
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7863
Timeline.DetailedEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7864
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7865
};
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
Timeline.DetailedEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7868
    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
  7869
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7870
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7871
            break;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7875
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7876
Timeline.DetailedEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7877
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7878
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7879
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7880
Timeline.DetailedEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7881
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7882
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7883
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7884
Timeline.DetailedEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7885
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7886
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7887
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7888
Timeline.DetailedEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7889
    this._highlightMatcher = highlightMatcher;
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
Timeline.DetailedEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7893
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7894
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7895
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7896
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7897
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7898
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7899
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7900
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7901
    var eventTheme = this._params.theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7902
    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
  7903
    var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7904
        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
  7905
        trackHeight:    trackHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7906
        trackGap:       eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7907
        trackIncrement: trackHeight + eventTheme.track.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7908
        icon:           eventTheme.instant.icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7909
        iconWidth:      eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7910
        iconHeight:     eventTheme.instant.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7911
        labelWidth:     eventTheme.label.width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7912
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7913
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7914
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7915
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7916
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7917
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7918
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7919
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7920
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7921
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7922
        function(evt) { return -1; };
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
    var iterator = eventSource.getEventReverseIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7925
    while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7926
        var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7927
        if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7928
            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
  7929
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7930
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7931
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7932
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7933
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7934
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7935
    // 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
  7936
    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
  7937
                                 metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7938
};
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
Timeline.DetailedEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7941
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7942
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7943
Timeline.DetailedEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7944
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7945
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7946
    if (this._backLayer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7947
        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
  7948
        this._backLayer.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7949
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7950
        var eventLabelPrototype = document.createElement("span");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7951
        eventLabelPrototype.className = "timeline-event-label";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7952
        this._backLayer.appendChild(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7953
        this._frc = SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7954
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7955
    this._frc.update();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7956
    this._lowerTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7957
    this._upperTracks = [];
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._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7960
        band.removeLayerDiv(this._highlightLayer);
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._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7963
    this._highlightLayer.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._lineLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7966
        band.removeLayerDiv(this._lineLayer);
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._lineLayer = band.createLayerDiv(110, "timeline-band-lines");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7969
    this._lineLayer.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
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7972
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7973
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7974
    this._eventLayer = band.createLayerDiv(110, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7975
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7976
};
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
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
  7979
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7980
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7981
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7982
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7983
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7984
};
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
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
  7987
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7988
        this.paintImpreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7989
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7990
        this.paintPreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7991
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7992
}
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
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
  7995
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7996
        this.paintImpreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7997
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  7998
        this.paintPreciseDurationEvent(evt, metrics, theme, highlightIndex);
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
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8001
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8002
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
  8003
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8004
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8005
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8006
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8007
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8008
    var iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8009
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8010
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8011
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8012
    var iconTrack = this._findFreeTrackForSolid(iconRightEdge, startPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8013
    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
  8014
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8015
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8016
    var labelTrack = iconTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8017
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8018
    var iconTrackData = this._getTrackData(iconTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8019
    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
  8020
        iconTrackData.solid = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8021
        iconTrackData.text = labelLeft;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8022
    } else { // label on a different track, below icon
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8023
        iconTrackData.solid = iconLeftEdge;
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
        labelLeft = startPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8026
        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
  8027
        this._getTrackData(labelTrack).text = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8028
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8029
        this._paintEventLine(evt, startPixel, iconTrack, labelTrack, metrics, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8030
    }
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 labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8033
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8034
        metrics.trackHeight / 2 - labelSize.height / 2);
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
    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
  8037
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8038
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8039
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8040
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8041
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8042
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8043
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8044
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8045
    this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8046
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8047
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8048
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8049
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8050
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
  8051
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8052
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8053
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8054
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8055
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8056
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8057
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
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 iconRightEdge = Math.round(startPixel + metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8060
    var iconLeftEdge = Math.round(startPixel - metrics.iconWidth / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8061
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8062
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8063
    var iconTrack = this._findFreeTrackForSolid(endPixel, startPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8064
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8065
    var tapeElmtData = this._paintEventTape(evt, iconTrack, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8066
        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
  8067
    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
  8068
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8069
    var iconTrackData = this._getTrackData(iconTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8070
    iconTrackData.solid = iconLeftEdge;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8071
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8072
    var labelLeft = iconRightEdge + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8073
    var labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8074
    var labelTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8075
    if (labelRight < endPixel) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8076
        labelTrack = iconTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8077
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8078
        labelLeft = startPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8079
        labelRight = labelLeft + labelSize.width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8080
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8081
        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
  8082
        this._getTrackData(labelTrack).text = iconLeftEdge;
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
        this._paintEventLine(evt, startPixel, iconTrack, labelTrack, metrics, 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 labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8087
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8088
        metrics.trackHeight / 2 - labelSize.height / 2);
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
    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
  8091
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8092
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8093
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8094
        return self._onClickInstantEvent(iconElmtData.elmt, domEvt, evt);
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
    SimileAjax.DOM.registerEvent(iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8097
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8098
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8099
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8100
    this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8101
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8102
    this._eventIdToElmt[evt.getID()] = iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8103
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8104
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8105
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
  8106
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8107
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8108
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8109
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8110
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8111
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8112
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8113
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8114
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8115
    var tapeTrack = this._findFreeTrackForSolid(endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8116
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8117
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8118
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8119
    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
  8120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8121
    var tapeTrackData = this._getTrackData(tapeTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8122
    tapeTrackData.solid = startPixel;
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 labelLeft = startPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8125
    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
  8126
    this._getTrackData(labelTrack).text = startPixel - 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
    this._paintEventLine(evt, startPixel, tapeTrack, labelTrack, metrics, 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 labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8131
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8132
        metrics.trackHeight / 2 - labelSize.height / 2);
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
    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
  8135
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8136
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8137
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8138
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8139
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8140
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8141
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8142
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8143
    this._createHighlightDiv(highlightIndex, tapeElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8144
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8145
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8146
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8147
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8148
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
  8149
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8150
    var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8151
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8152
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8153
    var latestStartDate = evt.getLatestStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8154
    var endDate = evt.getEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8155
    var earliestEndDate = evt.getEarliestEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8157
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8158
    var latestStartPixel = Math.round(this._band.dateToPixelOffset(latestStartDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8159
    var endPixel = Math.round(this._band.dateToPixelOffset(endDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8160
    var earliestEndPixel = Math.round(this._band.dateToPixelOffset(earliestEndDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8161
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8162
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8163
    var tapeTrack = this._findFreeTrackForSolid(endPixel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8164
    var color = evt.getColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8165
    color = color != null ? color : theme.event.duration.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8166
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8167
    var impreciseTapeElmtData = this._paintEventTape(evt, tapeTrack, startPixel, endPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8168
        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
  8169
    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
  8170
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8171
    var tapeTrackData = this._getTrackData(tapeTrack);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8172
    tapeTrackData.solid = startPixel;
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 labelLeft = latestStartPixel + theme.event.label.offsetFromLine;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8175
    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
  8176
    this._getTrackData(labelTrack).text = latestStartPixel - 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
    this._paintEventLine(evt, latestStartPixel, tapeTrack, labelTrack, metrics, 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 labelTop = Math.round(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8181
        metrics.trackOffset + labelTrack * metrics.trackIncrement +
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8182
        metrics.trackHeight / 2 - labelSize.height / 2);
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
    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
  8185
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8186
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8187
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8188
        return self._onClickDurationEvent(tapeElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8189
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8190
    SimileAjax.DOM.registerEvent(tapeElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8191
    SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8192
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8193
    this._createHighlightDiv(highlightIndex, tapeElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8194
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8195
    this._eventIdToElmt[evt.getID()] = tapeElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8196
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8197
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8198
Timeline.DetailedEventPainter.prototype._findFreeTrackForSolid = function(solidEdge, softEdge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8199
    for (var i = 0; true; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8200
        if (i < this._lowerTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8201
            var t = this._lowerTracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8202
            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
  8203
                return i;
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
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8206
            this._lowerTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8207
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8208
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8209
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8210
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8211
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8212
            return 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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8215
        if (i < this._upperTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8216
            var t = this._upperTracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8217
            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
  8218
                return -1 - i;
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
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8221
            this._upperTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8222
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8223
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8224
                line:   Number.POSITIVE_INFINITY
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8227
            return -1 - i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8228
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8229
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8230
};
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
Timeline.DetailedEventPainter.prototype._findFreeTrackForText = function(fromTrack, edge, occupiedTrackVisitor) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8233
    var extendUp;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8234
    var index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8235
    var firstIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8236
    var result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8237
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8238
    if (fromTrack < 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8239
        extendUp = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8240
        firstIndex = -fromTrack;
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._findFreeUpperTrackForText(firstIndex, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8243
        result = -1 - index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8244
    } else if (fromTrack > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8245
        extendUp = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8246
        firstIndex = fromTrack + 1;
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
        index = this._findFreeLowerTrackForText(firstIndex, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8249
        result = index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8250
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8251
        var upIndex = this._findFreeUpperTrackForText(0, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8252
        var downIndex = this._findFreeLowerTrackForText(1, edge);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8253
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8254
        if (downIndex - 1 <= upIndex) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8255
            extendUp = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8256
            firstIndex = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8257
            index = downIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8258
            result = index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8259
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8260
            extendUp = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8261
            firstIndex = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8262
            index = upIndex;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8263
            result = -1 - index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8264
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8265
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8266
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8267
    if (extendUp) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8268
        if (index == this._upperTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8269
            this._upperTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8270
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8271
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8272
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8273
            });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8274
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8275
        for (var i = firstIndex; i < index; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8276
            occupiedTrackVisitor(this._upperTracks[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8277
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8278
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8279
        if (index == this._lowerTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8280
            this._lowerTracks.push({
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8281
                solid:  Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8282
                text:   Number.POSITIVE_INFINITY,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8283
                line:   Number.POSITIVE_INFINITY
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8284
            });
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
        for (var i = firstIndex; i < index; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8287
            occupiedTrackVisitor(this._lowerTracks[i]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8288
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8289
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8290
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8291
};
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
Timeline.DetailedEventPainter.prototype._findFreeLowerTrackForText = function(index, edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8294
    for (; index < this._lowerTracks.length; index++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8295
        var t = this._lowerTracks[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8296
        if (Math.min(t.solid, t.text) >= edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8297
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8298
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8299
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8300
    return index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8301
};
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
Timeline.DetailedEventPainter.prototype._findFreeUpperTrackForText = function(index, edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8304
    for (; index < this._upperTracks.length; index++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8305
        var t = this._upperTracks[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8306
        if (Math.min(t.solid, t.text) >= edge) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8307
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8308
        }
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
    return index;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8311
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8312
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8313
Timeline.DetailedEventPainter.prototype._getTrackData = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8314
    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
  8315
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8316
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8317
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
  8318
    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
  8319
    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
  8320
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8321
    var lineStyle = "1px solid " + theme.event.label.lineColor;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8322
    var lineDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8323
	lineDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8324
    lineDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8325
    lineDiv.style.width = theme.event.label.offsetFromLine + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8326
    lineDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8327
    if (startTrack > endTrack) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8328
        lineDiv.style.top = (top - height) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8329
        lineDiv.style.borderTop = lineStyle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8330
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8331
        lineDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8332
        lineDiv.style.borderBottom = lineStyle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8333
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8334
    lineDiv.style.borderLeft = lineStyle;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8335
    this._lineLayer.appendChild(lineDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8336
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8337
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8338
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
  8339
    var icon = evt.getIcon();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8340
    icon = icon != null ? icon : metrics.icon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8341
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8342
    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
  8343
    var top = Math.round(middle - metrics.iconHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8344
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8345
    var img = SimileAjax.Graphics.createTranslucentImage(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8346
    var iconDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8347
    iconDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8348
    iconDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8349
    iconDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8350
    iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8351
    iconDiv.style.cursor = "pointer";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8352
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8353
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8354
        iconDiv.title = evt._title
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8355
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8356
    this._eventLayer.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8357
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8358
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8359
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8360
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8361
        width:  metrics.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8362
        height: metrics.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8363
        elmt:   iconDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8364
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8365
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8366
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8367
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
  8368
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8369
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8370
    var labelBackgroundDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8371
    labelBackgroundDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8372
    labelBackgroundDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8373
    labelBackgroundDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8374
    labelBackgroundDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8375
    labelBackgroundDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8376
    labelBackgroundDiv.style.backgroundColor = theme.event.label.backgroundColor;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8377
    SimileAjax.Graphics.setOpacity(labelBackgroundDiv, theme.event.label.backgroundOpacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8378
    this._eventLayer.appendChild(labelBackgroundDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8379
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8380
    var labelDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8381
    labelDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8382
    labelDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8383
    labelDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8384
    labelDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8385
    labelDiv.innerHTML = text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8386
    labelDiv.style.cursor = "pointer";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8387
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8388
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8389
        labelDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8390
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8391
    var color = evt.getTextColor();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8392
    if (color == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8393
        color = evt.getColor();
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
    if (color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8396
        labelDiv.style.color = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8397
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8398
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8399
    this._eventLayer.appendChild(labelDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8400
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8401
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8402
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8403
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8404
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8405
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8406
        elmt:   labelDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8407
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8408
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8409
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8410
Timeline.DetailedEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8411
    evt, iconTrack, startPixel, endPixel, color, opacity, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8412
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8413
    var tapeWidth = endPixel - startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8414
    var tapeHeight = theme.event.tape.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8415
    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
  8416
    var top = Math.round(middle - tapeHeight / 2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8417
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8418
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8419
    tapeDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8420
    tapeDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8421
    tapeDiv.style.width = tapeWidth + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8422
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8423
    tapeDiv.style.height = tapeHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8424
    tapeDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8425
    tapeDiv.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8426
    tapeDiv.style.cursor = "pointer";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8427
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8428
    if(evt._title != null)
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8429
        tapeDiv.title = evt._title;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8430
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8431
    SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8432
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8433
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8434
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8435
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8436
        left:   startPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8437
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8438
        width:  tapeWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8439
        height: tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8440
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8441
    };
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8444
Timeline.DetailedEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8445
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8446
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8447
        var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8448
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8449
        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
  8450
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8451
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8452
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8453
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8454
        div.style.left =    (dimensions.left - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8455
        div.style.width =   (dimensions.width + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8456
        div.style.top =     (dimensions.top - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8457
        div.style.height =  (dimensions.height + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8458
        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8459
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8460
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8461
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8462
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8463
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8464
Timeline.DetailedEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8465
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8466
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8467
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8468
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8469
        evt
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
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8472
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8473
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8474
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8475
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8476
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8477
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8478
Timeline.DetailedEventPainter.prototype._onClickDurationEvent = function(target, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8479
    if ("pageX" in domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8480
        var x = domEvt.pageX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8481
        var y = domEvt.pageY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8482
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8483
        var c = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8484
        var x = domEvt.offsetX + c.left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8485
        var y = domEvt.offsetY + c.top;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8486
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8487
    this._showBubble(x, y, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8488
    this._fireOnSelect(evt.getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8489
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8490
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8491
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8492
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8493
};
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
Timeline.DetailedEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8496
    var elmt = this._eventIdToElmt[evt.getID()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8497
    if (elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8498
        var c = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8499
        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
  8500
    }
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8503
Timeline.DetailedEventPainter.prototype._showBubble = function(x, y, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8504
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8505
    var themeBubble = this._params.theme.event.bubble;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8506
    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
  8507
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8508
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8509
    SimileAjax.Graphics.createBubbleForContentAndPoint(div, x, y,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8510
       themeBubble.width, null, themeBubble.maxHeight);
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
Timeline.DetailedEventPainter.prototype._fireOnSelect = function(eventID) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8514
    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
  8515
        this._onSelectListeners[i](eventID);
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
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  8518
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8519
 *  Overview Event Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  8520
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8521
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8522
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8523
Timeline.OverviewEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8524
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8525
    this._onSelectListeners = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8526
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8527
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8528
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8529
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8530
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8531
Timeline.OverviewEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8532
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8533
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8534
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8535
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8536
    this._highlightLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8537
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8538
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8539
Timeline.OverviewEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8540
    return 'overview';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8541
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8542
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8543
Timeline.OverviewEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8544
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8545
};
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
Timeline.OverviewEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8548
    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
  8549
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8550
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8551
            break;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8555
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8556
Timeline.OverviewEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8557
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8558
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8559
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8560
Timeline.OverviewEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8561
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8562
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8563
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8564
Timeline.OverviewEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8565
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8566
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8567
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8568
Timeline.OverviewEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8569
    this._highlightMatcher = highlightMatcher;
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
Timeline.OverviewEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8573
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8574
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8575
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8576
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8577
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8578
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8579
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8580
    var eventTheme = this._params.theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8581
    var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8582
        trackOffset:    eventTheme.overviewTrack.offset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8583
        trackHeight:    eventTheme.overviewTrack.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8584
        trackGap:       eventTheme.overviewTrack.gap,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8585
        trackIncrement: eventTheme.overviewTrack.height + eventTheme.overviewTrack.gap
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8586
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8587
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8588
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8589
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8590
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8591
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8592
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8593
        function(evt) { return true; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8594
    var highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8595
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8596
        function(evt) { return -1; };
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
    var iterator = eventSource.getEventReverseIterator(minDate, maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8599
    while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8600
        var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8601
        if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8602
            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
  8603
        }
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
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8607
    this._eventLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8608
    // 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
  8609
    this._band.updateEventTrackInfo(this._tracks.length, metrics.trackIncrement);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8610
};
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
Timeline.OverviewEventPainter.prototype.softPaint = function() {
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8615
Timeline.OverviewEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8616
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8617
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8618
    this._tracks = [];
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._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8621
        band.removeLayerDiv(this._highlightLayer);
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._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8624
    this._highlightLayer.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
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8627
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8628
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8629
    this._eventLayer = band.createLayerDiv(110, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8630
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8631
};
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
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
  8634
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8635
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8636
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8637
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8640
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8641
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
  8642
    var startDate = evt.getStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8643
    var startPixel = Math.round(this._band.dateToPixelOffset(startDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8644
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8645
    var color = evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8646
        klassName = evt.getClassName();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8647
    if (klassName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8648
      color = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8649
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8650
      color = color != null ? color : theme.event.duration.color;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8653
    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
  8654
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8655
    this._createHighlightDiv(highlightIndex, tickElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8656
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8657
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8658
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
  8659
    var latestStartDate = evt.getLatestStart();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8660
    var earliestEndDate = evt.getEarliestEnd();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8661
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8662
    var latestStartPixel = Math.round(this._band.dateToPixelOffset(latestStartDate));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8663
    var earliestEndPixel = Math.round(this._band.dateToPixelOffset(earliestEndDate));
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
    var tapeTrack = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8666
    for (; tapeTrack < this._tracks.length; tapeTrack++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8667
        if (earliestEndPixel < this._tracks[tapeTrack]) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8668
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8669
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8670
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8671
    this._tracks[tapeTrack] = earliestEndPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8672
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8673
    var color = evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8674
        klassName = evt.getClassName();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8675
    if (klassName) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8676
      color = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8677
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8678
      color = color != null ? color : theme.event.duration.color;
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
    var tapeElmtData = this._paintEventTape(evt, tapeTrack, latestStartPixel, earliestEndPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8682
      color, 100, 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
    this._createHighlightDiv(highlightIndex, tapeElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8685
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8686
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8687
Timeline.OverviewEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8688
    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
  8689
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8690
    var top = metrics.trackOffset + track * metrics.trackIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8691
    var width = right - left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8692
    var height = metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8693
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8694
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8695
    tapeDiv.className = 'timeline-small-event-tape'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8696
    if (klassName) {tapeDiv.className += ' small-' + klassName;}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8697
    tapeDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8698
    tapeDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8699
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8700
    tapeDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8701
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8702
    if (color) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8703
      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
  8704
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8705
 //   tapeDiv.style.overflow = "hidden";   // now set in css
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8706
 //   tapeDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8707
    if(opacity<100) SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8708
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8709
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8710
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8711
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8712
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8713
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8714
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8715
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8716
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8717
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8718
}
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8719
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8720
Timeline.OverviewEventPainter.prototype._paintEventTick = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8721
    evt, left, color, opacity, metrics, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8722
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8723
    var height = theme.event.overviewTrack.tickHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8724
    var top = metrics.trackOffset - height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8725
    var width = 1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8726
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8727
    var tickDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8728
	  tickDiv.className = 'timeline-small-event-icon'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8729
    tickDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8730
    tickDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8731
  //  tickDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8732
  //  tickDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8733
  //  tickDiv.style.height = height + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8734
  //  tickDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8735
  //  tickDiv.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8736
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8737
    var klassName = evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8738
    if (klassName) {tickDiv.className +=' small-' + klassName};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8739
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8740
    if(opacity<100) {SimileAjax.Graphics.setOpacity(tickDiv, opacity)};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8741
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8742
    this._eventLayer.appendChild(tickDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8743
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8744
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8745
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8746
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8747
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8748
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8749
        elmt:   tickDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8750
    };
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8753
Timeline.OverviewEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8754
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8755
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8756
        var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8757
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8758
        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
  8759
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8760
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8761
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8762
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8763
        div.style.left =    (dimensions.left - 1) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8764
        div.style.width =   (dimensions.width + 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8765
        div.style.top =     (dimensions.top - 1) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8766
        div.style.height =  (dimensions.height + 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8767
        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8768
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8769
        this._highlightLayer.appendChild(div);
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
};
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
Timeline.OverviewEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8774
    // not implemented
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8775
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  8776
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8777
 *  Compact Event Painter
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  8778
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8779
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8780
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8781
Timeline.CompactEventPainter = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8782
    this._params = params;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8783
    this._onSelectListeners = [];
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
    this._filterMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8786
    this._highlightMatcher = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8787
    this._frc = null;
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
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8790
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8791
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8792
Timeline.CompactEventPainter.prototype.getType = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8793
    return 'compact';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8794
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8795
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8796
Timeline.CompactEventPainter.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8797
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8798
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8799
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8800
    this._backLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8801
    this._eventLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8802
    this._lineLayer = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8803
    this._highlightLayer = null;
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
    this._eventIdToElmt = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8806
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8807
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8808
Timeline.CompactEventPainter.prototype.addOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8809
    this._onSelectListeners.push(listener);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8810
};
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
Timeline.CompactEventPainter.prototype.removeOnSelectListener = function(listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8813
    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
  8814
        if (this._onSelectListeners[i] == listener) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8815
            this._onSelectListeners.splice(i, 1);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8816
            break;
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
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8820
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8821
Timeline.CompactEventPainter.prototype.getFilterMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8822
    return this._filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8823
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8824
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8825
Timeline.CompactEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8826
    this._filterMatcher = filterMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8827
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8828
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8829
Timeline.CompactEventPainter.prototype.getHighlightMatcher = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8830
    return this._highlightMatcher;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8831
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8832
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8833
Timeline.CompactEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8834
    this._highlightMatcher = highlightMatcher;
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
Timeline.CompactEventPainter.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8838
    var eventSource = this._band.getEventSource();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8839
    if (eventSource == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8840
        return;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8841
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8842
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8843
    this._eventIdToElmt = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8844
    this._prepareForPainting();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8845
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8846
    var metrics = this._computeMetrics();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8847
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8848
    var maxDate = this._band.getMaxDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8849
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8850
    var filterMatcher = (this._filterMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8851
        this._filterMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8852
        function(evt) { return true; };
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 highlightMatcher = (this._highlightMatcher != null) ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8855
        this._highlightMatcher :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8856
        function(evt) { return -1; };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8857
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8858
    var iterator = eventSource.getEventIterator(minDate, maxDate);
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
    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
  8861
    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
  8862
    if (collapseConcurrentPreciseInstantEvents || stackConcurrentPreciseInstantEvents) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8863
        var bufferedEvents = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8864
        var previousInstantEvent = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8865
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8866
        while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8867
            var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8868
            if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8869
                if (!evt.isInstant() || evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8870
                    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
  8871
                } else if (previousInstantEvent != null &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8872
                        previousInstantEvent.getStart().getTime() == evt.getStart().getTime()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8873
                    bufferedEvents[bufferedEvents.length - 1].push(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8874
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8875
                    bufferedEvents.push([ evt ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8876
                    previousInstantEvent = evt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8877
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8878
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8879
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8880
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8881
        for (var i = 0; i < bufferedEvents.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8882
            var compositeEvents = bufferedEvents[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8883
            if (compositeEvents.length == 1) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8884
                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
  8885
            } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8886
                var match = -1;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8887
                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
  8888
                    match = highlightMatcher(compositeEvents[j]);
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
                if (stackConcurrentPreciseInstantEvents) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8892
                    this.paintStackedPreciseInstantEvents(compositeEvents, metrics, this._params.theme, match);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8893
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8894
                    this.paintCompositePreciseInstantEvents(compositeEvents, metrics, this._params.theme, match);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8895
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8896
            }
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
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8899
        while (iterator.hasNext()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8900
            var evt = iterator.next();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8901
            if (filterMatcher(evt)) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8902
                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
  8903
            }
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
    }
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
    this._highlightLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8908
    this._lineLayer.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8909
    this._eventLayer.style.display = "block";
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
    this._setOrthogonalOffset(metrics);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8912
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8913
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8914
Timeline.CompactEventPainter.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8915
    this._setOrthogonalOffset(this._computeMetrics());
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8918
Timeline.CompactEventPainter.prototype._setOrthogonalOffset = function(metrics) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8919
    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
  8920
    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
  8921
    var orthogonalOffset = Math.max(minOrthogonalOffset, this._band.getViewOrthogonalOffset());
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
    this._highlightLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8924
        this._lineLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8925
            this._eventLayer.style.top =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8926
                orthogonalOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8927
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8928
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8929
Timeline.CompactEventPainter.prototype._computeMetrics = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8930
    var theme = this._params.theme;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8931
    var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8932
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8933
    var metrics = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8934
        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
  8935
        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
  8936
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8937
        tapeHeight:             theme.event.tape.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8938
        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
  8939
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8940
        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
  8941
        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
  8942
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8943
        defaultIcon:            eventTheme.instant.icon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8944
        defaultIconWidth:       eventTheme.instant.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8945
        defaultIconHeight:      eventTheme.instant.iconHeight,
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
        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
  8948
        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
  8949
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8950
        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
  8951
        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
  8952
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8953
    if ("compositeIcon" in this._params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8954
        metrics.compositeIcon = this._params.compositeIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8955
        metrics.compositeIconWidth = this._params.compositeIconWidth || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8956
        metrics.compositeIconHeight = this._params.compositeIconHeight || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8957
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8958
        metrics.compositeIcon = metrics.defaultIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8959
        metrics.compositeIconWidth = metrics.defaultIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8960
        metrics.compositeIconHeight = metrics.defaultIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8961
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8962
    metrics.defaultStackIcon = "icon" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8963
        this._params.stackConcurrentPreciseInstantEvents.icon : metrics.defaultIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8964
    metrics.defaultStackIconWidth = "iconWidth" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8965
        this._params.stackConcurrentPreciseInstantEvents.iconWidth : metrics.defaultIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8966
    metrics.defaultStackIconHeight = "iconHeight" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8967
        this._params.stackConcurrentPreciseInstantEvents.iconHeight : metrics.defaultIconHeight;
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
    return metrics;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8970
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8971
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8972
Timeline.CompactEventPainter.prototype._prepareForPainting = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8973
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8974
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8975
    if (this._backLayer == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8976
        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
  8977
        this._backLayer.style.visibility = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8978
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8979
        var eventLabelPrototype = document.createElement("span");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8980
        eventLabelPrototype.className = "timeline-event-label";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8981
        this._backLayer.appendChild(eventLabelPrototype);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8982
        this._frc = SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
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._frc.update();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8985
    this._tracks = [];
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._highlightLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8988
        band.removeLayerDiv(this._highlightLayer);
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._highlightLayer = band.createLayerDiv(105, "timeline-band-highlights");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8991
    this._highlightLayer.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._lineLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8994
        band.removeLayerDiv(this._lineLayer);
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._lineLayer = band.createLayerDiv(110, "timeline-band-lines");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  8997
    this._lineLayer.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
    if (this._eventLayer != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9000
        band.removeLayerDiv(this._eventLayer);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9001
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9002
    this._eventLayer = band.createLayerDiv(115, "timeline-band-events");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9003
    this._eventLayer.style.display = "none";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9004
};
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
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
  9007
    if (evt.isInstant()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9008
        this.paintInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9009
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9010
        this.paintDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9011
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9012
};
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
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
  9015
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9016
        this.paintImpreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9017
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9018
        this.paintPreciseInstantEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9019
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9020
}
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
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
  9023
    if (evt.isImprecise()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9024
        this.paintImpreciseDurationEvent(evt, metrics, theme, highlightIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9025
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9026
        this.paintPreciseDurationEvent(evt, metrics, theme, highlightIndex);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9030
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
  9031
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9032
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9033
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9034
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9035
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9036
        url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9037
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9038
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9039
        iconData.url = metrics.defaultIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9040
        iconData.width = metrics.defaultIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9041
        iconData.height = metrics.defaultIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9042
        iconData.className = "timeline-event-icon-default";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9043
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9044
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9045
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
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 labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9049
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9050
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9051
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9052
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9053
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9054
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9055
        evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9056
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9057
        null, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9058
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9059
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9060
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9061
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9062
        highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9063
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9064
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9065
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9066
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9067
        return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
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
    SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9070
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
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
    this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9073
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9074
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9075
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
  9076
    var evt = events[0];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9077
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9078
    var tooltips = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9079
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9080
        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
  9081
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9082
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9083
        tooltip: tooltips.join("; ")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9084
    };
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
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9087
        url: metrics.compositeIcon,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9088
        width: metrics.compositeIconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9089
        height: metrics.compositeIconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9090
        className: "timeline-event-icon-composite"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9091
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9092
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9093
    var labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9094
        text: String.substitute(this._params.compositeEventLabelTemplate, [ events.length ])
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9095
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9096
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9097
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9098
        evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9099
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9100
        null, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9101
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9102
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9103
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9104
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9105
        highlightIndex
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9108
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9109
    var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9110
        return self._onClickMultiplePreciseInstantEvent(result.iconElmtData.elmt, domEvt, events);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9111
    };
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
    SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9114
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9115
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9116
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9117
        this._eventIdToElmt[events[i].getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9118
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9119
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9120
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9121
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
  9122
    var limit = "limit" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9123
        this._params.stackConcurrentPreciseInstantEvents.limit : 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9124
    var moreMessageTemplate = "moreMessageTemplate" in this._params.stackConcurrentPreciseInstantEvents ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9125
        this._params.stackConcurrentPreciseInstantEvents.moreMessageTemplate : "%0 More Events";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9126
    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
  9127
                                                      // 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
  9128
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9129
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9130
    var getPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9131
        return Math.round(band.dateToPixelOffset(date));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9132
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9133
    var getIconData = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9134
        var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9135
            url: evt.getIcon()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9136
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9137
        if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9138
            iconData.url = metrics.defaultStackIcon;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9139
            iconData.width = metrics.defaultStackIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9140
            iconData.height = metrics.defaultStackIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9141
            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
  9142
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9143
            iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9144
            iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9145
            iconData.className = "timeline-event-icon-stack";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9146
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9147
        return iconData;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9148
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9149
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9150
    var firstIconData = getIconData(events[0]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9151
    var horizontalIncrement = 5;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9152
    var leftIconEdge = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9153
    var totalLabelWidth = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9154
    var totalLabelHeight = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9155
    var totalIconHeight = 0;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9157
    var records = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9158
    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
  9159
        var evt = events[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9160
        var text = evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9161
        var iconData = getIconData(evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9162
        var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9163
        var record = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9164
            text:       text,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9165
            iconData:   iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9166
            labelSize:  labelSize,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9167
            iconLeft:   firstIconData.width + i * horizontalIncrement - iconData.width
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9168
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9169
        record.labelLeft = firstIconData.width + i * horizontalIncrement + metrics.iconLabelGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9170
        record.top = totalLabelHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9171
        records.push(record);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9172
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9173
        leftIconEdge = Math.min(leftIconEdge, record.iconLeft);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9174
        totalLabelHeight += labelSize.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9175
        totalLabelWidth = Math.max(totalLabelWidth, record.labelLeft + labelSize.width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9176
        totalIconHeight = Math.max(totalIconHeight, record.top + iconData.height);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9177
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9178
    if (showMoreMessage) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9179
        var moreMessage = String.substitute(moreMessageTemplate, [ events.length - limit ]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9180
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9181
        var moreMessageLabelSize = this._frc.computeSize(moreMessage);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9182
        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
  9183
        var moreMessageLabelTop = totalLabelHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9184
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9185
        totalLabelHeight += moreMessageLabelSize.height;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9186
        totalLabelWidth = Math.max(totalLabelWidth, moreMessageLabelLeft + moreMessageLabelSize.width);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9187
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9188
    totalLabelWidth += metrics.labelRightMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9189
    totalLabelHeight += metrics.labelBottomMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9190
    totalIconHeight += metrics.iconBottomMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9191
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9192
    var anchorPixel = getPixelOffset(events[0].getStart());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9193
    var newTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9194
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9195
    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
  9196
    var rightIconEdge = firstIconData.width + (events.length - 1) * horizontalIncrement;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9197
    for (var i = 0; i < trackCount; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9198
        newTracks.push({ start: leftIconEdge, end: rightIconEdge });
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 labelTrackCount = Math.ceil(totalLabelHeight / metrics.trackHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9201
    for (var i = 0; i < labelTrackCount; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9202
        var track = newTracks[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9203
        track.end = Math.max(track.end, totalLabelWidth);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9204
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9205
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9206
    var firstTrack = this._fitTracks(anchorPixel, newTracks);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9207
    var verticalPixelOffset = firstTrack * metrics.trackHeight + metrics.trackOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9208
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9209
    var iconStackDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9210
    iconStackDiv.className = 'timeline-event-icon-stack';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9211
    iconStackDiv.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9212
    iconStackDiv.style.overflow = "visible";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9213
    iconStackDiv.style.left = anchorPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9214
    iconStackDiv.style.top = verticalPixelOffset + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9215
    iconStackDiv.style.width = rightIconEdge + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9216
    iconStackDiv.style.height = totalIconHeight + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9217
    iconStackDiv.innerHTML = "<div style='position: relative'></div>";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9218
    this._eventLayer.appendChild(iconStackDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9219
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9220
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9221
    var onMouseOver = function(domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9222
        try {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9223
            var n = parseInt(this.getAttribute("index"));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9224
            var childNodes = iconStackDiv.firstChild.childNodes;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9225
            for (var i = 0; i < childNodes.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9226
                var child = childNodes[i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9227
                if (i == n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9228
                    child.style.zIndex = childNodes.length;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9229
                } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9230
                    child.style.zIndex = childNodes.length - i;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9231
                }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9232
            }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9233
        } catch (e) {
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
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9236
    var paintEvent = function(index) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9237
        var record = records[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9238
        var evt = events[index];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9239
        var tooltip = evt.getProperty("tooltip") || evt.getText();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9240
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9241
        var labelElmtData = self._paintEventLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9242
            { tooltip: tooltip },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9243
            { text: record.text },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9244
            anchorPixel + record.labelLeft,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9245
            verticalPixelOffset + record.top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9246
            record.labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9247
            record.labelSize.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9248
            theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9249
        );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9250
        labelElmtData.elmt.setAttribute("index", index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9251
        labelElmtData.elmt.onmouseover = onMouseOver;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9252
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9253
        var img = SimileAjax.Graphics.createTranslucentImage(record.iconData.url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9254
        var iconDiv = self._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9255
        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
  9256
        iconDiv.style.left = record.iconLeft + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9257
        iconDiv.style.top = record.top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9258
        iconDiv.style.zIndex = (records.length - index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9259
        iconDiv.appendChild(img);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9260
        iconDiv.setAttribute("index", index);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9261
        iconDiv.onmouseover = onMouseOver;
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
        iconStackDiv.firstChild.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9264
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9265
        var clickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9266
            return self._onClickInstantEvent(labelElmtData.elmt, domEvt, evt);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9269
        SimileAjax.DOM.registerEvent(iconDiv, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9270
        SimileAjax.DOM.registerEvent(labelElmtData.elmt, "mousedown", clickHandler);
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
        self._eventIdToElmt[evt.getID()] = iconDiv;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9273
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9274
    for (var i = 0; i < records.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9275
        paintEvent(i);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9276
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9277
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9278
    if (showMoreMessage) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9279
        var moreEvents = events.slice(limit);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9280
        var moreMessageLabelElmtData = this._paintEventLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9281
            { tooltip: moreMessage },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9282
            { text: moreMessage },
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9283
            anchorPixel + moreMessageLabelLeft,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9284
            verticalPixelOffset + moreMessageLabelTop,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9285
            moreMessageLabelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9286
            moreMessageLabelSize.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9287
            theme
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9290
        var moreMessageClickHandler = function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9291
            return self._onClickMultiplePreciseInstantEvent(moreMessageLabelElmtData.elmt, domEvt, moreEvents);
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
        SimileAjax.DOM.registerEvent(moreMessageLabelElmtData.elmt, "mousedown", moreMessageClickHandler);
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
        for (var i = 0; i < moreEvents.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9296
            this._eventIdToElmt[moreEvents[i].getID()] = moreMessageLabelElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9297
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9298
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9299
    //this._createHighlightDiv(highlightIndex, iconElmtData, theme);
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9302
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
  9303
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9304
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9305
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9306
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9307
    var tapeData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9308
        start:          evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9309
        end:            evt.getEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9310
        latestStart:    evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9311
        earliestEnd:    evt.getEarliestEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9312
        isInstant:      true
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9313
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9314
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9315
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9316
        url: evt.getIcon()
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
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9319
        iconData = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9320
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9321
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9322
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
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 labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9326
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9327
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9328
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9329
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9330
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9331
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9332
        evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9333
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9334
        tapeData, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9335
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9336
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9337
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9338
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9339
        highlightIndex
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9342
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9343
    var clickHandler = iconData != null ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9344
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9345
            return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9346
        } :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9347
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9348
            return self._onClickInstantEvent(result.labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9349
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9350
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9351
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9352
    SimileAjax.DOM.registerEvent(result.impreciseTapeElmtData.elmt, "mousedown", clickHandler);
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
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9355
        SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9356
        this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9357
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9358
        this._eventIdToElmt[evt.getID()] = result.labelElmtData.elmt;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9362
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
  9363
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9364
        tooltip: evt.getProperty("tooltip") || evt.getText()
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 tapeData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9368
        start:          evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9369
        end:            evt.getEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9370
        isInstant:      false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9371
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9372
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9373
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9374
        url: evt.getIcon()
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
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9377
        iconData = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9378
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9379
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9380
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
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 labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9384
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9385
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9386
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9387
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9388
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9389
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9390
        evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9391
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9392
        tapeData, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9393
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9394
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9395
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9396
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9397
        highlightIndex
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9400
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9401
    var clickHandler = iconData != null ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9402
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9403
            return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9404
        } :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9405
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9406
            return self._onClickInstantEvent(result.labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9407
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9408
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9409
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9410
    SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt, "mousedown", clickHandler);
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
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9413
        SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9414
        this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9415
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9416
        this._eventIdToElmt[evt.getID()] = result.labelElmtData.elmt;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9420
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
  9421
    var commonData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9422
        tooltip: evt.getProperty("tooltip") || evt.getText()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9423
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9424
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9425
    var tapeData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9426
        start:          evt.getStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9427
        end:            evt.getEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9428
        latestStart:    evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9429
        earliestEnd:    evt.getEarliestEnd(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9430
        isInstant:      false
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9431
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9432
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9433
    var iconData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9434
        url: evt.getIcon()
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
    if (iconData.url == null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9437
        iconData = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9438
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9439
        iconData.width = evt.getProperty("iconWidth") || metrics.customIconWidth;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9440
        iconData.height = evt.getProperty("iconHeight") || metrics.customIconHeight;
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 labelData = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9444
        text:       evt.getText(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9445
        color:      evt.getTextColor() || evt.getColor(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9446
        className:  evt.getClassName()
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9447
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9448
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9449
    var result = this.paintTapeIconLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9450
        evt.getLatestStart(),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9451
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9452
        tapeData, // no tape data
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9453
        iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9454
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9455
        metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9456
        theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9457
        highlightIndex
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9460
    var self = this;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9461
    var clickHandler = iconData != null ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9462
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9463
            return self._onClickInstantEvent(result.iconElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9464
        } :
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9465
        function(elmt, domEvt, target) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9466
            return self._onClickInstantEvent(result.labelElmtData.elmt, domEvt, evt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9467
        };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9468
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9469
    SimileAjax.DOM.registerEvent(result.labelElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9470
    SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt, "mousedown", clickHandler);
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
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9473
        SimileAjax.DOM.registerEvent(result.iconElmtData.elmt, "mousedown", clickHandler);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9474
        this._eventIdToElmt[evt.getID()] = result.iconElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9475
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9476
        this._eventIdToElmt[evt.getID()] = result.labelElmtData.elmt;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9477
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9478
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9479
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9480
Timeline.CompactEventPainter.prototype.paintTapeIconLabel = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9481
    anchorDate,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9482
    commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9483
    tapeData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9484
    iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9485
    labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9486
    metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9487
    theme,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9488
    highlightIndex
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9489
) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9490
    var band = this._band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9491
    var getPixelOffset = function(date) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9492
        return Math.round(band.dateToPixelOffset(date));
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9493
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9494
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9495
    var anchorPixel = getPixelOffset(anchorDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9496
    var newTracks = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9497
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9498
    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
  9499
    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
  9500
    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
  9501
    if (tapeData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9502
        tapeHeightOccupied = metrics.tapeHeight + metrics.tapeBottomMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9503
        tapeTrackCount = Math.ceil(metrics.tapeHeight / metrics.trackHeight);
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
        var tapeEndPixelOffset = getPixelOffset(tapeData.end) - anchorPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9506
        var tapeStartPixelOffset = getPixelOffset(tapeData.start) - anchorPixel;
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
        for (var t = 0; t < tapeTrackCount; t++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9509
            newTracks.push({ start: tapeStartPixelOffset, end: tapeEndPixelOffset });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9510
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9511
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9512
        tapeLastTrackExtraSpace = metrics.trackHeight - (tapeHeightOccupied % metrics.tapeHeight);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9513
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9514
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9515
    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
  9516
                                         // 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
  9517
    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
  9518
                                         // 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
  9519
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9520
        if ("iconAlign" in iconData && iconData.iconAlign == "center") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9521
            iconStartPixelOffset = -Math.floor(iconData.width / 2);
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
        iconHorizontalSpaceOccupied = iconStartPixelOffset + iconData.width + metrics.iconLabelGap;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9524
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9525
        if (tapeTrackCount > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9526
            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
  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
        var iconHeight = iconData.height + metrics.iconBottomMargin + tapeLastTrackExtraSpace;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9530
        while (iconHeight > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9531
            newTracks.push({ start: iconStartPixelOffset, end: iconHorizontalSpaceOccupied });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9532
            iconHeight -= metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9533
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9534
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9535
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9536
    var text = labelData.text;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9537
    var labelSize = this._frc.computeSize(text);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9538
    var labelHeight = labelSize.height + metrics.labelBottomMargin + tapeLastTrackExtraSpace;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9539
    var labelEndPixelOffset = iconHorizontalSpaceOccupied + labelSize.width + metrics.labelRightMargin;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9540
    if (tapeTrackCount > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9541
        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
  9542
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9543
    for (var i = 0; labelHeight > 0; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9544
        if (tapeTrackCount + i < newTracks.length) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9545
            var track = newTracks[tapeTrackCount + i];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9546
            track.end = labelEndPixelOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9547
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9548
            newTracks.push({ start: 0, end: labelEndPixelOffset });
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9549
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9550
        labelHeight -= metrics.trackHeight;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9551
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9552
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9553
    /*
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9554
     *  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
  9555
     *  render the various elements.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9556
     */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9557
    var firstTrack = this._fitTracks(anchorPixel, newTracks);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9558
    var verticalPixelOffset = firstTrack * metrics.trackHeight + metrics.trackOffset;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9559
    var result = {};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9560
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9561
    result.labelElmtData = this._paintEventLabel(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9562
        commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9563
        labelData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9564
        anchorPixel + iconHorizontalSpaceOccupied,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9565
        verticalPixelOffset + tapeHeightOccupied,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9566
        labelSize.width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9567
        labelSize.height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9568
        theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9569
    );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9570
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9571
    if (tapeData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9572
        if ("latestStart" in tapeData || "earliestEnd" in tapeData) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9573
            result.impreciseTapeElmtData = this._paintEventTape(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9574
                commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9575
                tapeData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9576
                metrics.tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9577
                verticalPixelOffset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9578
                getPixelOffset(tapeData.start),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9579
                getPixelOffset(tapeData.end),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9580
                theme.event.duration.impreciseColor,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9581
                theme.event.duration.impreciseOpacity,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9582
                metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9583
                theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9584
            );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9585
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9586
        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
  9587
            result.tapeElmtData = this._paintEventTape(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9588
                commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9589
                tapeData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9590
                metrics.tapeHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9591
                verticalPixelOffset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9592
                anchorPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9593
                getPixelOffset("earliestEnd" in tapeData ? tapeData.earliestEnd : tapeData.end),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9594
                tapeData.color,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9595
                100,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9596
                metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9597
                theme
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9598
            );
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9599
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9600
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9601
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9602
    if (iconData != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9603
        result.iconElmtData = this._paintEventIcon(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9604
            commonData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9605
            iconData,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9606
            verticalPixelOffset + tapeHeightOccupied,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9607
            anchorPixel + iconStartPixelOffset,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9608
            metrics,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9609
            theme
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
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9612
    //this._createHighlightDiv(highlightIndex, iconElmtData, theme);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9613
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9614
    return result;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9615
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9616
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9617
Timeline.CompactEventPainter.prototype._fitTracks = function(anchorPixel, newTracks) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9618
    var firstTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9619
    for (firstTrack = 0; firstTrack < this._tracks.length; firstTrack++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9620
        var fit = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9621
        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
  9622
            var existingTrack = this._tracks[firstTrack + j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9623
            var newTrack = newTracks[j];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9624
            if (anchorPixel + newTrack.start < existingTrack) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9625
                fit = false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9626
                break;
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
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9629
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9630
        if (fit) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9631
            break;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9632
        }
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
    for (var i = 0; i < newTracks.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9635
        this._tracks[firstTrack + i] = anchorPixel + newTracks[i].end;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9636
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9637
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9638
    return firstTrack;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9639
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9640
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9641
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9642
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
  9643
    var img = SimileAjax.Graphics.createTranslucentImage(iconData.url);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9644
    var iconDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9645
    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
  9646
    iconDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9647
    iconDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9648
    iconDiv.appendChild(img);
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
    if ("tooltip" in commonData && typeof commonData.tooltip == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9651
        iconDiv.title = commonData.tooltip;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9652
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9653
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9654
    this._eventLayer.appendChild(iconDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9655
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9656
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9657
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9658
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9659
        width:  metrics.iconWidth,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9660
        height: metrics.iconHeight,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9661
        elmt:   iconDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9662
    };
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9663
};
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
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
  9666
    var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9667
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9668
    var labelDiv = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9669
    labelDiv.className = 'timeline-event-label';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9670
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9671
    labelDiv.style.left = left + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9672
    labelDiv.style.width = (width + 1) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9673
    labelDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9674
    labelDiv.innerHTML = labelData.text;
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 ("tooltip" in commonData && typeof commonData.tooltip == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9677
        labelDiv.title = commonData.tooltip;
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
    if ("color" in labelData && typeof labelData.color == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9680
        labelDiv.style.color = labelData.color;
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
    if ("className" in labelData && typeof labelData.className == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9683
        labelDiv.className += ' ' + labelData.className;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9684
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9685
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9686
    this._eventLayer.appendChild(labelDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9687
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9688
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9689
        left:   left,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9690
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9691
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9692
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9693
        elmt:   labelDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9694
    };
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9697
Timeline.CompactEventPainter.prototype._paintEventTape = function(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9698
    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
  9699
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9700
    var width = endPixel - startPixel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9701
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9702
    var tapeDiv = this._timeline.getDocument().createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9703
    tapeDiv.className = "timeline-event-tape"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9704
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9705
    tapeDiv.style.left = startPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9706
    tapeDiv.style.top = top + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9707
    tapeDiv.style.width = width + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9708
    tapeDiv.style.height = height + "px";
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
    if ("tooltip" in commonData && typeof commonData.tooltip == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9711
        tapeDiv.title = commonData.tooltip;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9712
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9713
    if (color != null && typeof tapeData.color == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9714
        tapeDiv.style.backgroundColor = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9715
    }
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
    if ("backgroundImage" in tapeData && typeof tapeData.backgroundImage == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9718
        tapeDiv.style.backgroundImage = "url(" + backgroundImage + ")";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9719
        tapeDiv.style.backgroundRepeat =
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9720
            ("backgroundRepeat" in tapeData && typeof tapeData.backgroundRepeat == "string")
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9721
                ? tapeData.backgroundRepeat : 'repeat';
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
    SimileAjax.Graphics.setOpacity(tapeDiv, opacity);
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
    if ("className" in tapeData && typeof tapeData.className == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9727
        tapeDiv.className += ' ' + tapeData.className;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9728
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9729
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9730
    this._eventLayer.appendChild(tapeDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9731
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9732
    return {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9733
        left:   startPixel,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9734
        top:    top,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9735
        width:  width,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9736
        height: height,
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9737
        elmt:   tapeDiv
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9738
    };
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9741
Timeline.CompactEventPainter.prototype._createHighlightDiv = function(highlightIndex, dimensions, theme) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9742
    if (highlightIndex >= 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9743
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9744
        var eventTheme = theme.event;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9745
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9746
        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
  9747
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9748
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9749
        div.style.position = "absolute";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9750
        div.style.overflow = "hidden";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9751
        div.style.left =    (dimensions.left - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9752
        div.style.width =   (dimensions.width + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9753
        div.style.top =     (dimensions.top - 2) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9754
        div.style.height =  (dimensions.height + 4) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9755
//        div.style.background = color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9756
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9757
        this._highlightLayer.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9758
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9759
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9760
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9761
Timeline.CompactEventPainter.prototype._onClickMultiplePreciseInstantEvent = function(icon, domEvt, events) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9762
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9763
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9764
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9765
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9766
        events
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9767
    );
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
    var ids = [];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9770
    for (var i = 0; i < events.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9771
        ids.push(events[i].getID());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9772
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9773
    this._fireOnSelect(ids);
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
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9776
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9777
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9778
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9779
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9780
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9781
Timeline.CompactEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9782
    var c = SimileAjax.DOM.getPageCoordinates(icon);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9783
    this._showBubble(
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9784
        c.left + Math.ceil(icon.offsetWidth / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9785
        c.top + Math.ceil(icon.offsetHeight / 2),
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9786
        [evt]
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
    this._fireOnSelect([evt.getID()]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9789
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9790
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9791
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9792
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9793
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9794
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9795
Timeline.CompactEventPainter.prototype._onClickDurationEvent = function(target, domEvt, evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9796
    if ("pageX" in domEvt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9797
        var x = domEvt.pageX;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9798
        var y = domEvt.pageY;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9799
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9800
        var c = SimileAjax.DOM.getPageCoordinates(target);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9801
        var x = domEvt.offsetX + c.left;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9802
        var y = domEvt.offsetY + c.top;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9803
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9804
    this._showBubble(x, y, [evt]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9805
    this._fireOnSelect([evt.getID()]);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9806
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9807
    domEvt.cancelBubble = true;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9808
    SimileAjax.DOM.cancelEvent(domEvt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9809
    return false;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9810
};
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
Timeline.CompactEventPainter.prototype.showBubble = function(evt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9813
    var elmt = this._eventIdToElmt[evt.getID()];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9814
    if (elmt) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9815
        var c = SimileAjax.DOM.getPageCoordinates(elmt);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9816
        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
  9817
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9818
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9819
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9820
Timeline.CompactEventPainter.prototype._showBubble = function(x, y, evts) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9821
    var div = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9822
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9823
    evts = ("fillInfoBubble" in evts) ? [evts] : evts;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9824
    for (var i = 0; i < evts.length; i++) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9825
        var div2 = document.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9826
        div.appendChild(div2);
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
        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
  9829
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9830
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9831
    SimileAjax.WindowManager.cancelPopups();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9832
    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
  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
Timeline.CompactEventPainter.prototype._fireOnSelect = function(eventIDs) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9836
    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
  9837
        this._onSelectListeners[i](eventIDs);
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
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  9840
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9841
 *  Span Highlight Decorator
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  9842
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9843
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9844
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9845
Timeline.SpanHighlightDecorator = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9846
    // 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
  9847
    // 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
  9848
    // 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
  9849
    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
  9850
    this._startDate = (typeof params.startDate == "string") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9851
        this._unit.parseFromObject(params.startDate) : params.startDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9852
    this._endDate = (typeof params.endDate == "string") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9853
        this._unit.parseFromObject(params.endDate) : params.endDate;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9854
    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
  9855
    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
  9856
    this._color = params.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9857
    this._cssClass = params.cssClass != null ? params.cssClass : null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9858
    this._opacity = params.opacity != null ? params.opacity : 100;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9859
         // 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
  9860
         // 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
  9861
    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
  9862
};
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
Timeline.SpanHighlightDecorator.prototype.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9865
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9866
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9867
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9868
    this._layerDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9869
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9870
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9871
Timeline.SpanHighlightDecorator.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9872
    if (this._layerDiv != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9873
        this._band.removeLayerDiv(this._layerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9874
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9875
    this._layerDiv = this._band.createLayerDiv(this._zIndex);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9876
    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
  9877
    this._layerDiv.style.display = "none";
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
    var minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9880
    var maxDate = this._band.getMaxDate();
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
    if (this._unit.compare(this._startDate, maxDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9883
        this._unit.compare(this._endDate, minDate) > 0) {
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
        minDate = this._unit.later(minDate, this._startDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9886
        maxDate = this._unit.earlier(maxDate, this._endDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9887
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9888
        var minPixel = this._band.dateToPixelOffset(minDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9889
        var maxPixel = this._band.dateToPixelOffset(maxDate);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9890
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9891
        var doc = this._timeline.getDocument();
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 createTable = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9894
            var table = doc.createElement("table");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9895
            table.insertRow(0).insertCell(0);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9896
            return table;
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9899
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9900
        div.className='timeline-highlight-decorator'
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9901
        if(this._cssClass) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9902
        	  div.className += ' ' + this._cssClass;
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
        if(this._color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9905
        	  div.style.backgroundColor = this._color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9906
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9907
        if (this._opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9908
            SimileAjax.Graphics.setOpacity(div, this._opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9909
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9910
        this._layerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9911
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9912
        var tableStartLabel = createTable();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9913
        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
  9914
        var tdStart =  tableStartLabel.rows[0].cells[0]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9915
        tdStart.innerHTML = this._startLabel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9916
        if (this._cssClass) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9917
        	  tdStart.className = 'label_' + this._cssClass;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9918
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9919
        this._layerDiv.appendChild(tableStartLabel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9920
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9921
        var tableEndLabel = createTable();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9922
        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
  9923
        var tdEnd = tableEndLabel.rows[0].cells[0]
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9924
        tdEnd.innerHTML = this._endLabel;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9925
        if (this._cssClass) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9926
        	   tdEnd.className = 'label_' + this._cssClass;
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
        this._layerDiv.appendChild(tableEndLabel);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9929
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9930
        if (this._timeline.isHorizontal()){
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9931
            div.style.left = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9932
            div.style.width = (maxPixel - minPixel) + "px";
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
            tableStartLabel.style.right = (this._band.getTotalViewLength() - minPixel) + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9935
            tableStartLabel.style.width = (this._startLabel.length) + "em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9936
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9937
            tableEndLabel.style.left = maxPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9938
            tableEndLabel.style.width = (this._endLabel.length) + "em";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9939
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9940
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9941
            div.style.top = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9942
            div.style.height = (maxPixel - minPixel) + "px";
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
            tableStartLabel.style.bottom = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9945
            tableStartLabel.style.height = "1.5px";
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
            tableEndLabel.style.top = maxPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9948
            tableEndLabel.style.height = "1.5px";
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
    this._layerDiv.style.display = "block";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9952
};
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
Timeline.SpanHighlightDecorator.prototype.softPaint = function() {
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  9957
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9958
 *  Point Highlight Decorator
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
  9959
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9960
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9961
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9962
Timeline.PointHighlightDecorator = function(params) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9963
    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
  9964
    this._date = (typeof params.date == "string") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9965
        this._unit.parseFromObject(params.date) : params.date;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9966
    this._width = params.width != null ? params.width : 10;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9967
      // 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
  9968
      // specify width here, not in css.
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9969
    this._color = params.color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9970
    this._cssClass = params.cssClass != null ? params.cssClass : '';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9971
    this._opacity = params.opacity != null ? params.opacity : 100;
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.initialize = function(band, timeline) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9975
    this._band = band;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9976
    this._timeline = timeline;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9977
    this._layerDiv = null;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9978
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9979
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9980
Timeline.PointHighlightDecorator.prototype.paint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9981
    if (this._layerDiv != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9982
        this._band.removeLayerDiv(this._layerDiv);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9983
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9984
    this._layerDiv = this._band.createLayerDiv(10);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9985
    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
  9986
    this._layerDiv.style.display = "none";
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 minDate = this._band.getMinDate();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9989
    var maxDate = this._band.getMaxDate();
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
    if (this._unit.compare(this._date, maxDate) < 0 &&
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9992
        this._unit.compare(this._date, minDate) > 0) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9993
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9994
        var pixel = this._band.dateToPixelOffset(this._date);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9995
        var minPixel = pixel - Math.round(this._width / 2);
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
        var doc = this._timeline.getDocument();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9998
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
  9999
        var div = doc.createElement("div");
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10000
        div.className='timeline-highlight-point-decorator';
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10001
        div.className += ' ' + this._cssClass;
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
        if(this._color != null) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10004
        	  div.style.backgroundColor = this._color;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10005
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10006
        if (this._opacity < 100) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10007
            SimileAjax.Graphics.setOpacity(div, this._opacity);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10008
        }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10009
        this._layerDiv.appendChild(div);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10010
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10011
        if (this._timeline.isHorizontal()) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10012
            div.style.left = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10013
            div.style.width = this._width;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10014
        } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10015
            div.style.top = minPixel + "px";
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10016
            div.style.height = this._width;
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
    this._layerDiv.style.display = "block";
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
Timeline.PointHighlightDecorator.prototype.softPaint = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10023
};
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10024
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10025
 *  Default Unit
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10026
 *
1156
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 = new Object();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10030
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10031
Timeline.NativeDateUnit.createLabeller = function(locale, timeZone) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10032
    return new Timeline.GregorianDateLabeller(locale, timeZone);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10033
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10034
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10035
Timeline.NativeDateUnit.makeDefaultValue = function() {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10036
    return new Date();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10037
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10038
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10039
Timeline.NativeDateUnit.cloneValue = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10040
    return new Date(v.getTime());
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10041
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10042
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10043
Timeline.NativeDateUnit.getParser = function(format) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10044
    if (typeof format == "string") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10045
        format = format.toLowerCase();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10046
    }
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10047
    return (format == "iso8601" || format == "iso 8601") ?
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10048
        Timeline.DateTime.parseIso8601DateTime : 
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10049
        Timeline.DateTime.parseGregorianDateTime;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10050
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10051
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10052
Timeline.NativeDateUnit.parseFromObject = function(o) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10053
    return Timeline.DateTime.parseGregorianDateTime(o);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10054
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10055
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10056
Timeline.NativeDateUnit.toNumber = function(v) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10057
    return v.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10058
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10059
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10060
Timeline.NativeDateUnit.fromNumber = function(n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10061
    return new Date(n);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10062
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10063
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10064
Timeline.NativeDateUnit.compare = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10065
    var n1, n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10066
    if (typeof v1 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10067
        n1 = v1.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10068
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10069
        n1 = Number(v1);
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
    if (typeof v2 == "object") {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10072
        n2 = v2.getTime();
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10073
    } else {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10074
        n2 = Number(v2);
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10075
    }
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
    return n1 - n2;
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10078
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10079
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10080
Timeline.NativeDateUnit.earlier = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10081
    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
 10082
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10083
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10084
Timeline.NativeDateUnit.later = function(v1, v2) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10085
    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
 10086
};
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10087
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10088
Timeline.NativeDateUnit.change = function(v, n) {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10089
    return new Date(v.getTime() + n);
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10092
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10093
 *  Common localization strings
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10094
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10097
Timeline.strings["fr"] = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10098
    wikiLinkLabel:  "Discute"
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10101
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10102
 *  Localization of labellers.js
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10103
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10104
 */
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
Timeline.GregorianDateLabeller.monthNames["fr"] = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10107
    "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
 10108
];
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10109
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10110
 *  Common localization strings
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10111
 *
1156
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
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10114
Timeline.strings["en"] = {
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10115
    wikiLinkLabel:  "Discuss"
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
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10118
/*
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10119
 *  Localization of labellers.js
5470
fb004819cab4 [book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2097
diff changeset
 10120
 *
1156
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10121
 */
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10122
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10123
Timeline.GregorianDateLabeller.monthNames["en"] = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10124
    "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
 10125
];
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10126
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10127
Timeline.GregorianDateLabeller.dayNames["en"] = [
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10128
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
4b920f836567 [javascript] new timeline bundle
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 68
diff changeset
 10129
];