Fossil

Check-in [7fbad143]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Deduplicate more code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tooltip-experiments
Files: files | file ages | folders
SHA3-256: 7fbad143e67f0afe8cb873f5421168107bbec4a6f90e454fcd00ee3155ef9888
User & Date: florian 2019-05-21 08:20:00
Wiki:tooltip-experiments
Context
2019-05-21
08:27
Resolve the fork. check-in: fde231b2 user: florian tags: tooltip-experiments
08:20
Deduplicate more code. check-in: 7fbad143 user: florian tags: tooltip-experiments
07:26
Deduplicate code, and consistently use "style.display" instead of "style.visibility" to show and hide the tooltip. check-in: e0198213 user: florian tags: tooltip-experiments
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/graph.js.

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

111


112


113

114







115







116
117
118
119
120
121
122
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

202
203
204
205
206
207
208
}
var tooltipObj = document.createElement("span");
tooltipObj.className = "tl-tooltip";
tooltipObj.style.display = "none";
document.getElementsByClassName("content")[0].appendChild(tooltipObj);
/* Clear the close timer if the mouse is over the tooltip. */
tooltipObj.onmouseenter = function(e) {
  if (tooltipInfo.idTimerClose != 0) {
    clearTimeout(tooltipInfo.idTimerClose);
    tooltipInfo.idTimerClose = 0;
  }
};
/* Init the close timer if the mouse is no longer over the tooltip. */
tooltipObj.onmouseleave = function(e) {
  if (tooltipInfo.ixActive != -1 && tooltipInfo.idTimerClose == 0) {
    tooltipInfo.idTimerClose = setTimeout(function() {
      tooltipInfo.idTimerClose = 0;
      hideGraphTooltip();
    }.bind(window),tooltipInfo.closeTimeout);
  }
};
/* This object must be in the global scope, so that (non-shadowed) access is
** possible from within a setTimeout() closure. */
window.tooltipInfo = {
  dwellTimeout: 250,  /* The tooltip dwell timeout. */
  closeTimeout: 3000, /* The tooltip close timeout. */
  idTimer: 0,         /* The tooltip dwell timer id. */
  idTimerClose: 0,    /* The tooltip close timer id. */
  ixHover: -1,        /* The id of the element with the mouse. */
  ixActive: -1,       /* The id of the element with the tooltip. */
  posX: 0, posY: 0    /* The last mouse position. */
};
/* This function must be in the global scope, so that access is possible from
** within non-local event handlers. */
function hideGraphTooltip() {

  tooltipObj.style.display = "none";


  (function() {


    this.tooltipInfo.ixActive = -1;

  }).call(window);







}








/* Construct that graph corresponding to the timeline-data-N object */
function TimelineGraph(tx){
  var topObj = document.getElementById("timelineTable"+tx.iTableId);
  amendCss(tx.circleNodes, tx.showArrowheads);
  topObj.onclick = clickOnGraph
  topObj.ondblclick = dblclickOnGraph
................................................................................
        return;
      if (-1 == tooltipInfo.ixHover && ix == tooltipInfo.ixActive)
        isReentry = true;
    }
    /* The tooltip is either not visible, or the mouse is over a different
    ** element, so clear the dwell timer, and record the new element id and
    ** mouse position. */
    if (tooltipInfo.idTimer != 0) {
      clearTimeout(tooltipInfo.idTimer);
      tooltipInfo.idTimer = 0;
    }
    if (ix >= 0) {
      /* Close the tooltip only if the mouse is over another element, and init
      ** the dwell timer again. */
      if (!isReentry)
        hideGraphTooltip();
      tooltipInfo.ixHover = ix;
      tooltipInfo.posX = e.x;
      tooltipInfo.posY = e.y;
      /* Clear the close timer. */
      if (tooltipInfo.idTimerClose != 0) {
        clearTimeout(tooltipInfo.idTimerClose);
        tooltipInfo.idTimerClose = 0;
      }
      if (!isReentry) {
        tooltipInfo.idTimer = setTimeout(function() {
          this.tooltipInfo.idTimer = 0;
          /* Clear the timer to hide the tooltip. */
          if (this.tooltipInfo.idTimerClose != 0) {
            clearTimeout(this.tooltipInfo.idTimerClose);
            this.tooltipInfo.idTimerClose = 0;
          }
          showGraphTooltip(
            this.tooltipInfo.ixHover,
            this.tooltipInfo.posX,
            this.tooltipInfo.posY);
          this.tooltipInfo.ixActive = this.tooltipInfo.ixHover;
        }.bind(window),tooltipInfo.dwellTimeout);
      }
    }
    else {
      tooltipInfo.ixHover = -1;
      /* The mouse is not over an element with a tooltip, init the hide
      ** timer. */
      if (tooltipInfo.idTimerClose == 0) {
        tooltipInfo.idTimerClose = setTimeout(function() {
          this.tooltipInfo.idTimerClose = 0;
          hideGraphTooltip();
        }.bind(window),tooltipInfo.closeTimeout);
      }
    }
  };
  topObj.onmouseleave = function(e) {
    /* Hide the tooltip if the mouse is outside the "timelineTableN" element,
    ** and outside the tooltip. */
    if (tooltipObj.style.display != "none" &&
          e.relatedTarget &&
          e.relatedTarget != tooltipObj) {
      tooltipInfo.ixHover = -1;
      hideGraphTooltip();
      /* Clear the dwell timer. */
      if (tooltipInfo.idTimer != 0) {
        clearTimeout(tooltipInfo.idTimer);
        tooltipInfo.idTimer = 0;
      }
      /* Clear the close timer. */
      if (tooltipInfo.idTimerClose != 0) {
        clearTimeout(tooltipInfo.idTimerClose);
        tooltipInfo.idTimerClose = 0;
      }

    }
  };
  var canvasDiv;
  var railPitch;
  var mergeOffset;
  var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;








