Blame view

src/components/tooltip/tooltip.vue 2.03 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>
4b7138b9   梁灏   fixed some bugs
6
7
8
9
          <div :class="[prefixCls + '-popper']" transition="fade" v-el:popper v-show="!disabled && visible">
              <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
dce3e753   梁灏   add Tooltip compo...
44
45
46
47
48
49
50
              }
          },
          data () {
              return {
                  prefixCls: prefixCls
              }
          },
dce3e753   梁灏   add Tooltip compo...
51
52
53
          methods: {
              handleShowPopper() {
                  this.timeout = setTimeout(() => {
9699c270   梁灏   add Poptip component
54
                      this.visible = true;
dce3e753   梁灏   add Tooltip compo...
55
56
57
58
                  }, this.delay);
              },
              handleClosePopper() {
                  clearTimeout(this.timeout);
73772536   梁灏   optimize Slider t...
59
60
61
                  if (!this.controlled) {
                      this.visible = false;
                  }
dce3e753   梁灏   add Tooltip compo...
62
63
64
              }
          }
      }
d6342fe1   jingsam   fixed ie bug
65
  </script>