Last active
August 21, 2017 07:02
-
-
Save bigopon/2fab3554cca54ed8c7ed82db15ecc96d to your computer and use it in GitHub Desktop.
Datepicker
This file contains hidden or 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
<template> | |
<require from="./datepicker"></require> | |
<br/> | |
<br/> | |
<date-picker date.two-way='date'></date-picker> | |
<hr/> | |
<b>Date in app view model: ${date}</b> | |
</template> |
This file contains hidden or 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
export class App { | |
empty = false; | |
/** | |
* Random data | |
*/ | |
messages = (() => { | |
const msgs = []; | |
for (let i = 1; i < 5; ++i) { | |
msgs.push(`Inbox message ${i}`); | |
} | |
return msgs | |
})(); | |
clickedMessages = []; | |
logClick(msg, index) { | |
this.clickedMessages.push(`Clicked msg with index: ${index} at ${+new Date()}`); | |
if (this.clickedMessages.length === this.messages.length) { | |
this.empty = true; | |
} | |
} | |
} |
This file contains hidden or 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
<template> | |
<input type='text' ref='input' /> | |
</template> |
This file contains hidden or 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
import { | |
customElement, | |
bindable | |
} from 'aurelia-framework'; | |
@customElement('date-picker') | |
export class DatePicker { | |
@bindable date; | |
attached() { | |
this.pikaday = new Pikaday({ | |
field: this.input, | |
onSelect: date => { | |
this.date = date | |
} | |
}); | |
} | |
detached() { | |
this.pikaday.destroy(); | |
this.pikaday = null; | |
} | |
} |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> | |
<style> | |
body { | |
padding: 20px; | |
} | |
.form-component { | |
display: block; | |
margin-bottom: 20px; | |
} | |
</style> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.6.1/css/pikaday.css" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.6.1/pikaday.min.js"></script> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment