Commit cf3d3f8e4602cd0ced751935dc5c7024f80cc6aa
Committed by
GitHub
Merge pull request #300 from rijn/295
added show-tip to slider and added always to tooltip
Showing
5 changed files
with
55 additions
and
7 deletions
Show diff stats
src/components/modal/confirm.js
@@ -17,7 +17,7 @@ Modal.newInstance = properties => { | @@ -17,7 +17,7 @@ Modal.newInstance = properties => { | ||
17 | 17 | ||
18 | const div = document.createElement('div'); | 18 | const div = document.createElement('div'); |
19 | div.innerHTML = ` | 19 | div.innerHTML = ` |
20 | - <Modal${props} :visible.sync="visible" :width="width"> | 20 | + <Modal${props} :visible.sync="visible" :width="width" :scrollable.sync="scrollable"> |
21 | <div class="${prefixCls}"> | 21 | <div class="${prefixCls}"> |
22 | <div class="${prefixCls}-head"> | 22 | <div class="${prefixCls}-head"> |
23 | <div class="${prefixCls}-head-title">{{{ title }}}</div> | 23 | <div class="${prefixCls}-head-title">{{{ title }}}</div> |
@@ -49,7 +49,8 @@ Modal.newInstance = properties => { | @@ -49,7 +49,8 @@ Modal.newInstance = properties => { | ||
49 | cancelText: t('i.modal.cancelText'), | 49 | cancelText: t('i.modal.cancelText'), |
50 | showCancel: false, | 50 | showCancel: false, |
51 | loading: false, | 51 | loading: false, |
52 | - buttonLoading: false | 52 | + buttonLoading: false, |
53 | + scrollable: false | ||
53 | }), | 54 | }), |
54 | computed: { | 55 | computed: { |
55 | iconTypeCls () { | 56 | iconTypeCls () { |
@@ -153,6 +154,10 @@ Modal.newInstance = properties => { | @@ -153,6 +154,10 @@ Modal.newInstance = properties => { | ||
153 | modal.$parent.loading = props.loading; | 154 | modal.$parent.loading = props.loading; |
154 | } | 155 | } |
155 | 156 | ||
157 | + if ('scrollable' in props) { | ||
158 | + modal.$parent.scrollable = props.scrollable; | ||
159 | + } | ||
160 | + | ||
156 | // notice when component destroy | 161 | // notice when component destroy |
157 | modal.$parent.onRemove = props.onRemove; | 162 | modal.$parent.onRemove = props.onRemove; |
158 | 163 |
src/components/slider/slider.vue
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | :class="[prefixCls + '-button-wrap']" | 18 | :class="[prefixCls + '-button-wrap']" |
19 | :style="{left: firstPosition + '%'}" | 19 | :style="{left: firstPosition + '%'}" |
20 | @mousedown="onFirstButtonDown"> | 20 | @mousedown="onFirstButtonDown"> |
21 | - <Tooltip :controlled="firstDragging" placement="top" :content="tipFormat(value[0])" :disabled="tipFormat(value[0]) === null" v-ref:tooltip> | 21 | + <Tooltip :controlled="firstDragging" placement="top" :content="tipFormat(value[0])" :disabled="tipDisabled" :always="showTip === 'always'" v-ref:tooltip> |
22 | <div :class="button1Classes"></div> | 22 | <div :class="button1Classes"></div> |
23 | </Tooltip> | 23 | </Tooltip> |
24 | </div> | 24 | </div> |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | :class="[prefixCls + '-button-wrap']" | 26 | :class="[prefixCls + '-button-wrap']" |
27 | :style="{left: secondPosition + '%'}" | 27 | :style="{left: secondPosition + '%'}" |
28 | @mousedown="onSecondButtonDown"> | 28 | @mousedown="onSecondButtonDown"> |
29 | - <Tooltip :controlled="secondDragging" placement="top" :content="tipFormat(value[1])" :disabled="tipFormat(value[1]) === null" v-ref:tooltip2> | 29 | + <Tooltip :controlled="secondDragging" placement="top" :content="tipFormat(value[1])" :disabled="tipDisabled" :always="showTip === 'always'" v-ref:tooltip2> |
30 | <div :class="button2Classes"></div> | 30 | <div :class="button2Classes"></div> |
31 | </Tooltip> | 31 | </Tooltip> |
32 | </div> | 32 | </div> |
@@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
36 | :class="[prefixCls + '-button-wrap']" | 36 | :class="[prefixCls + '-button-wrap']" |
37 | :style="{left: singlePosition + '%'}" | 37 | :style="{left: singlePosition + '%'}" |
38 | @mousedown="onSingleButtonDown"> | 38 | @mousedown="onSingleButtonDown"> |
39 | - <Tooltip :controlled="dragging" placement="top" :content="tipFormat(value)" :disabled="tipFormat(value) === null" v-ref:tooltip> | 39 | + <Tooltip :controlled="dragging" placement="top" :content="tipFormat(value)" :disabled="tipDisabled" :always="showTip === 'always'" v-ref:tooltip> |
40 | <div :class="buttonClasses"></div> | 40 | <div :class="buttonClasses"></div> |
41 | </Tooltip> | 41 | </Tooltip> |
42 | </div> | 42 | </div> |
@@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
47 | <script> | 47 | <script> |
48 | import InputNumber from '../../components/input-number/input-number.vue'; | 48 | import InputNumber from '../../components/input-number/input-number.vue'; |
49 | import Tooltip from '../../components/tooltip/tooltip.vue'; | 49 | import Tooltip from '../../components/tooltip/tooltip.vue'; |
50 | - import { getStyle } from '../../utils/assist'; | 50 | + import { getStyle, oneOf } from '../../utils/assist'; |
51 | 51 | ||
52 | const prefixCls = 'ivu-slider'; | 52 | const prefixCls = 'ivu-slider'; |
53 | 53 | ||
@@ -91,6 +91,13 @@ | @@ -91,6 +91,13 @@ | ||
91 | default (val) { | 91 | default (val) { |
92 | return val; | 92 | return val; |
93 | } | 93 | } |
94 | + }, | ||
95 | + showTip: { | ||
96 | + type: String, | ||
97 | + default: 'hover', | ||
98 | + validator (value) { | ||
99 | + return oneOf(value, ['hover', 'always', 'never']); | ||
100 | + } | ||
94 | } | 101 | } |
95 | }, | 102 | }, |
96 | data () { | 103 | data () { |
@@ -173,6 +180,9 @@ | @@ -173,6 +180,9 @@ | ||
173 | }, | 180 | }, |
174 | sliderWidth () { | 181 | sliderWidth () { |
175 | return parseInt(getStyle(this.$els.slider, 'width'), 10); | 182 | return parseInt(getStyle(this.$els.slider, 'width'), 10); |
183 | + }, | ||
184 | + tipDisabled () { | ||
185 | + return this.tipFormat(this.value[0]) === null || this.showTip === 'never'; | ||
176 | } | 186 | } |
177 | }, | 187 | }, |
178 | watch: { | 188 | watch: { |
src/components/tooltip/tooltip.vue
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <div :class="[prefixCls + '-rel']" v-el:reference> | 3 | <div :class="[prefixCls + '-rel']" v-el:reference> |
4 | <slot></slot> | 4 | <slot></slot> |
5 | </div> | 5 | </div> |
6 | - <div :class="[prefixCls + '-popper']" transition="fade" v-el:popper v-show="!disabled && visible"> | 6 | + <div :class="[prefixCls + '-popper']" transition="fade" v-el:popper v-show="!disabled && (visible || always)"> |
7 | <div :class="[prefixCls + '-content']"> | 7 | <div :class="[prefixCls + '-content']"> |
8 | <div :class="[prefixCls + '-arrow']"></div> | 8 | <div :class="[prefixCls + '-arrow']"></div> |
9 | <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div> | 9 | <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div> |
@@ -41,6 +41,10 @@ | @@ -41,6 +41,10 @@ | ||
41 | controlled: { // under this prop,Tooltip will not close when mouseleave | 41 | controlled: { // under this prop,Tooltip will not close when mouseleave |
42 | type: Boolean, | 42 | type: Boolean, |
43 | default: false | 43 | default: false |
44 | + }, | ||
45 | + always: { | ||
46 | + type: Boolean, | ||
47 | + default: false | ||
44 | } | 48 | } |
45 | }, | 49 | }, |
46 | data () { | 50 | data () { |
test/routers/more.vue
@@ -8,6 +8,11 @@ | @@ -8,6 +8,11 @@ | ||
8 | top: 0; | 8 | top: 0; |
9 | } | 9 | } |
10 | } | 10 | } |
11 | + | ||
12 | + .placeholder { | ||
13 | + min-height: 2000px; | ||
14 | + width: 1px; | ||
15 | + } | ||
11 | </style> | 16 | </style> |
12 | <template> | 17 | <template> |
13 | <i-button @click="modal9 = true">距离顶部 20px</i-button> | 18 | <i-button @click="modal9 = true">距离顶部 20px</i-button> |
@@ -28,6 +33,9 @@ | @@ -28,6 +33,9 @@ | ||
28 | <p>对话框内容</p> | 33 | <p>对话框内容</p> |
29 | <p>对话框内容</p> | 34 | <p>对话框内容</p> |
30 | </Modal> | 35 | </Modal> |
36 | + <i-button @click="instance(true)">Create Instance Scrollable</i-button> | ||
37 | + <i-button @click="instance(false)">Create Instance Non-scrollable</i-button> | ||
38 | + <div class="placeholder"></div> | ||
31 | </template> | 39 | </template> |
32 | <script> | 40 | <script> |
33 | export default { | 41 | export default { |
@@ -35,6 +43,24 @@ | @@ -35,6 +43,24 @@ | ||
35 | return { | 43 | return { |
36 | modal9: false, | 44 | modal9: false, |
37 | modal10: false, | 45 | modal10: false, |
46 | + modal1: false, | ||
47 | + scrollable: false | ||
48 | + } | ||
49 | + }, | ||
50 | + methods: { | ||
51 | + ok () { | ||
52 | + this.$nextTick(() => this.modal1 = true); | ||
53 | + this.$Message.info('点击了确定'); | ||
54 | + }, | ||
55 | + cancel () { | ||
56 | + this.$Message.info('点击了取消'); | ||
57 | + }, | ||
58 | + instance (scrollable) { | ||
59 | + this.$Modal.info({ | ||
60 | + title: 'test', | ||
61 | + content: 'test', | ||
62 | + scrollable: scrollable | ||
63 | + }); | ||
38 | } | 64 | } |
39 | } | 65 | } |
40 | } | 66 | } |
test/routers/slider.vue
@@ -14,6 +14,9 @@ | @@ -14,6 +14,9 @@ | ||
14 | </div> | 14 | </div> |
15 | <Slider :value="75"></Slider> | 15 | <Slider :value="75"></Slider> |
16 | <Slider :value="[20, 50]" range></Slider> | 16 | <Slider :value="[20, 50]" range></Slider> |
17 | + <Slider :value="[20, 50]" show-tip="always"></Slider> | ||
18 | + <Slider :value="[20, 50]" show-tip="hover"></Slider> | ||
19 | + <Slider :value="[20, 50]" show-tip="never"></Slider> | ||
17 | </div> | 20 | </div> |
18 | </template> | 21 | </template> |
19 | <script> | 22 | <script> |