From 7c7fcc1ff654e3fe79b41e5514c167b02f266e46 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 23 May 2016 16:53:26 +0200 Subject: [PATCH] OO-2013: allow the play/stop javascript's events to flow to the backend --- .../java/org/olat/core/gui/components/Window.java | 11 +++++++++++ .../java/org/olat/core/gui/render/URLBuilder.java | 3 +++ .../gui/render/velocity/VelocityRenderDecorator.java | 6 ++++++ .../olat/modules/video/ui/_content/video_run.html | 12 +++++------- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/olat/core/gui/components/Window.java b/src/main/java/org/olat/core/gui/components/Window.java index efe4ec614ce..9e1d5ca2d54 100644 --- a/src/main/java/org/olat/core/gui/components/Window.java +++ b/src/main/java/org/olat/core/gui/components/Window.java @@ -139,6 +139,12 @@ public class Window extends AbstractComponent { */ public static final Event ABOUT_TO_DISPATCH = new Event("about_to_dispatch"); + /** The parameter name for the case where the event doesn't need to trigger a response */ + public static final String NO_RESPONSE_PARAMETER_MARKER = "no-response"; + + /** The parameter value for the case where the event doesn't need to trigger a response */ + public static final String NO_RESPONSE_VALUE_MARKER = "oo-no-response"; + private String uriPrefix; private ComponentCollection contentPane; private String latestTimestamp; @@ -335,6 +341,11 @@ public class Window extends AbstractComponent { // this can happen e.g. on quick double-clicks, so that the dom-replacement-command never reaches the client. if (isDebugLog) log.debug("no ajax dispatch: component not found (target=null)"); validForDispatching = false; + //check no response call + String noResponseMarker = ureq.getParameter("no-response"); + if("oo-no-response".equals(noResponseMarker)) { + return; + } } // 2.) collect dirty components (top-down, return from sub-path when first dirty node met) diff --git a/src/main/java/org/olat/core/gui/render/URLBuilder.java b/src/main/java/org/olat/core/gui/render/URLBuilder.java index 13ae1d1b129..0a5da9a4ca0 100644 --- a/src/main/java/org/olat/core/gui/render/URLBuilder.java +++ b/src/main/java/org/olat/core/gui/render/URLBuilder.java @@ -32,6 +32,7 @@ import java.util.regex.Pattern; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; +import org.olat.core.gui.components.Window; import org.olat.core.gui.components.form.flexible.impl.NameValuePair; import org.olat.core.gui.control.winmgr.AJAXFlags; import org.olat.core.logging.AssertException; @@ -197,6 +198,8 @@ public class URLBuilder { } sb.append("'"); commandParameters(sb, commands); + //no response marker + commandParameters(sb, new NameValuePair(Window.NO_RESPONSE_PARAMETER_MARKER, Window.NO_RESPONSE_VALUE_MARKER)); return sb; } diff --git a/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java b/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java index 6a87b4231c1..19e4c01d8a2 100644 --- a/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java +++ b/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java @@ -193,6 +193,12 @@ public class VelocityRenderDecorator implements Closeable { return ""; } + public String openNoResponseJavaScriptCommand(String command) { + renderer.getUrlBuilder().openXHRNoResponseEvent(target, null, + new NameValuePair(VelocityContainer.COMMAND_ID, command)); + return ""; + } + /** * * @param command diff --git a/src/main/java/org/olat/modules/video/ui/_content/video_run.html b/src/main/java/org/olat/modules/video/ui/_content/video_run.html index 5ebd1058078..f90cc3638ab 100644 --- a/src/main/java/org/olat/modules/video/ui/_content/video_run.html +++ b/src/main/java/org/olat/modules/video/ui/_content/video_run.html @@ -38,34 +38,32 @@ ## Callback to communicate with the server success: function (mediaElement, domObject) { -#* -## does not work for now with autoplay ## listen to play events, fired when movie is finished mediaElement.addEventListener('play', function(e) { if (!o_info.linkbusy) { - $r.openJavaScriptCommand("play"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); + $r.openNoResponseJavaScriptCommand("play"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); } }, false); ## listen to pause events, fired when movie is paused by user mediaElement.addEventListener('pause', function(e) { if (!o_info.linkbusy) { - $r.openJavaScriptCommand("pause"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); + $r.openNoResponseJavaScriptCommand("pause"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); } }, false); ## listen to seeked events, fired when user uses the slider in the movie mediaElement.addEventListener('seeked', function(e) { if (!o_info.linkbusy) { - $r.openJavaScriptCommand("seeked"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); + $r.openNoResponseJavaScriptCommand("seeked"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); } }, false); ## listen to end events, fired when movie is finished mediaElement.addEventListener('ended', function(e) { if (!o_info.linkbusy) { - $r.openJavaScriptCommand("ended"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); + $r.openNoResponseJavaScriptCommand("ended"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src); } }, false); -*# + ## ## Preselect the preferred source #if($useSourceChooser) -- GitLab