-
-
Save jasoncarreira/e876e03ee86fe0fc4ab263f1bf3a3e86 to your computer and use it in GitHub Desktop.
Aurelia - Materialize Range
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="./slider-value.html"></require> | |
<md-colors md-primary-color="#ee6e73" md-accent-color="#009688"></md-colors> | |
<section class="au-animate"> | |
<h2>YourChoices</h2> | |
<slider-value propertyName.two-way="retirementAge" label="Retirement Age" callback="onRetirementAgeChanged"></slider-value> | |
</section> |
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 { | |
_retirementAge; | |
constructor() { | |
this._retirementAge = 68; | |
} | |
get retirementAge() { | |
return this._retirementAge; | |
} | |
set retirementAge(value) { | |
this._retirementAge = value; | |
} | |
retirementAgeChanged = function() { | |
alert("Retirement aged changed to " + retirementAge); | |
} | |
} |
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> | |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script> | |
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-materialize-bundles/0.1.1/config2.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
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
const interceptMethods = ['updateTarget', 'updateSource', 'callSource']; | |
export class InterceptBindingBehavior { | |
bind(binding, scope, interceptor) { | |
let i = interceptMethods.length; | |
while (i--) { | |
let method = interceptMethods[i]; | |
if (!binding[method]) { | |
continue; | |
} | |
binding[`intercepted-${method}`] = binding[method]; | |
let update = binding[method].bind(binding); | |
binding[method] = interceptor.bind(binding, method, update); | |
} | |
} | |
unbind(binding, scope) { | |
let i = interceptMethods.length; | |
while (i--) { | |
let method = interceptMethods[i]; | |
if (!binding[method]) { | |
continue; | |
} | |
binding[method] = binding[`intercepted-${method}`]; | |
binding[`intercepted-${method}`] = 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
/******************************************************************************* | |
* The following two lines enable async/await without using babel's | |
* "runtime" transformer. Uncomment the lines if you intend to use async/await. | |
* | |
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2 | |
*/ | |
//import regeneratorRuntime from 'babel-runtime/regenerator'; | |
//window.regeneratorRuntime = regeneratorRuntime; | |
/******************************************************************************/ | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-materialize-bridge', bridge => bridge.useAll() ); | |
aurelia.start().then(a => a.setRoot()); | |
} |
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 bindable="propertyName, label, callback"> | |
<require from="./intercept-binding-behavior"></require> | |
<div>${label}</div> | |
<div> | |
<md-range md-value.two-way="propertyName & intercept:onRetirementAgeChanged"></md-range> | |
</div> | |
<div> | |
<md-input md-label="${label}" md-value.two-way="propertyName & intercept:onRetirementAgeChanged"></md-input> | |
</div> | |
</template> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment