-
-
Save AshleyGrant/6e4a6ea77751ae9c69b178eb51105137 to your computer and use it in GitHub Desktop.
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> | |
Control value: ${controlValue} | |
<form> | |
<div class="form-group"> | |
<test></test> | |
<label for="color">Color</label> | |
<input type="text" value.bind="colorInfo.color" class="form-control" id="color"> | |
<div>Color: ${colorInfo.color}</div> | |
</div> | |
<div class="form-group"> | |
<test></test> | |
<label for="color">Color</label> | |
<input type="text" ref="minicolors" value.bind="colorInfo.color" class="form-control" id="color"> | |
<div>Color: ${colorInfo.color}</div> | |
</div> | |
</form> | |
</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 {inject, BindingEngine} from 'aurelia-framework'; | |
@inject(BindingEngine) | |
export class App { | |
colorInfo = { | |
color: '#ff6161' | |
} | |
constructor(bindingEngine) { | |
this.subscription = bindingEngine.propertyObserver(this.colorInfo, 'color') | |
.subscribe( () => { | |
this.widget.minicolors('value', this.colorInfo.color); | |
}); | |
} | |
attached() { | |
this.widget = $(this.minicolors); | |
this.widget.minicolors({ | |
change: (color, opacity) => { | |
this.colorInfo.color = color; | |
this.colorInfo.opacity = opacity; | |
} | |
}); | |
} | |
get controlValue() { | |
if(this.widget) { | |
return this.widget.minicolors('value'); | |
} | |
return ''; | |
} | |
detached() { | |
subscription.dispose(); | |
} | |
} |
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 href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" | |
crossorigin="anonymous"> | |
<link href="https://rawgit.com/claviska/jquery-minicolors/2.2.4/jquery.minicolors.css" rel="stylesheet"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" | |
crossorigin="anonymous"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" | |
crossorigin="anonymous"></script> | |
<script src="https://rawgit.com/claviska/jquery-minicolors/2.2.4/jquery.minicolors.js"></script> | |
<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