nnnjjj123
2020-11-17 1b2c1edb61190eeb19f465ff031eaa3b2a1b8dbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
define([
  'dijit/TooltipDialog',
  'dijit/popup',
  'dojo/_base/html',
  'dojo/on',
  'dojo/mouse',
  'dojo/query'
], function(TooltipDialog, dojoPopup, html, on, Mouse, query) {
  var mo = {}, tooltipTimeout = 200;
 
  mo.initTooltips = function(domNode) {
    query('[title]', domNode).forEach(function(node){
      if (node) {
        var content = html.getAttr(node, 'title');
        html.setAttr(node, 'title', '');
        createTooptipDialog(content, node);
      }
    });
  };
 
  function createTooptipDialog(content, node){
    var tooltipDialogContent = html.create("div", {
      'innerHTML': content,
      'class': 'dialog-content'
    });
 
    var tooltipDialog = new TooltipDialog({
      content: tooltipDialogContent
    }), tooltipTimeoutId;
 
    on(node, Mouse.enter, function() {
      clearTimeout(tooltipTimeoutId);
      tooltipTimeoutId = -1;
      tooltipTimeoutId = setTimeout(function() {
        dojoPopup.open({
          parent: null,
          popup: tooltipDialog,
          around: node,
          position: ["below"]
        });
      }, tooltipTimeout);
    });
    on(node, Mouse.leave, function(){
      clearTimeout(tooltipTimeoutId);
      tooltipTimeoutId = -1;
      dojoPopup.close(tooltipDialog);
    });
 
    return tooltipDialog;
  }
 
  return mo;
});