use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class MenuTreeRenderer method renderInsertCalloutButton.
private void renderInsertCalloutButton(String cmd, String cssClass, StringOutput sb, TreeNode node, URLBuilder ubu, AJAXFlags flags) {
sb.append("<a class='btn btn-default small' ");
ubu.buildHrefAndOnclick(sb, flags.isIframePostEnabled(), new NameValuePair(COMMAND_ID, cmd), new NameValuePair(NODE_IDENT, node.getIdent()));
sb.append("><i class='o_icon ").append(cssClass).append("'> </i></a>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class MenuTreeRenderer method renderInsertionPoint.
private void renderInsertionPoint(StringOutput sb, Position positionToRender, int level, TreeNode node, URLBuilder ubu, AJAXFlags flags, MenuTree tree) {
if (tree.getInsertionPoint() != null && tree.getInsertionPoint().getPosition() == positionToRender && tree.getInsertionPoint().getNodeId().equals(node.getIdent())) {
sb.append("<li><div class='o_tree_l").append(level).append("'>").append("<span class=\"o_tree_leaf o_tree_oc_l").append(level).append("\"> </span>").append("<span class='o_tree_link o_tree_l").append(level).append(" o_insertion_point'><a href=\"");
ubu.buildHrefAndOnclick(sb, null, flags.isIframePostEnabled(), false, false, new NameValuePair(COMMAND_ID, COMMAND_TREENODE_INSERT_REMOVE), new NameValuePair(NODE_IDENT, node.getIdent()));
Translator pointTranslator = Util.createPackageTranslator(MenuTreeRenderer.class, tree.getTranslator().getLocale());
String pointTranslation = pointTranslator.translate("insertion.point");
sb.append("><span>").append(pointTranslation).append(" <i class='o_icon o_icon_remove'> </i></span>").append("</a></span></div></li>");
}
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class TabbedPaneRenderer method render.
/**
* @see org.olat.core.gui.render.ui.ComponentRenderer#render(org.olat.core.gui.render.Renderer, org.olat.core.gui.render.StringOutput, org.olat.core.gui.components.Component, org.olat.core.gui.render.URLBuilder, org.olat.core.gui.translator.Translator, org.olat.core.gui.render.RenderResult, java.lang.String[])
*/
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
TabbedPane tb = (TabbedPane) source;
int cnt = tb.getTabCount();
// nothing to render
if (cnt == 0)
return;
int selPane = tb.getSelectedPane();
boolean iframePostEnabled = renderer.getGlobalSettings().getAjaxFlags().isIframePostEnabled();
sb.append("<div id=\"o_c").append(tb.getDispatchID()).append("\" class='o_tabbed_pane'>");
sb.append("<ul class='nav nav-tabs");
String css = tb.getElementCssClass();
if (StringHelper.containsNonWhitespace(css)) {
sb.append(" ").append(css);
}
sb.append("'>");
for (int i = 0; i < cnt; i++) {
String tabName = tb.getDisplayNameAt(i);
// Render active tab as non clickable, passive tabs with link
sb.append("<li");
if (i != selPane && cnt > 1) {
if (tb.isEnabled(i)) {
sb.append("><a ");
ubu.buildHrefAndOnclick(sb, iframePostEnabled, new NameValuePair(TabbedPane.PARAM_PANE_ID, String.valueOf(i)));
sb.append(">").append(tabName).append("</a></li>");
} else {
// disabled panels can not be clicked, but for layout reason needs still a a href
sb.append(" class='disabled'><a href='javascript:;' title='").append(StringHelper.escapeHtml(translator.translate("disabled"))).append("'>").append(tabName).append("</a></li>");
}
} else {
sb.append(" class='active'><a href='javascript:;'>").append(tabName).append("</a></li>");
}
}
sb.append("</ul>");
// now let the selected component render itself
Component paneToRender = tb.getTabAt(selPane);
sb.append("<div class='o_tabbed_pane_content'>");
if (paneToRender != null) {
renderer.render(sb, paneToRender, null);
}
sb.append("</div></div>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class AssessmentTestComponentRenderer method renderSectionRubrics.
private void renderSectionRubrics(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode itemRefNode, URLBuilder ubu, Translator translator) {
boolean writeRubrics = false;
boolean writeTitles = false;
List<AssessmentSection> sectionParentLine = new ArrayList<>();
for (TestPlanNode parentNode = itemRefNode.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
AssessmentSection selectedSection = component.getAssessmentSection(parentNode.getIdentifier());
if (selectedSection != null && selectedSection.getVisible()) {
sectionParentLine.add(selectedSection);
if (selectedSection.getRubricBlocks().size() > 0) {
for (RubricBlock rubric : selectedSection.getRubricBlocks()) {
if (rubric.getBlocks().size() > 0) {
writeRubrics = true;
}
}
}
if (StringHelper.containsNonWhitespace(selectedSection.getTitle())) {
writeTitles = true;
}
}
}
if (writeRubrics) {
boolean show = true;
for (int i = sectionParentLine.size(); i-- > 0; ) {
AssessmentSection selectedSection = sectionParentLine.get(i);
if (component.getCandidateSessionContext().isRubricHidden(selectedSection.getIdentifier())) {
show = false;
}
}
String key = sectionParentLine.get(0).getIdentifier().toString();
Form form = component.getQtiItem().getRootForm();
String dispatchId = component.getQtiItem().getFormDispatchId();
sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics translated'><i class='o_icon o_icon-fw ");
if (show) {
sb.append("o_icon_close_togglebox'> </i> <span>").append(translator.translate("hide.rubric"));
} else {
sb.append("o_icon_open_togglebox'> </i> <span>").append(translator.translate("show.rubric"));
}
sb.append("</span></a>");
sb.append("<div class='o_info o_assessmentsection_rubrics clearfix");
if (show) {
sb.append(" o_show");
} else {
sb.append(" o_hide");
}
sb.append("'>");
// write the titles first
if (writeTitles) {
sb.append("<h4>");
for (int i = 0; i < sectionParentLine.size(); i++) {
if (i == 1) {
sb.append("<small>");
} else if (i > 1) {
sb.append(" / ");
}
sb.append(sectionParentLine.get(i).getTitle());
}
if (sectionParentLine.size() > 1) {
sb.append("</small>");
}
sb.append("</h4>");
}
for (int i = sectionParentLine.size(); i-- > 0; ) {
AssessmentSection selectedSection = sectionParentLine.get(i);
for (RubricBlock rubricBlock : selectedSection.getRubricBlocks()) {
// @view (candidate)
sb.append("<div class='rubric'>");
rubricBlock.getBlocks().forEach(block -> renderBlock(renderer, sb, component, null, null, block, ubu, translator));
sb.append("</div>");
}
}
sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics o_hide'><span>").append(translator.translate("hide.rubric.short")).append("</span></a>");
// script to show/hide the rubrics with the translated linked
sb.append("<script type=\"text/javascript\">\n").append("/* <![CDATA[ */ \n").append("jQuery(function() {\n").append(" jQuery('.o_toogle_rubrics').on('click', function() {\n").append(" jQuery('.o_assessmentsection_rubrics').each(function(index, el) {\n").append(" var current = jQuery(el).attr('class');\n").append(" if(current.indexOf('o_hide') >= 0) {\n").append(" jQuery(el).removeClass('o_hide').addClass('o_show');\n").append(" jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_open_togglebox').addClass('o_icon_close_togglebox');\n").append(" jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("hide.rubric")).append("');").append(" } else {\n").append(" jQuery(el).removeClass('o_show').addClass('o_hide');\n").append(" jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_close_togglebox').addClass('o_icon_open_togglebox');\n").append(" jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("show.rubric")).append("');").append(" }\n").append(" });").append(" });").append("});\n /* ]]> */").append("</script>").append("</div>");
}
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.
the class AssessmentTreeComponentRenderer method renderAssessmentItemMark.
private void renderAssessmentItemMark(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
String key = itemNode.getKey().toString();
Form form = component.getQtiItem().getRootForm();
String dispatchId = component.getQtiItem().getFormDispatchId();
boolean mark = component.getCandidateSessionContext().isMarked(key);
sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", Event.mark.name()), new NameValuePair("item", key))).append("; o_toggleMark(this); return false;\" class='o_assessmentitem_marks'><i class='o_icon ").append("o_icon_bookmark", "o_icon_bookmark_add", mark).append("' title='").append(StringHelper.escapeHtml(translator.translate("assessment.item.mark"))).append("'> </i></a>");
}
Aggregations