use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method addBodyCssClass.
/**
* adds a css-Classname to the OLAT body-tag
*
* @param cssClass
* the name of a css-Class
*/
@Override
public void addBodyCssClass(String cssClass) {
// sets class for full page refreshes
bodyCssClasses.add(cssClass);
// only relevant in AJAX mode
JSCommand jsc = new JSCommand("try { jQuery('#o_body').addClass('" + cssClass + "'); } catch(e){if(window.console) console.log(e) }");
getWindowControl().getWindowBackOffice().sendCommandTo(jsc);
}
use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method setBodyDataResource.
/**
* Helper method to set data-" attributes to the body element in the DOM.
* Using the data attributes it is possible to implement css styles specific
* to certain areas (sites, groups, courses) of for specific course id's.
* The data attributes are removed if null
*
* @param restype The resource type or NULL if n.a.
* @param resid The resource ID that matchtes the restype or NULL if n.a.
* @param repoentryid the repository entry ID if available or NULL if n.a.
*/
private void setBodyDataResource(String restype, String resid, String repoentryid) {
StringBuilder sb = new StringBuilder();
sb.append("try {var oobody = jQuery('body');");
// 'CourseModule' and groups 'BusinessGroup'
if (restype == null) {
sb.append("oobody.removeAttr('data-restype');");
} else {
sb.append("oobody.attr('data-restype','");
sb.append(Formatter.escapeDoubleQuotes(restype));
sb.append("');");
}
// course/repo entry id)
if (resid == null) {
sb.append("oobody.removeAttr('data-resid');");
} else {
sb.append("oobody.attr('data-resid','");
sb.append(Formatter.escapeDoubleQuotes(resid));
sb.append("');");
}
// (not for sites or groups)
if (repoentryid == null) {
sb.append("oobody.removeAttr('data-repoid');");
} else {
sb.append("oobody.attr('data-repoid','");
sb.append(Formatter.escapeDoubleQuotes(repoentryid));
sb.append("');");
}
sb.append("oobody=null;}catch(e){}");
JSCommand jsc = new JSCommand(sb.toString());
WindowControl wControl = getWindowControl();
if (wControl != null && wControl.getWindowBackOffice() != null) {
wControl.getWindowBackOffice().sendCommandTo(jsc);
}
}
use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method removeBodyCssClass.
/**
* removes the given css-Classname from the OLAT body-tag
*
* @param cssClass
* the name of a css-Class
*/
@Override
public void removeBodyCssClass(String cssClass) {
// sets class for full page refreshes
bodyCssClasses.remove(cssClass);
// only relevant in AJAX mode
JSCommand jsc = new JSCommand("try { jQuery('#o_body').removeClass('" + cssClass + "'); } catch(e){if(window.console) console.log(e) }");
getWindowControl().getWindowBackOffice().sendCommandTo(jsc);
}
use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.
the class FIBEditorController method feedbackToTextElement.
private void feedbackToTextElement(String responseIdentifier, String solution) {
try {
JSONObject jo = new JSONObject();
jo.put("responseIdentifier", responseIdentifier);
jo.put("data-qti-solution", solution);
Command jsc = new JSCommand("try { tinymce.activeEditor.execCommand('qtiUpdateTextEntry', false, " + jo.toString() + "); } catch(e){if(window.console) console.log(e) }");
getWindowControl().getWindowBackOffice().sendCommandTo(jsc);
} catch (JSONException e) {
logError("", e);
}
}
use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityInteractionsController method doSetOverridenScore.
private void doSetOverridenScore(BigDecimal newScore) {
overrideAutoScore = newScore;
if (newScore == null) {
AssessmentItemSession itemSession = correction.getItemSession();
String score = itemSession == null ? "" : AssessmentHelper.getRoundedScore(itemSession.getScore());
overrideScoreCont.contextPut("score", score);
} else {
overrideScoreCont.contextPut("score", AssessmentHelper.getRoundedScore(newScore));
}
String dirtyOnLoad = FormJSHelper.setFlexiFormDirtyOnLoad(flc.getRootForm());
getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand(dirtyOnLoad));
}
Aggregations