From 157c85c20ae5a53f315dee4ca937c75fafc74822 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 10 Jun 2020 13:40:15 +0100 Subject: [PATCH] MDL-68436 atto_recordrtc: only works once per page --- .../moodle-atto_recordrtc-button-debug.js | 9 +++++++-- .../moodle-atto_recordrtc-button-min.js | 2 +- .../moodle-atto_recordrtc-button.js | 9 +++++++-- .../atto/plugins/recordrtc/yui/src/button/js/button.js | 9 +++++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-debug.js b/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-debug.js index 3f62f9d4e64..e6fd0f403b2 100644 --- a/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-debug.js +++ b/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-debug.js @@ -118,12 +118,12 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto focusAfterHide: null }); - // If dialogue is closed during recording, do the following. dialogue.after('visibleChange', function() { var closed = !dialogue.get('visible'), m = M.atto_recordrtc.commonmodule; if (closed) { + // If dialogue is closed during recording, do the following. window.clearInterval(m.countdownTicker); if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') { @@ -137,9 +137,14 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto } }); } + + // Because the player uses ids to identify things (this should be fixed) + // we must make sure the dialogue contents only exist once in the DOM. + // Therefore, when a dialogue is closed, we must remove its contents. + this.getDialogue().set('bodyContent', ''); } - }); + }, this); dialogue.on('click', function() { this.centered(); diff --git a/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-min.js b/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-min.js index 1e16ae05b2a..013087c2f2b 100644 --- a/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-min.js +++ b/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button-min.js @@ -1 +1 @@ -YUI.add("moodle-atto_recordrtc-button",function(s,t){var n="atto_recordrtc";s.namespace("M.atto_recordrtc").Button=s.Base.create("button",s.M.editor_atto.EditorPlugin,[],{_lang:"en",initializer:function(){var t,e,i;if(this.get("host").canShowFilepicker("media")){if(e=!1,"both"!==(t=this.get("allowedtypes"))&&"audio"!==t||(this._addButton("audio",this._audio),e=!0),"both"!==t&&"video"!==t||(this._addButton("video",this._video),e=!0),!e)return;(i=this.getDialogue({width:1e3,focusAfterHide:null})).after("visibleChange",function(){var t=!i.get("visible"),e=M.atto_recordrtc.commonmodule;t&&(window.clearInterval(e.countdownTicker),e.mediaRecorder&&"inactive"!==e.mediaRecorder.state&&e.mediaRecorder.stop(),e.stream&&e.stream.getTracks().forEach(function(t){"ended"!==t.readyState&&t.stop()}))}),i.on("click",function(){this.centered()}),window.require(["core/adapter"],function(t){window.adapter=t})}},_addButton:function(t,e){this.addButton({buttonName:t,icon:this.get(t+"rtcicon"),iconComponent:n,callback:e,title:t+"rtc",tags:t+"rtc",tagMatchRequiresAll:!1})},_audio:function(){var t=this.getDialogue();t.set("headerContent",M.util.get_string("audiortc","atto_recordrtc")),t.set("bodyContent",this._createContent("audio")),t.show(),M.atto_recordrtc.audiomodule.init(this)},_video:function(){var t=this.getDialogue();t.set("headerContent",M.util.get_string("videortc","atto_recordrtc")),t.set("bodyContent",this._createContent("video")),t.show(),M.atto_recordrtc.videomodule.init(this)},_createContent:function(t){var e="audio"===t,i="row",o="col-",r="alert-danger",a="btn btn-lg btn-outline-danger btn-block",d=s.Handlebars.compile('
{{insecurealert_title}} {{insecurealert}}
{{#if isAudio}}
{{else}}
{{/if}}
')({PLUGINNAME:n,isAudio:e,bs_row:i,bs_col:o,bs_al_dang:r,bs_ss_btn:a,insecurealert_title:M.util.get_string("insecurealert_title","atto_recordrtc"),insecurealert:M.util.get_string("insecurealert","atto_recordrtc"),startrecording:M.util.get_string("startrecording","atto_recordrtc"),attachrecording:M.util.get_string("attachrecording","atto_recordrtc")});return d},closeDialogue:function(t){t.getDialogue().hide(),t.editor.focus()},setLink:function(t,e){t.getDialogue().hide(),t.editor.focus(),t.get("host").insertContentAtFocusPoint(e),t.markUpdated()}},{ATTRS:{contextid:{value:null},sesskey:{value:null},allowedtypes:{value:null},audiobitrate:{value:null},videobitrate:{value:null},timelimit:{value:null},audiortcicon:{value:null},videortcicon:{value:null},maxrecsize:{value:null}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","moodle-atto_recordrtc-recording"]}); \ No newline at end of file +YUI.add("moodle-atto_recordrtc-button",function(s,t){var n="atto_recordrtc";s.namespace("M.atto_recordrtc").Button=s.Base.create("button",s.M.editor_atto.EditorPlugin,[],{_lang:"en",initializer:function(){var t,e,i;if(this.get("host").canShowFilepicker("media")){if(e=!1,"both"!==(t=this.get("allowedtypes"))&&"audio"!==t||(this._addButton("audio",this._audio),e=!0),"both"!==t&&"video"!==t||(this._addButton("video",this._video),e=!0),!e)return;(i=this.getDialogue({width:1e3,focusAfterHide:null})).after("visibleChange",function(){var t=!i.get("visible"),e=M.atto_recordrtc.commonmodule;t&&(window.clearInterval(e.countdownTicker),e.mediaRecorder&&"inactive"!==e.mediaRecorder.state&&e.mediaRecorder.stop(),e.stream&&e.stream.getTracks().forEach(function(t){"ended"!==t.readyState&&t.stop()}),this.getDialogue().set("bodyContent",""))},this),i.on("click",function(){this.centered()}),window.require(["core/adapter"],function(t){window.adapter=t})}},_addButton:function(t,e){this.addButton({buttonName:t,icon:this.get(t+"rtcicon"),iconComponent:n,callback:e,title:t+"rtc",tags:t+"rtc",tagMatchRequiresAll:!1})},_audio:function(){var t=this.getDialogue();t.set("headerContent",M.util.get_string("audiortc","atto_recordrtc")),t.set("bodyContent",this._createContent("audio")),t.show(),M.atto_recordrtc.audiomodule.init(this)},_video:function(){var t=this.getDialogue();t.set("headerContent",M.util.get_string("videortc","atto_recordrtc")),t.set("bodyContent",this._createContent("video")),t.show(),M.atto_recordrtc.videomodule.init(this)},_createContent:function(t){var e="audio"===t,i="row",o="col-",r="alert-danger",a="btn btn-lg btn-outline-danger btn-block",d=s.Handlebars.compile('
{{insecurealert_title}} {{insecurealert}}
{{#if isAudio}}
{{else}}
{{/if}}
')({PLUGINNAME:n,isAudio:e,bs_row:i,bs_col:o,bs_al_dang:r,bs_ss_btn:a,insecurealert_title:M.util.get_string("insecurealert_title","atto_recordrtc"),insecurealert:M.util.get_string("insecurealert","atto_recordrtc"),startrecording:M.util.get_string("startrecording","atto_recordrtc"),attachrecording:M.util.get_string("attachrecording","atto_recordrtc")});return d},closeDialogue:function(t){t.getDialogue().hide(),t.editor.focus()},setLink:function(t,e){t.getDialogue().hide(),t.editor.focus(),t.get("host").insertContentAtFocusPoint(e),t.markUpdated()}},{ATTRS:{contextid:{value:null},sesskey:{value:null},allowedtypes:{value:null},audiobitrate:{value:null},videobitrate:{value:null},timelimit:{value:null},audiortcicon:{value:null},videortcicon:{value:null},maxrecsize:{value:null}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","moodle-atto_recordrtc-recording"]}); \ No newline at end of file diff --git a/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button.js b/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button.js index 3f62f9d4e64..e6fd0f403b2 100644 --- a/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button.js +++ b/lib/editor/atto/plugins/recordrtc/yui/build/moodle-atto_recordrtc-button/moodle-atto_recordrtc-button.js @@ -118,12 +118,12 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto focusAfterHide: null }); - // If dialogue is closed during recording, do the following. dialogue.after('visibleChange', function() { var closed = !dialogue.get('visible'), m = M.atto_recordrtc.commonmodule; if (closed) { + // If dialogue is closed during recording, do the following. window.clearInterval(m.countdownTicker); if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') { @@ -137,9 +137,14 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto } }); } + + // Because the player uses ids to identify things (this should be fixed) + // we must make sure the dialogue contents only exist once in the DOM. + // Therefore, when a dialogue is closed, we must remove its contents. + this.getDialogue().set('bodyContent', ''); } - }); + }, this); dialogue.on('click', function() { this.centered(); diff --git a/lib/editor/atto/plugins/recordrtc/yui/src/button/js/button.js b/lib/editor/atto/plugins/recordrtc/yui/src/button/js/button.js index 3ffa677a2be..bba8d70e050 100644 --- a/lib/editor/atto/plugins/recordrtc/yui/src/button/js/button.js +++ b/lib/editor/atto/plugins/recordrtc/yui/src/button/js/button.js @@ -116,12 +116,12 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto focusAfterHide: null }); - // If dialogue is closed during recording, do the following. dialogue.after('visibleChange', function() { var closed = !dialogue.get('visible'), m = M.atto_recordrtc.commonmodule; if (closed) { + // If dialogue is closed during recording, do the following. window.clearInterval(m.countdownTicker); if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') { @@ -135,9 +135,14 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto } }); } + + // Because the player uses ids to identify things (this should be fixed) + // we must make sure the dialogue contents only exist once in the DOM. + // Therefore, when a dialogue is closed, we must remove its contents. + this.getDialogue().set('bodyContent', ''); } - }); + }, this); dialogue.on('click', function() { this.centered();