|
<
<
<



|
|
<
<
<
<












|
|
|
>

>
>
|
>
>
|
>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>







 







|
<
<
<








|
|
<
<
<




|
<
<
<












|
<
<
<
<
<











|
<
<
<

<
<
<
<
>







76
77
78
79
80
81
82
83



84
85
86
87
88




89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
...
145
146
147
148
149
150
151
152



153
154
155
156
157
158
159
160
161
162



163
164
165
166
167



168
169
170
171
172
173
174
175
176
177
178
179
180





181
182
183
184
185
186
187
188
189
190
191
192



193




194
195
196
197
198
199
200
201
}
var tooltipObj = document.createElement("span");
tooltipObj.className = "tl-tooltip";
tooltipObj.style.display = "none";
document.getElementsByClassName("content")[0].appendChild(tooltipObj);
/* Clear the close timer if the mouse is over the tooltip. */
tooltipObj.onmouseenter = function(e) {
  stopCloseTimer();



};
/* Init the close timer if the mouse is no longer over the tooltip. */
tooltipObj.onmouseleave = function(e) {
  if (tooltipInfo.ixActive != -1)
    resumeCloseTimer();




};
/* This object must be in the global scope, so that (non-shadowed) access is
** possible from within a setTimeout() closure. */
window.tooltipInfo = {
  dwellTimeout: 250,  /* The tooltip dwell timeout. */
  closeTimeout: 3000, /* The tooltip close timeout. */
  idTimer: 0,         /* The tooltip dwell timer id. */
  idTimerClose: 0,    /* The tooltip close timer id. */
  ixHover: -1,        /* The id of the element with the mouse. */
  ixActive: -1,       /* The id of the element with the tooltip. */
  posX: 0, posY: 0    /* The last mouse position. */
};
/* These functions must be in the global scope, so that access is possible from
** within (non-local) event handlers. */
var hideGraphTooltip = function() {
  stopCloseTimer();
  tooltipObj.style.display = "none";
  this.tooltipInfo.ixActive = -1;
}.bind(window);
var stopDwellTimer = function() {
  if (this.tooltipInfo.idTimer != 0) {
    clearTimeout(this.tooltipInfo.idTimer);
    this.tooltipInfo.idTimer = 0;
  }
}.bind(window);
var resumeCloseTimer = function() {
  /* This timer must be stopped explicitly to reset the elapsed timeout. */
  if (this.tooltipInfo.idTimerClose == 0) {
    this.tooltipInfo.idTimerClose = setTimeout(function() {
      this.tooltipInfo.idTimerClose = 0;
      hideGraphTooltip();
    }.bind(window),this.tooltipInfo.closeTimeout);
  }
}.bind(window);
var stopCloseTimer = function() {
  if (this.tooltipInfo.idTimerClose != 0) {
    clearTimeout(this.tooltipInfo.idTimerClose);
    this.tooltipInfo.idTimerClose = 0;
  }
}.bind(window);

/* Construct that graph corresponding to the timeline-data-N object */
function TimelineGraph(tx){
  var topObj = document.getElementById("timelineTable"+tx.iTableId);
  amendCss(tx.circleNodes, tx.showArrowheads);
  topObj.onclick = clickOnGraph
  topObj.ondblclick = dblclickOnGraph
................................................................................
        return;
      if (-1 == tooltipInfo.ixHover && ix == tooltipInfo.ixActive)
        isReentry = true;
    }
    /* The tooltip is either not visible, or the mouse is over a different
    ** element, so clear the dwell timer, and record the new element id and
    ** mouse position. */
    stopDwellTimer();



    if (ix >= 0) {
      /* Close the tooltip only if the mouse is over another element, and init
      ** the dwell timer again. */
      if (!isReentry)
        hideGraphTooltip();
      tooltipInfo.ixHover = ix;
      tooltipInfo.posX = e.x;
      tooltipInfo.posY = e.y;
      /* Clear the close timer, if not already cleared by hideGraphTooltip(). */
      stopCloseTimer();



      if (!isReentry) {
        tooltipInfo.idTimer = setTimeout(function() {
          this.tooltipInfo.idTimer = 0;
          /* Clear the timer to hide the tooltip. */
          stopCloseTimer();



          showGraphTooltip(
            this.tooltipInfo.ixHover,
            this.tooltipInfo.posX,
            this.tooltipInfo.posY);
          this.tooltipInfo.ixActive = this.tooltipInfo.ixHover;
        }.bind(window),tooltipInfo.dwellTimeout);
      }
    }
    else {
      tooltipInfo.ixHover = -1;
      /* The mouse is not over an element with a tooltip, init the hide
      ** timer. */
      resumeCloseTimer();





    }
  };
  topObj.onmouseleave = function(e) {
    /* Hide the tooltip if the mouse is outside the "timelineTableN" element,
    ** and outside the tooltip. */
    if (tooltipObj.style.display != "none" &&
          e.relatedTarget &&
          e.relatedTarget != tooltipObj) {
      tooltipInfo.ixHover = -1;
      hideGraphTooltip();
      /* Clear the dwell timer. */
      stopDwellTimer();



      /* Clear the close timer. */




      stopCloseTimer();
    }
  };
  var canvasDiv;
  var railPitch;
  var mergeOffset;
  var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;