Search in sources :

Example 16 with JSCommand

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

the class ValidatingVisitor method handleBusinessPath.

public Command handleBusinessPath(UserRequest ureq) {
    HistoryPoint p = ureq.getUserSession().getLastHistoryPoint();
    if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
        StringBuilder sb = new StringBuilder();
        List<ContextEntry> ces = p.getEntries();
        String url = BusinessControlFactory.getInstance().getAsURIString(ces, true);
        sb.append("try { o_info.businessPath='").append(url).append("';");
        // Add analytics code
        if (analyticsSPI != null) {
            String serverUri = Settings.getServerContextPathURI();
            if (url != null && url.startsWith(serverUri)) {
                analyticsSPI.analyticsCountPageJavaScript(sb, getTitle(), url.substring(serverUri.length()));
            }
        }
        sb.append(" } catch(e) { }");
        return new JSCommand(sb.toString());
    }
    return null;
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 17 with JSCommand

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

the class EditorMainController method doInsert.

private void doInsert(UserRequest ureq, CourseNode newNode) {
    menuTree.setSelectedNodeId(newNode.getIdent());
    // update the current node in the editor course environment
    euce.getCourseEditorEnv().setCurrentCourseNodeId(newNode.getIdent());
    euce.getCourseEditorEnv().validateCourse();
    StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
    updateCourseStatusMessages(getLocale(), courseStatus);
    initNodeEditor(ureq, newNode);
    // do logging
    ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_NODE_CREATED, getClass(), LoggingResourceable.wrap(newNode));
    // Resize layout columns to make all nodes viewable in the menu column
    JSCommand resizeCommand = new JSCommand("try { OPOL.adjustHeight(); } catch(e) {if(window.console) console.log(e); }");
    getWindowControl().getWindowBackOffice().sendCommandTo(resizeCommand);
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 18 with JSCommand

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

the class RunMainController method updateCourseDataAttributes.

private void updateCourseDataAttributes(CourseNode calledCourseNode) {
    StringBuilder sb = new StringBuilder();
    sb.append("try {var oocourse = jQuery('.o_course_run');");
    if (calledCourseNode == null) {
        sb.append("oocourse.removeAttr('data-nodeid');");
    } else {
        sb.append("oocourse.attr('data-nodeid','");
        sb.append(Formatter.escapeDoubleQuotes(calledCourseNode.getIdent()));
        sb.append("');");
    }
    sb.append("oocourse=null;}catch(e){}");
    JSCommand jsc = new JSCommand(sb.toString());
    WindowControl wControl = getWindowControl();
    if (wControl != null && wControl.getWindowBackOffice() != null) {
        wControl.getWindowBackOffice().sendCommandTo(jsc);
    }
    // course title already set by BaseFullWebappController on tab activate
    if (calledCourseNode != null) {
        String newTitle = courseTitle + " - " + calledCourseNode.getShortTitle();
        getWindowControl().getWindowBackOffice().getWindow().setTitle(getTranslator(), newTitle);
    }
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand) WindowControl(org.olat.core.gui.control.WindowControl)

Example 19 with JSCommand

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

the class CPDisplayController method printPages.

private void printPages(final List<String> selectedNodeIds) {
    StringBuilder sb = new StringBuilder();
    sb.append("window.open('" + mapperBaseURL + "/print.html', '_print','height=800,left=100,top=100,width=800,toolbar=no,titlebar=0,status=0,menubar=yes,location= no,scrollbars=1');");
    printMapper.setSelectedNodeIds(selectedNodeIds);
    getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand(sb.toString()));
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand)

Example 20 with JSCommand

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

the class StepsMainRunController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, org.olat.core.gui.components.form.flexible.impl.FormEvent event) {
    int whichTitleClickedIndex = stepTitleLinks.indexOf(source);
    if (source == cancelButton || source == closeLink) {
        if (cancel != null) {
            // execute some cancel / rollback code
            // a wizard is expected not to touch / change data in the cancel
            // case undo your work here.
            Step returnStep = cancel.execute(ureq, getWindowControl(), stepsContext);
            if (returnStep != Step.NOSTEP) {
            // error case FIXME:pb finish wizard for this case
            } else {
            // fireEvent(ureq, Event.CANCELLED_EVENT);
            }
        }
        fireEvent(ureq, Event.CANCELLED_EVENT);
    } else if (source == nextButton) {
        // submit and let current unsaved step do its work
        flc.getRootForm().submitAndNext(ureq);
        // getWindowControl().getWindowBackOffice()
        // .sendCommandTo(new JSCommand("try { o_scrollToElement('.o_wizard.modal.show.in'); } catch(e){ }"));
        getWindowControl().getWindowBackOffice().sendCommandTo(new ScrollTopCommand());
    // the current step decides whether to proceed to the next step or
    // not.
    } else if (source == finishButton) {
        // submit and let last unsaved step do its work
        finishCycle = true;
        flc.getRootForm().submitAndFinish(ureq);
        getWindowControl().getWindowBackOffice().sendCommandTo(new ScrollTopCommand());
    // the current step decides whether to proceed or not
    // an end step will fire FINISH
    // a intermediate step will fire NEXT .. but NEXT && FINISHCYCLE
    // means also finish
    } else if (source == prevButton) {
        lastEvent = StepsEvent.ACTIVATE_PREVIOUS;
        doAfterDispatch = true;
        getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("try { o_scrollToElement('.o_wizard.modal.show.in'); } catch(e){ }"));
    } else if (whichTitleClickedIndex >= 0) {
        // remove all steps until the clicked one
        for (int from = currentStepIndex; from > whichTitleClickedIndex; from--) {
            stepPages.pop();
            steps.pop();
            currentStepIndex--;
            // disable
            stepTitleLinks.get(currentStepIndex).setEnabled(false);
            // "previous"
            // step.
            StepFormController controller = stepPagesController.pop();
            controller.back();
            removeAsListenerAndDispose(controller);
            // update current step index to velocity
            flc.contextPut("currentStepPos", currentStepIndex + 1);
        }
        flc.add("FFO_CURRENTSTEPPAGE", stepPages.peek());
        PrevNextFinishConfig pnfConf = steps.peek().getInitialPrevNextFinishConfig();
        prevButton.setEnabled(pnfConf.isBackIsEnabled());
        nextButton.setEnabled(pnfConf.isNextIsEnabled());
        finishButton.setEnabled(pnfConf.isFinishIsEnabled());
    }
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand) ScrollTopCommand(org.olat.core.gui.control.winmgr.ScrollTopCommand)

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