Search in sources :

Example 11 with JSCommand

use of org.olat.core.gui.control.winmgr.JSCommand in project openolat by klemens.

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 12 with JSCommand

use of org.olat.core.gui.control.winmgr.JSCommand in project openolat by klemens.

the class WeeklyCalendarController method doPrint.

private void doPrint(Date from, Date to) {
    StringBuilder sb = new StringBuilder();
    sb.append("window.open('" + printUrl + "/print.html', '_print','height=800,left=100,top=100,width=800,toolbar=no,titlebar=0,status=0,menubar=yes,location= no,scrollbars=1');");
    printMapper.setFrom(from);
    printMapper.setTo(to);
    printMapper.setCalendarWrappers(calendarWrappers);
    getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand(sb.toString()));
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 13 with JSCommand

use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.

the class ShareLinkController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    UserSession usess = ureq.getUserSession();
    if (source == shareLinkVC && "setLandingPage".equals(event.getCommand()) && usess != null && usess.isAuthenticated()) {
        HistoryPoint p = usess.getLastHistoryPoint();
        if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
            List<ContextEntry> ces = p.getEntries();
            String landingPage = BusinessControlFactory.getInstance().getAsURIString(ces, true);
            int start = landingPage.indexOf("/url/");
            if (start != -1) {
                // start with / after /url
                landingPage = landingPage.substring(start + 4);
            }
            // update user prefs
            Preferences prefs = usess.getGuiPreferences();
            prefs.put(WindowManager.class, "landing-page", landingPage);
            prefs.save();
            getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("showInfoBox(\"" + translate("info.header") + "\",\"" + translate("landingpage.set.message") + "\");"));
        }
    }
}
Also used : UserSession(org.olat.core.util.UserSession) JSCommand(org.olat.core.gui.control.winmgr.JSCommand) Preferences(org.olat.core.util.prefs.Preferences) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 14 with JSCommand

use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.

the class WeeklyCalendarController method doPrint.

private void doPrint(Date from, Date to) {
    StringBuilder sb = new StringBuilder();
    sb.append("window.open('" + printUrl + "/print.html', '_print','height=800,left=100,top=100,width=800,toolbar=no,titlebar=0,status=0,menubar=yes,location= no,scrollbars=1');");
    printMapper.setFrom(from);
    printMapper.setTo(to);
    printMapper.setCalendarWrappers(calendarWrappers);
    getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand(sb.toString()));
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 15 with JSCommand

use of org.olat.core.gui.control.winmgr.JSCommand in project OpenOLAT by OpenOLAT.

the class ValidatingVisitor method setTitle.

/**
 * @param title The new title of this window (for browser history)
 */
public void setTitle(Translator translator, String newTitle) {
    this.title = translator.translate("page.appname") + " - " + newTitle;
    StringBuilder sb = new StringBuilder();
    sb.append("document.title = \"");
    sb.append(Formatter.escapeDoubleQuotes(this.title));
    sb.append("\";");
    JSCommand jsc = new JSCommand(sb.toString());
    if (getWindowBackOffice() != null) {
        getWindowBackOffice().sendCommandTo(jsc);
    }
}
Also used : 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