use of org.olat.core.gui.components.form.flexible.elements.SliderElement in project OpenOLAT by OpenOLAT.
the class EvaluationFormController method forgeContinuousSlider.
private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element, EvaluationFormResponse response) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setEnabled(!readOnly);
if (response != null && response.getNumericalResponse() != null) {
double val = response.getNumericalResponse().doubleValue();
sliderEl.setInitialValue(val);
}
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.core.gui.components.form.flexible.elements.SliderElement in project openolat by klemens.
the class SliderElementRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
SliderElementComponent sec = (SliderElementComponent) source;
SliderElement sel = sec.getSliderElement();
String formDispatchFieldId = sel.getRootForm().getDispatchFieldId();
String inputId = sec.getFormDispatchId().concat("_sinput");
sb.append("<div id='").append(sec.getFormDispatchId()).append("_slider'> </div>");
sb.append("<input id='").append(inputId).append("' type='hidden' name='").append(sec.getFormDispatchId()).append("' value=''/>");
sb.append("<script type='text/javascript'>/* <![CDATA[ */\n").append("jQuery(function() {\n").append(" jQuery('#").append(sec.getFormDispatchId()).append("_slider').slider({\n").append(" value: ").append(sec.getInitialValue()).append(",\n");
if (sec.getStep() > 0) {
sb.append(" step: ").append(sec.getStep()).append(",\n");
}
sb.append(" min: ").append(sec.getMinValue()).append(",\n").append(" max: ").append(sec.getMaxValue()).append(",\n").append(" slide: function(event, ui) {\n").append(" jQuery('#").append(inputId).append("').val(ui.value);\n").append(" setFlexiFormDirty('").append(formDispatchFieldId).append("');\n").append(" },\n").append(" stop: function(event, ui) {\n").append(" jQuery('#").append(inputId).append("').val(ui.value);\n");
if (sel.getAction() >= 0) {
sb.append(" ").append(FormJSHelper.getJSFnCallFor(sel.getRootForm(), sec.getFormDispatchId(), 2)).append(";\n");
}
sb.append(" setFlexiFormDirty('").append(formDispatchFieldId).append("');\n").append(" }\n").append(" })");
if (!sec.isEnabled()) {
sb.append(".slider('disable')");
}
if (sec.getStep() > 0) {
sb.append(".slider('pips', {\n").append(" first:'pip',\n").append(" last:'pip',\n").append("})");
}
sb.append("\n");
sb.append("});\n").append("/* ]]> */</script>\n");
}
use of org.olat.core.gui.components.form.flexible.elements.SliderElement in project openolat by klemens.
the class EvaluationFormController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (saveAsDoneButton == source) {
doConfirmDone(ureq);
} else if (source instanceof SingleSelection) {
SingleSelection radioEl = (SingleSelection) source;
Object uobject = radioEl.getUserObject();
if (uobject instanceof SliderWrapper) {
String selectedKey = radioEl.getSelectedKey();
SliderWrapper sliderWrapper = (SliderWrapper) uobject;
saveNumericalResponse(new BigDecimal(selectedKey), selectedKey, sliderWrapper.getId());
}
} else if (source instanceof SliderElement) {
SliderElement slider = (SliderElement) source;
Object uobject = slider.getUserObject();
if (uobject instanceof SliderWrapper) {
double value = slider.getValue();
SliderWrapper sliderWrapper = (SliderWrapper) uobject;
saveNumericalResponse(BigDecimal.valueOf(value), Double.toString(value), sliderWrapper.getId());
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
Object uobject = link.getUserObject();
if (uobject instanceof TextInputWrapper) {
TextInputWrapper wrapper = (TextInputWrapper) uobject;
String value = wrapper.getTextEl().getValue();
saveNumericalResponse(null, value, wrapper.getId());
}
} else if (source instanceof FileElement) {
FileElement fileElement = (FileElement) source;
Object uobject = fileElement.getUserObject();
if (uobject instanceof FileUploadWrapper) {
FileUploadWrapper wrapper = (FileUploadWrapper) uobject;
if (event instanceof FileElementEvent) {
if (FileElementEvent.DELETE.equals(event.getCommand())) {
saveFileResponse(null, null, wrapper.getId());
fileElement.setInitialFile(null);
if (fileElement.getUploadFile() != null) {
fileElement.reset();
}
flc.setDirty(true);
}
} else if (fileElement.isUploadSuccess()) {
File file = fileElement.getUploadFile();
String filename = fileElement.getUploadFileName();
saveFileResponse(file, filename, wrapper.getId());
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.SliderElement in project openolat by klemens.
the class EvaluationFormController method forgeDiscreteSlider.
private SliderWrapper forgeDiscreteSlider(Slider slider, Rubric element, EvaluationFormResponse response) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setEnabled(!readOnly);
if (response != null && response.getNumericalResponse() != null) {
double val = response.getNumericalResponse().doubleValue();
sliderEl.setInitialValue(val);
}
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
sliderEl.setStep(1);
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.core.gui.components.form.flexible.elements.SliderElement in project openolat by klemens.
the class RubricController method forgeContinuousSlider.
private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
Aggregations