<div id="relative-container" style="position:relative;height:460px"></div>
<script type="text/javascript">
var w = new ludo.FramedView({
title: 'Relative Layout',
renderTo:'#relative-container',
layout: {
width: 400, height: 400,
minWidth: 300, minHeight: 300,
type: 'relative'
},
css:{
margin:2,
border: '1px solid #aaa'
},
id: 'relativeView',
// This is the view for the demo
form: {
listeners: {
'change': function () {
this.view.updatePreviews();
}
}
},
listeners: {
'render': function () {
this.updatePreviews();
}
},
updatePreviews: function () {
var color = this.getColorCode();
if (this.currentColor != color) {
ludo.get('colorPreview').getBody().css('background-color', color);
ludo.get('colorCode').html(color);
this.currentColor = color;
var complementary = this.colorUtil.offsetHue(color, 180);
ludo.get('colorPreviewComplementary').getBody().css('background-color', complementary);
ludo.get('colorCodeComplementary').html(complementary);
}
},
/* Custom function which can be called using this.getColorCode() */
getColorCode: function () {
if (this.colorUtil == undefined) {
this.colorUtil = new ludo.color.Color();
}
return this.colorUtil.rgbCode(
ludo.get('redSlider').val(),
ludo.get('greenSlider').val(),
ludo.get('blueSlider').val()
);
},
children: [
{
id: 'greenValue',
type: 'form.Number',
layout: {
centerHorizontal: true,
alignParentBottom: true,
width: 50
},
linkWith: 'greenSlider'
},
{
id: 'greenSlider',
type: 'form.Seekbar',
orientation: 'vertical',
layout: {
alignLeft: 'greenValue',
above: 'greenValue',
fillUp: true,
width: 50
},
value: 144,
minValue: 0, maxValue: 255,
increments: 1,
thumbColor: '#388E3C',
negativeColor: '#388E3C'
},
/** Red */
{
id: 'redValue',
type: 'form.Number',
layout: {
leftOf: 'greenValue',
alignParentBottom: true,
width: 50,
height:20
},
linkWith: 'redSlider'
},
{
id: 'redSlider',
type: 'form.Seekbar',
orientation: 'vertical',
layout: {
alignLeft: 'redValue',
above: 'redValue',
fillUp: true,
width: 50
},
minValue: 0, maxValue: 255,
thumbColor: '#D32F2F',
negativeColor: '#D32F2F',
increments: 1,
value: 33
},
/** Blue */
{
id: 'blueValue',
type: 'form.Number',
layout: {
rightOf: 'greenValue',
alignParentBottom: true,
width: 50
},
linkWith: 'blueSlider'
},
{
id: 'blueSlider',
increments: 1,
type: 'form.Seekbar',
orientation: 'vertical',
layout: {
alignLeft: 'blueValue',
above: 'blueValue',
fillUp: true,
width: 50
},
value: 22,
thumbColor: '#1976D2',
negativeColor: '#1976D2',
minValue: 0, maxValue: 255,
},
{
id: 'colorPreview',
layout: {
type: 'relative',
alignParentTop: true,
leftOf: 'redValue',
fillLeft: true,
fillDown: true
},
children: [
{
id: 'colorCode',
elCss: {
border: '1px solid #EEE',
'border-radius': '10px'
},
css: {
'line-height': '20px',
'text-align': 'center'
},
layout: {
centerInParent: true,
width: 70,
height: 20
}
}
]
},
{
id: 'colorPreviewComplementary',
layout: {
type: 'relative',
alignParentTop: true,
rightOf: 'blueValue',
fillRight: true,
fillDown: true
},
children: [
{
id: 'colorCodeComplementary',
elCss: {
border: '1px solid #EEE',
'border-radius': '10px'
},
css: {
'line-height': '20px',
'text-align': 'center'
},
layout: {
centerInParent: true,
width: 70,
height: 20
}
},
{
layout: {
centerHorizontal: true,
width: 100,
alignParentTop: true,
offsetY: 20,
height:20
},
elCss: {
border: '1px solid #EEE',
'border-radius': '10px',
'background-color': '#333',
color: '#EEE'
},
css: {
'font-size': '0.8em',
'text-align': 'center',
'line-height': '17px'
},
html: 'Complementary'
}
]
}
]
});
</script>