Skip to content

Instantly share code, notes, and snippets.

@jasoncarreira
Forked from Thanood/app.html
Last active April 26, 2016 06:14
Show Gist options
  • Save jasoncarreira/e876e03ee86fe0fc4ab263f1bf3a3e86 to your computer and use it in GitHub Desktop.
Save jasoncarreira/e876e03ee86fe0fc4ab263f1bf3a3e86 to your computer and use it in GitHub Desktop.
Aurelia - Materialize Range
<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>
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);
}
}
<!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>
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;
}
}
}
/*******************************************************************************
* 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());
}
<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