Hi Pyromanik
ive tested your suggestion but this also doesnt set an ID.
it would be handy to have an id on that field to use it in jquery.
class MyImageDecorator extends DataExtension :
function getCustomFields(){
Requirements::javascript('mysite/javascript/ImageDecorator.js');
Requirements::css("mysite/css/ImageDecorator.css");
$previewSrc = $this->owner->getMyCMSFilter() ? $this->owner->GetMyCMSFilter()->SetHeight(100)->Link() : $this->owner->SetHeight(100)->Link();
$size = $this->owner->getMyCMSFilter() ? $this->format_size(filesize($this->owner->GetMyCMSFilter()->getFullPath())) : $this->format_size(filesize($this->owner->getFullPath()));
//$size = ceil(filesize($this->owner->GetMyCMSFilter()->getFullPath()) / 1024).' KB';
$urlField = new FieldGroup(
new LiteralField('', '<div style="height: 100px;">
<img id="loader" src="'.PROJECT_DIR.'/img/loading.gif"/>
<img id="preview" style="display:none;" src="'.$previewSrc.'"/>
</div>'
),
new LiteralField('',$size)
);
$urlField->setTitle('Preview');
$selectionGroup = new OptionsetField(
$name = "Rotate",
$title = "Rotate",
$source = array(
"1" => "90º CW",
"2" => "90º CCW",
"3" => "180º"
),
$value = ""
);
$filter = new OptionsetField(
$name = "Filter",
$title = "Filter",
$source = array(
"Colorize,100,10,10" => "Colorize Red",
"Greyscale,0,0,255" => "Greyscale",
"Colorize,10,100,10" => "Colorize Green",
"Sepia" => "Sepia",
"Colorize,10,10,100" => "Colorize Blue",
"Custom" => "Custom Colorize",
"" => "REMOVE FILTER"
),
$value = ""
);
$CFGroup = FieldGroup::create(
new SliderField('BN', 'Brightness', -100, 100),
new SliderField('R', 'Red', 0, 255),
new SliderField('G', 'Green', 0, 255),
new SliderField('B', 'Blue', 0, 255)
)->setAttribute('ID', 'CFGroup');
//$CFGroup->setID('CFGroup');
//$CFGroup->setAttribute('ID', 'CFGroup');
$fields = new FieldList();
if($this->owner->getMyCMSFilter() || isset($_POST['Rotate'])){
$fields->push($urlField);
}
$fields->push($selectionGroup);
$fields->push($filter);
$fields->push($CFGroup);
return $fields;
}
(function($) {
$.entwine('ss',function($) {
$('input[name=Filter]').entwine({
onmatch: function() {
$active = $('input[name=Filter]:checked').val();
$('#Filter').next().css({'display' : 'none'}); // ID ???? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if($active == 'Custom'){
$('#Filter').next().css( {'display' : 'block'} );
}
},
onchange: function() {
var radiovalue = $(this).val();
if(radiovalue == 'Custom'){
$('#Filter').next().css( {'display' : 'block'} );
}else{
$('#Filter').next().css( {'display' : 'none'} );
}
}
});
});
})(jQuery);
timo.