Skip to content

Commit

Permalink
feat(textfield): implement mdc v0.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stasson committed Dec 18, 2017
1 parent 7422b42 commit cf20cb5
Showing 1 changed file with 53 additions and 71 deletions.
124 changes: 53 additions & 71 deletions components/textfield/mdc-textfield.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,73 +138,6 @@ export default {
}
},
mounted () {
this.foundation = new MDCTextfieldFoundation({
addClass: (className) => {
this.$set(this.rootClasses, className, true)
},
removeClass: (className) => {
this.$delete(this.rootClasses, className)
},
addClassToLabel: (className) => {
this.$set(this.labelClasses, className, true)
},
removeClassFromLabel: (className) => {
this.$delete(this.labelClasses, className)
},
setIconAttr: (/* name: string, value: string */) => {},
eventTargetHasClass: (target, className) => target.classList.contains(className),
registerTextFieldInteractionHandler: (evtType, handler) => {
this.$refs.root.addEventListener(evtType, handler)
},
deregisterTextFieldInteractionHandler: (evtType, handler) => {
this.$refs.root.removeEventListener(evtType, handler)
},
registerInputInteractionHandler: (evtType, handler) => {
this.$refs.input.addEventListener(evtType, handler)
},
deregisterInputInteractionHandler: (evtType, handler) => {
this.$refs.input.removeEventListener(evtType, handler)
},
// registerTransitionEndHandler: (handler) => {
// if (this.$refs.bottom) {
// this.$refs.bottom.addEventListener('transitionend', handler)
// }
// },
// deregisterTransitionEndHandler: (handler) => {
// if (this.$refs.bottom) {
// this.$refs.bottom.removeEventListener('transitionend', handler)
// }
// },
getNativeInput: () => {
return this.$refs.input
},
notifyIconAction: () => {
this.$emit('icon')
},
registerBottomLineEventHandler: (evtType, handler) => {
if (this.$refs.bottom) {
this.$refs.bottom.addEventListener(evtType, handler);
}
},
deregisterBottomLineEventHandler: (evtType, handler) => {
if (this.$refs.bottom) {
this.$refs.bottom.removeEventListener(evtType, handler);
}
},
getBottomLineFoundation: () => {
if (this.$refs.bottom) {
return this.bottomLineFoundation
}
return undefined;
},
getHelperTextFoundation: () => {
if (this.$refs.help) {
return this.helperTextFoundation
}
return undefined;
},
})
if (this.$refs.bottom) {
this.bottomLineFoundation = new MDCTextFieldBottomLineFoundation({
addClass: (className) => {
Expand Down Expand Up @@ -255,6 +188,55 @@ export default {
})
this.helperTextFoundation.init()
}
this.foundation = new MDCTextfieldFoundation({
addClass: (className) => {
this.$set(this.rootClasses, className, true)
},
removeClass: (className) => {
this.$delete(this.rootClasses, className)
},
addClassToLabel: (className) => {
this.$set(this.labelClasses, className, true)
},
removeClassFromLabel: (className) => {
this.$delete(this.labelClasses, className)
},
setIconAttr: (/* name: string, value: string */) => {},
eventTargetHasClass: (target, className) => target.classList.contains(className),
registerTextFieldInteractionHandler: (evtType, handler) => {
this.$refs.root.addEventListener(evtType, handler)
},
deregisterTextFieldInteractionHandler: (evtType, handler) => {
this.$refs.root.removeEventListener(evtType, handler)
},
registerInputInteractionHandler: (evtType, handler) => {
this.$refs.input.addEventListener(evtType, handler)
},
deregisterInputInteractionHandler: (evtType, handler) => {
this.$refs.input.removeEventListener(evtType, handler)
},
getNativeInput: () => {
return this.$refs.input
},
notifyIconAction: () => {
this.$emit('icon')
},
registerBottomLineEventHandler: (evtType, handler) => {
if (this.$refs.bottom) {
this.$refs.bottom.addEventListener(evtType, handler);
}
},
deregisterBottomLineEventHandler: (evtType, handler) => {
if (this.$refs.bottom) {
this.$refs.bottom.removeEventListener(evtType, handler);
}
},
}, {
bottomLine: this.bottomLineFoundation,
helperText: this.helperTextFoundation
})
this.foundation.init()
this.foundation.setDisabled(this.disabled)
Expand All @@ -266,10 +248,10 @@ export default {
},
beforeDestroy () {
this.foundation.destroy()
if (this.ripple) {
this.ripple.destroy()
}
this.foundation && this.foundation.destroy()
this.bottomLineFoundation && this.bottomLineFoundation.destroy()
this.helperTextFoundation && this.helperTextFoundation.destroy()
this.ripple && this.ripple.destroy()
}
}
</script>

0 comments on commit cf20cb5

Please sign in to comment.