Search in sources :

Example 1 with JSCommand

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);
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 2 with JSCommand

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);
    }
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand) WindowControl(org.olat.core.gui.control.WindowControl)

Example 3 with JSCommand

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);
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 4 with JSCommand

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);
    }
}
Also used : JSONObject(org.json.JSONObject) Command(org.olat.core.gui.control.winmgr.Command) JSCommand(org.olat.core.gui.control.winmgr.JSCommand) JSONException(org.json.JSONException) JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 5 with JSCommand

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));
}
Also used : AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Aggregations

JSCommand (org.olat.core.gui.control.winmgr.JSCommand)26 WindowControl (org.olat.core.gui.control.WindowControl)4 ContextEntry (org.olat.core.id.context.ContextEntry)4 HistoryPoint (org.olat.core.id.context.HistoryPoint)4 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 Command (org.olat.core.gui.control.winmgr.Command)2 ScrollTopCommand (org.olat.core.gui.control.winmgr.ScrollTopCommand)2 UserSession (org.olat.core.util.UserSession)2 Preferences (org.olat.core.util.prefs.Preferences)2 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)2