Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private createRipple_(): MDCRipple {
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
const adapter: MDCRippleAdapter = {
...MDCRipple.createAdapter(this),
deregisterInteractionHandler: (evtType, handler) => this.nativeControl_.removeEventListener(
evtType, handler, applyPassive()),
isSurfaceActive: () => matches(this.nativeControl_, ':active'),
isUnbounded: () => true,
registerInteractionHandler: (evtType, handler) => this.nativeControl_.addEventListener(
evtType, handler, applyPassive()),
};
return new MDCRipple(this.root_, new MDCRippleFoundation(adapter));
}
private createRipple_(): MDCRipple {
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
const adapter: MDCRippleAdapter = {
...MDCRipple.createAdapter(this),
registerInteractionHandler: (evtType, handler) => this.targetElement_.addEventListener(evtType, handler),
deregisterInteractionHandler: (evtType, handler) => this.targetElement_.removeEventListener(evtType, handler),
};
// tslint:enable:object-literal-sort-keys
return new MDCRipple(this.root_, new MDCRippleFoundation(adapter));
}
MDCTextField.prototype.createRipple_ = function (rippleFactory) {
var _this = this;
var isTextArea = this.root_.classList.contains(cssClasses.TEXTAREA);
var isOutlined = this.root_.classList.contains(cssClasses.OUTLINED);
if (isTextArea || isOutlined) {
return null;
}
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = tslib_1.__assign({}, MDCRipple.createAdapter(this), { isSurfaceActive: function () { return ponyfill.matches(_this.input_, ':active'); }, registerInteractionHandler: function (evtType, handler) { return _this.input_.addEventListener(evtType, handler, applyPassive()); }, deregisterInteractionHandler: function (evtType, handler) {
return _this.input_.removeEventListener(evtType, handler, applyPassive());
} });
// tslint:enable:object-literal-sort-keys
return rippleFactory(this.root_, new MDCRippleFoundation(adapter));
};
return MDCTextField;
MDCSwitch.prototype.createRipple_ = function () {
var _this = this;
var RIPPLE_SURFACE_SELECTOR = MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR;
var rippleSurface = this.root_.querySelector(RIPPLE_SURFACE_SELECTOR);
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
var adapter = tslib_1.__assign({}, MDCRipple.createAdapter(this), { addClass: function (className) { return rippleSurface.classList.add(className); }, computeBoundingRect: function () { return rippleSurface.getBoundingClientRect(); }, deregisterInteractionHandler: function (evtType, handler) {
_this.nativeControl_.removeEventListener(evtType, handler, applyPassive());
}, isSurfaceActive: function () { return matches(_this.nativeControl_, ':active'); }, isUnbounded: function () { return true; }, registerInteractionHandler: function (evtType, handler) {
_this.nativeControl_.addEventListener(evtType, handler, applyPassive());
}, removeClass: function (className) { return rippleSurface.classList.remove(className); }, updateCssVariable: function (varName, value) {
rippleSurface.style.setProperty(varName, value);
} });
return new MDCRipple(this.root_, new MDCRippleFoundation(adapter));
};
Object.defineProperty(MDCSwitch.prototype, "nativeControl_", {
initialize(rippleFactory: MDCRippleFactory = (el, foundation) => new MDCRipple(el, foundation)) {
this.leadingIcon_ = this.root_.querySelector(strings.LEADING_ICON_SELECTOR);
this.trailingIcon_ = this.root_.querySelector(strings.TRAILING_ICON_SELECTOR);
this.checkmark_ = this.root_.querySelector(strings.CHECKMARK_SELECTOR);
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
const rippleAdapter: MDCRippleAdapter = {
...MDCRipple.createAdapter(this),
computeBoundingRect: () => this.foundation_.getDimensions(),
};
this.ripple_ = rippleFactory(this.root_, new MDCRippleFoundation(rippleAdapter));
}
private createRipple_(rippleFactory: MDCRippleFactory): MDCRipple | null {
const isTextArea = this.root_.classList.contains(cssClasses.TEXTAREA);
const isOutlined = this.root_.classList.contains(cssClasses.OUTLINED);
if (isTextArea || isOutlined) {
return null;
}
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
const adapter: MDCRippleAdapter = {
...MDCRipple.createAdapter(this),
isSurfaceActive: () => ponyfill.matches(this.input_, ':active'),
registerInteractionHandler: (evtType, handler) => this.input_.addEventListener(evtType, handler, applyPassive()),
deregisterInteractionHandler: (evtType, handler) =>
this.input_.removeEventListener(evtType, handler, applyPassive()),
};
// tslint:enable:object-literal-sort-keys
return rippleFactory(this.root_, new MDCRippleFoundation(adapter));
}
}
private createRipple_(): MDCRipple {
const {RIPPLE_SURFACE_SELECTOR} = MDCSwitchFoundation.strings;
const rippleSurface = this.root_.querySelector(RIPPLE_SURFACE_SELECTOR) as HTMLElement;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
const adapter: MDCRippleAdapter = {
...MDCRipple.createAdapter(this),
addClass: (className: string) => rippleSurface.classList.add(className),
computeBoundingRect: () => rippleSurface.getBoundingClientRect(),
deregisterInteractionHandler: (evtType: EventType, handler: EventListener) => {
this.nativeControl_.removeEventListener(evtType, handler, applyPassive());
},
isSurfaceActive: () => matches(this.nativeControl_, ':active'),
isUnbounded: () => true,
registerInteractionHandler: (evtType: EventType, handler: EventListener) => {
this.nativeControl_.addEventListener(evtType, handler, applyPassive());
},
removeClass: (className: string) => rippleSurface.classList.remove(className),
updateCssVariable: (varName: string, value: string) => {
rippleSurface.style.setProperty(varName, value);
},
};
return new MDCRipple(this.root_, new MDCRippleFoundation(adapter));
MDCRadio.prototype.createRipple_ = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = tslib_1.__assign({}, MDCRipple.createAdapter(this), { registerInteractionHandler: function (evtType, handler) { return _this.nativeControl_.addEventListener(evtType, handler, applyPassive()); }, deregisterInteractionHandler: function (evtType, handler) { return _this.nativeControl_.removeEventListener(evtType, handler, applyPassive()); },
// Radio buttons technically go "active" whenever there is *any* keyboard interaction.
// This is not the UI we desire.
isSurfaceActive: function () { return false; }, isUnbounded: function () { return true; } });
// tslint:enable:object-literal-sort-keys
return new MDCRipple(this.root_, new MDCRippleFoundation(adapter));
};
Object.defineProperty(MDCRadio.prototype, "nativeControl_", {
initialize(
rippleFactory: MDCRippleFactory = (el, foundation) => new MDCRipple(el, foundation),
tabIndicatorFactory: MDCTabIndicatorFactory = (el) => new MDCTabIndicator(el),
) {
this.id = this.root_.id;
const rippleSurface = this.root_.querySelector(MDCTabFoundation.strings.RIPPLE_SELECTOR)!;
const rippleAdapter = {
...MDCRipple.createAdapter(this),
addClass: (className: string) => rippleSurface.classList.add(className),
removeClass: (className: string) => rippleSurface.classList.remove(className),
updateCssVariable: (varName: string, value: string) => rippleSurface.style.setProperty(varName, value),
};
const rippleFoundation = new MDCRippleFoundation(rippleAdapter);
this.ripple_ = rippleFactory(this.root_, rippleFoundation);
const tabIndicatorElement = this.root_.querySelector(MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR)!;
this.tabIndicator_ = tabIndicatorFactory(tabIndicatorElement);
this.content_ = this.root_.querySelector(MDCTabFoundation.strings.CONTENT_SELECTOR)!;
}