Skip to content

Commit b367ac3

Browse files
committed
feat(ui): small tweaks to events util
1 parent 09f3e4d commit b367ac3

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
lines changed

ui/dev/src/pages/form/form.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
<q-toggle v-model="autofocus" label="Autofocus" />
1010
<q-toggle v-model="dark" label="Dark" :false-value="null" />
1111
<q-toggle v-model="greedy" label="Greedy" />
12+
<q-toggle v-model="customInput" label="Custom Input" />
1213
<q-option-group class="q-mb-lg" inline v-model="autofocusEl" dense="dense" :options="autofocusEls" />
1314

15+
<q-btn loading label="loading" @click.native="onClick" />
16+
<q-btn label="loading" @click.native="onClick" />
1417
<q-form
1518
v-if="show"
1619
:autofocus="autofocus"
@@ -25,6 +28,7 @@
2528
>
2629
<div class="q-col-gutter-md">
2730
<custom-input
31+
v-if="customInput"
2832
filled
2933
v-model="customValue"
3034
label="Custom value *"
@@ -78,8 +82,8 @@
7882
<q-toggle :dark="dark" v-model="accept" label="I accept the license and terms" :autofocus="autofocusEl === 3" />
7983

8084
<div>
81-
<q-btn label="Submit" type="submit" color="primary" />
82-
<q-btn label="Reset" type="reset" color="primary" flat class="q-ml-sm" />
85+
<q-btn label="Submit" type="submit" color="primary" loading />
86+
<q-btn label="Reset" type="reset" color="primary" flat class="q-ml-sm" loading />
8387
</div>
8488
</div>
8589
</q-form>
@@ -160,7 +164,8 @@ export default {
160164
161165
user: null,
162166
pwd: null,
163-
customValue: ''
167+
customValue: '',
168+
customInput: true
164169
}
165170
},
166171
@@ -194,6 +199,11 @@ export default {
194199
195200
onValidationError () {
196201
console.log('@validation-error')
202+
},
203+
204+
onClick () {
205+
this.$q.notify('click')
206+
console.log('cliiick')
197207
}
198208
}
199209
}

ui/src/directives/TouchHold.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { client } from '../plugins/Platform.js'
22
import { addEvt, cleanEvt, getTouchTarget } from '../utils/touch.js'
3-
import { position, leftClick, stopAndPrevent } from '../utils/event.js'
3+
import { position, leftClick, stopAndPrevent, noop } from '../utils/event.js'
44
import { clearSelection } from '../utils/selection.js'
55

66
function update (el, binding) {
@@ -38,7 +38,7 @@ export default {
3838
}
3939

4040
const ctx = {
41-
noop () { },
41+
noop,
4242

4343
mouseStart (evt) {
4444
if (typeof ctx.handler === 'function' && leftClick(evt) === true) {

ui/src/directives/TouchPan.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { client } from '../plugins/Platform.js'
22
import { getModifierDirections, updateModifiers, addEvt, cleanEvt, getTouchTarget, shouldStart } from '../utils/touch.js'
3-
import { position, leftClick, prevent, stop, stopAndPrevent, preventDraggable } from '../utils/event.js'
3+
import { position, leftClick, prevent, stop, stopAndPrevent, preventDraggable, noop } from '../utils/event.js'
44
import { clearSelection } from '../utils/selection.js'
55

66
function getChanges (evt, ctx, isFinal) {
@@ -141,7 +141,7 @@ export default {
141141
modifiers,
142142
direction: getModifierDirections(modifiers),
143143

144-
noop () {},
144+
noop,
145145

146146
mouseStart (evt) {
147147
if (shouldStart(evt, ctx) && leftClick(evt)) {

ui/src/directives/TouchRepeat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { client } from '../plugins/Platform.js'
22
import { addEvt, cleanEvt, getTouchTarget } from '../utils/touch.js'
3-
import { position, leftClick, stopAndPrevent } from '../utils/event.js'
3+
import { position, leftClick, stopAndPrevent, noop } from '../utils/event.js'
44
import { clearSelection } from '../utils/selection.js'
55
import { isKeyCode } from '../utils/key-composition.js'
66

@@ -56,7 +56,7 @@ export default {
5656
keyboard,
5757
handler: value,
5858

59-
noop () {},
59+
noop,
6060

6161
mouseStart (evt) {
6262
if (ctx.event === void 0 && typeof ctx.handler === 'function' && leftClick(evt) === true) {

ui/src/directives/TouchSwipe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { client } from '../plugins/Platform.js'
22
import { getModifierDirections, updateModifiers, addEvt, cleanEvt, getTouchTarget, shouldStart } from '../utils/touch.js'
3-
import { position, leftClick, stopAndPrevent, preventDraggable } from '../utils/event.js'
3+
import { position, leftClick, stopAndPrevent, preventDraggable, noop } from '../utils/event.js'
44
import { clearSelection } from '../utils/selection.js'
55

66
function parseArg (arg) {
@@ -37,7 +37,7 @@ export default {
3737
modifiers: modifiers,
3838
direction: getModifierDirections(modifiers),
3939

40-
noop () {},
40+
noop,
4141

4242
mouseStart (evt) {
4343
if (shouldStart(evt, ctx) && leftClick(evt)) {

ui/src/mixins/btn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ export default {
118118
colors = `text-${this.textColor}`
119119
}
120120

121-
return `q-btn--${this.design} q-btn--${this.isRound === true ? 'round' : 'rectangle'}` +
121+
return `q-btn--${this.design} ` +
122+
`q-btn--${this.isRound === true ? 'round' : `rectangle${this.rounded === true ? ' q-btn--rounded' : ''}`}` +
122123
(colors !== void 0 ? ' ' + colors : '') +
123124
(this.isActionable === true ? ' q-btn--actionable q-focusable q-hoverable' : (this.disable === true ? ' disabled' : '')) +
124125
(this.fab === true ? ' q-btn--fab' : (this.fabMini === true ? ' q-btn--fab-mini' : '')) +
125126
(this.noCaps === true ? ' q-btn--no-uppercase' : '') +
126127
(this.noWrap === true ? '' : ' q-btn--wrap') + // this is for IE11
127-
(this.rounded === true && this.isRound !== true ? ' q-btn--rounded' : '') +
128128
(this.dense === true ? ' q-btn--dense' : '') +
129129
(this.stretch === true ? ' no-border-radius self-stretch' : '') +
130130
(this.glossy === true ? ' glossy' : '')

ui/src/utils.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import copyToClipboard from './utils/copy-to-clipboard.js'
44
import date from './utils/date.js'
55
import debounce from './utils/debounce.js'
66
import dom from './utils/dom.js'
7-
import event from './utils/event.js'
7+
import event, { noop } from './utils/event.js'
88
import exportFile from './utils/export-file.js'
99
import extend from './utils/extend.js'
1010
import format from './utils/format.js'
@@ -15,8 +15,6 @@ import scroll from './utils/scroll.js'
1515
import throttle from './utils/throttle.js'
1616
import uid from './utils/uid.js'
1717

18-
function noop () {}
19-
2018
export {
2119
clone,
2220
colors,

ui/src/utils/event.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ try {
2121
}
2222
catch (e) {}
2323

24+
export function noop () {}
25+
2426
export function leftClick (e) {
2527
return e.button === 0
2628
}

0 commit comments

Comments
 (0)