Blame view

src/components/tooltip/tooltip.vue 2.23 KB
dce3e753   梁灏   add Tooltip compo...
1
  <template>
4b7138b9   梁灏   fixed some bugs
2
      <div :class="[prefixCls]" @mouseenter="handleShowPopper" @mouseleave="handleClosePopper">
d6f644e1   梁灏   support Tooltip
3
          <div :class="[prefixCls + '-rel']" ref="reference">
dce3e753   梁灏   add Tooltip compo...
4
5
              <slot></slot>
          </div>
d6f644e1   梁灏   support Tooltip
6
7
8
9
10
11
          <transition name="fade">
              <div :class="[prefixCls + '-popper']" ref="popper" v-show="!disabled && (visible || always)">
                  <div :class="[prefixCls + '-content']">
                      <div :class="[prefixCls + '-arrow']"></div>
                      <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div>
                  </div>
dce3e753   梁灏   add Tooltip compo...
12
              </div>
d6f644e1   梁灏   support Tooltip
13
          </transition>
dce3e753   梁灏   add Tooltip compo...
14
15
16
17
18
19
20
21
22
      </div>
  </template>
  <script>
      import Popper from '../base/popper';
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-tooltip';
  
      export default {
79288d43   梁灏   support Poptip & ...
23
          name: 'Tooltip',
dce3e753   梁灏   add Tooltip compo...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
          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...
43
44
45
46
              },
              controlled: {    // under this prop,Tooltip will not close when mouseleave
                  type: Boolean,
                  default: false
59872199   Rijn   added show-tip to...
47
48
49
50
              },
              always: {
                  type: Boolean,
                  default: false
dce3e753   梁灏   add Tooltip compo...
51
52
53
54
55
              }
          },
          data () {
              return {
                  prefixCls: prefixCls
b0893113   jingsam   :art: add eslint
56
              };
dce3e753   梁灏   add Tooltip compo...
57
          },
dce3e753   梁灏   add Tooltip compo...
58
59
60
          methods: {
              handleShowPopper() {
                  this.timeout = setTimeout(() => {
9699c270   梁灏   add Poptip component
61
                      this.visible = true;
dce3e753   梁灏   add Tooltip compo...
62
63
64
65
                  }, this.delay);
              },
              handleClosePopper() {
                  clearTimeout(this.timeout);
73772536   梁灏   optimize Slider t...
66
67
68
                  if (!this.controlled) {
                      this.visible = false;
                  }
dce3e753   梁灏   add Tooltip compo...
69
70
              }
          }
b0893113   jingsam   :art: add eslint
71
      };
d6342fe1   jingsam   fixed ie bug
72
  </script>