Blame view

src/components/tooltip/tooltip.vue 2.14 KB
dce3e753   梁灏   add Tooltip compo...
1
  <template>
4b7138b9   梁灏   fixed some bugs
2
3
      <div :class="[prefixCls]" @mouseenter="handleShowPopper" @mouseleave="handleClosePopper">
          <div :class="[prefixCls + '-rel']" v-el:reference>
dce3e753   梁灏   add Tooltip compo...
4
5
              <slot></slot>
          </div>
59872199   Rijn   added show-tip to...
6
          <div :class="[prefixCls + '-popper']" transition="fade" v-el:popper v-show="!disabled && (visible || always)">
4b7138b9   梁灏   fixed some bugs
7
8
9
              <div :class="[prefixCls + '-content']">
                  <div :class="[prefixCls + '-arrow']"></div>
                  <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div>
dce3e753   梁灏   add Tooltip compo...
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
              </div>
          </div>
      </div>
  </template>
  <script>
      import Popper from '../base/popper';
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-tooltip';
  
      export default {
          mixins: [Popper],
          props: {
              placement: {
                  validator (value) {
                      return oneOf(value, ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']);
                  },
                  default: 'bottom'
              },
              content: {
                  type: [String, Number],
                  default: ''
              },
              delay: {
                  type: Number,
                  default: 0
              },
              disabled: {
                  type: Boolean,
                  default: false
73772536   梁灏   optimize Slider t...
40
41
42
43
              },
              controlled: {    // under this prop,Tooltip will not close when mouseleave
                  type: Boolean,
                  default: false
59872199   Rijn   added show-tip to...
44
45
46
47
              },
              always: {
                  type: Boolean,
                  default: false
dce3e753   梁灏   add Tooltip compo...
48
49
50
51
52
              }
          },
          data () {
              return {
                  prefixCls: prefixCls
b0893113   jingsam   :art: add eslint
53
              };
dce3e753   梁灏   add Tooltip compo...
54
          },
dce3e753   梁灏   add Tooltip compo...
55
56
57
          methods: {
              handleShowPopper() {
                  this.timeout = setTimeout(() => {
9699c270   梁灏   add Poptip component
58
                      this.visible = true;
dce3e753   梁灏   add Tooltip compo...
59
60
61
62
                  }, this.delay);
              },
              handleClosePopper() {
                  clearTimeout(this.timeout);
73772536   梁灏   optimize Slider t...
63
64
65
                  if (!this.controlled) {
                      this.visible = false;
                  }
dce3e753   梁灏   add Tooltip compo...
66
67
              }
          }
b0893113   jingsam   :art: add eslint
68
      };
d6342fe1   jingsam   fixed ie bug
69
  </script>