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 | 17 | |
| 18 | 18 | const div = document.createElement('div'); |
| 19 | 19 | div.innerHTML = ` |
| 20 | - <Modal${props} :visible.sync="visible" :width="width"> | |
| 20 | + <Modal${props} :visible.sync="visible" :width="width" :scrollable.sync="scrollable"> | |
| 21 | 21 | <div class="${prefixCls}"> |
| 22 | 22 | <div class="${prefixCls}-head"> |
| 23 | 23 | <div class="${prefixCls}-head-title">{{{ title }}}</div> |
| ... | ... | @@ -49,7 +49,8 @@ Modal.newInstance = properties => { |
| 49 | 49 | cancelText: t('i.modal.cancelText'), |
| 50 | 50 | showCancel: false, |
| 51 | 51 | loading: false, |
| 52 | - buttonLoading: false | |
| 52 | + buttonLoading: false, | |
| 53 | + scrollable: false | |
| 53 | 54 | }), |
| 54 | 55 | computed: { |
| 55 | 56 | iconTypeCls () { |
| ... | ... | @@ -153,6 +154,10 @@ Modal.newInstance = properties => { |
| 153 | 154 | modal.$parent.loading = props.loading; |
| 154 | 155 | } |
| 155 | 156 | |
| 157 | + if ('scrollable' in props) { | |
| 158 | + modal.$parent.scrollable = props.scrollable; | |
| 159 | + } | |
| 160 | + | |
| 156 | 161 | // notice when component destroy |
| 157 | 162 | modal.$parent.onRemove = props.onRemove; |
| 158 | 163 | ... | ... |
src/components/slider/slider.vue
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | :class="[prefixCls + '-button-wrap']" |
| 19 | 19 | :style="{left: firstPosition + '%'}" |
| 20 | 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 | 22 | <div :class="button1Classes"></div> |
| 23 | 23 | </Tooltip> |
| 24 | 24 | </div> |
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 | :class="[prefixCls + '-button-wrap']" |
| 27 | 27 | :style="{left: secondPosition + '%'}" |
| 28 | 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 | 30 | <div :class="button2Classes"></div> |
| 31 | 31 | </Tooltip> |
| 32 | 32 | </div> |
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | :class="[prefixCls + '-button-wrap']" |
| 37 | 37 | :style="{left: singlePosition + '%'}" |
| 38 | 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 | 40 | <div :class="buttonClasses"></div> |
| 41 | 41 | </Tooltip> |
| 42 | 42 | </div> |
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | <script> |
| 48 | 48 | import InputNumber from '../../components/input-number/input-number.vue'; |
| 49 | 49 | import Tooltip from '../../components/tooltip/tooltip.vue'; |
| 50 | - import { getStyle } from '../../utils/assist'; | |
| 50 | + import { getStyle, oneOf } from '../../utils/assist'; | |
| 51 | 51 | |
| 52 | 52 | const prefixCls = 'ivu-slider'; |
| 53 | 53 | |
| ... | ... | @@ -91,6 +91,13 @@ |
| 91 | 91 | default (val) { |
| 92 | 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 | 103 | data () { |
| ... | ... | @@ -173,6 +180,9 @@ |
| 173 | 180 | }, |
| 174 | 181 | sliderWidth () { |
| 175 | 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 | 188 | watch: { | ... | ... |
src/components/tooltip/tooltip.vue
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | <div :class="[prefixCls + '-rel']" v-el:reference> |
| 4 | 4 | <slot></slot> |
| 5 | 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 | 7 | <div :class="[prefixCls + '-content']"> |
| 8 | 8 | <div :class="[prefixCls + '-arrow']"></div> |
| 9 | 9 | <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div> |
| ... | ... | @@ -41,6 +41,10 @@ |
| 41 | 41 | controlled: { // under this prop,Tooltip will not close when mouseleave |
| 42 | 42 | type: Boolean, |
| 43 | 43 | default: false |
| 44 | + }, | |
| 45 | + always: { | |
| 46 | + type: Boolean, | |
| 47 | + default: false | |
| 44 | 48 | } |
| 45 | 49 | }, |
| 46 | 50 | data () { | ... | ... |
test/routers/more.vue
| ... | ... | @@ -8,6 +8,11 @@ |
| 8 | 8 | top: 0; |
| 9 | 9 | } |
| 10 | 10 | } |
| 11 | + | |
| 12 | + .placeholder { | |
| 13 | + min-height: 2000px; | |
| 14 | + width: 1px; | |
| 15 | + } | |
| 11 | 16 | </style> |
| 12 | 17 | <template> |
| 13 | 18 | <i-button @click="modal9 = true">距离顶部 20px</i-button> |
| ... | ... | @@ -28,6 +33,9 @@ |
| 28 | 33 | <p>对话框内容</p> |
| 29 | 34 | <p>对话框内容</p> |
| 30 | 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 | 39 | </template> |
| 32 | 40 | <script> |
| 33 | 41 | export default { |
| ... | ... | @@ -35,6 +43,24 @@ |
| 35 | 43 | return { |
| 36 | 44 | modal9: false, |
| 37 | 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 | 14 | </div> |
| 15 | 15 | <Slider :value="75"></Slider> |
| 16 | 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 | 20 | </div> |
| 18 | 21 | </template> |
| 19 | 22 | <script> | ... | ... |