defaultkavy
8e37f65f4f
fix: Array.detype() return empty array. new: RouteRecord, Route with path resolve function. change: $ElementManager rename to $NodeManager. add: $Node.hide() and $Node.show(). fix: $Node parent undefined. add: create element with 'label', 'input'. new: $.state() to binding data in element. new: $Form, $Button. fix: Router resolve path id bug
24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
import { $Container, $ContainerOptions } from "./$Container";
|
|
|
|
export interface AnchorOptions extends $ContainerOptions {}
|
|
|
|
export class $Anchor extends $Container<HTMLAnchorElement> {
|
|
constructor(options?: AnchorOptions) {
|
|
super('a', options);
|
|
// Link Handler event
|
|
this.dom.addEventListener('click', e => {
|
|
if ($.anchorPreventDefault) e.preventDefault();
|
|
if ($.anchorHandler && !!this.href()) $.anchorHandler(this.href(), e)
|
|
})
|
|
}
|
|
/**Set URL of anchor element. */
|
|
href(): string;
|
|
href(url: string | undefined): this;
|
|
href(url?: string | undefined) { return $.fluent(this, arguments, () => this.dom.href, () => {if (url) this.dom.href = url}) }
|
|
/**Link open with this window, new tab or other */
|
|
target(): string;
|
|
target(target: $AnchorTarget | undefined): this;
|
|
target(target?: $AnchorTarget | undefined) { return $.fluent(this, arguments, () => this.dom.target, () => {if (target) this.dom.target = target}) }
|
|
}
|
|
|
|
export type $AnchorTarget = '_blank' | '_self' | '_parent' | '_top'; |