This repository has been archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: charist-events attibute to attach to events fired by chartist o…
…r plugins
- Loading branch information
1 parent
d445050
commit ababb0f
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { customAttribute, dynamicOptions, inject } from "aurelia-framework"; | ||
import { ChartistElement } from "./chartist"; | ||
|
||
@dynamicOptions() | ||
@inject(Element) | ||
@customAttribute("chartist-events") | ||
export class ChartistEventsAttribute { | ||
|
||
private isCustomElement = false; | ||
private elementVM: ChartistElement; | ||
|
||
constructor (private element) { | ||
this.isCustomElement = typeof(element.au.controller) === "object" && typeof(element.au.controller.viewModel) === "object"; | ||
if (this.isCustomElement) { | ||
this.elementVM = element.au.controller.viewModel; | ||
} | ||
} | ||
|
||
public propertyChanged(name, value) { | ||
|
||
if (!this.isCustomElement) { | ||
return; | ||
} | ||
|
||
if (this.elementVM.chart) { | ||
this.elementVM.chart.on(name, data => value({ sdata: data })); | ||
} else { | ||
this.elementVM.eventsToAttachOnAttached.push( { name: name, value: data => value({ data: data }) }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function configure(config) { | ||
config.globalResources("./chartistElement"); | ||
config.globalResources(["./charlist", "./charlist-events"]); | ||
} |