| 1 |  |  | // This file is part of Moodle - http://moodle.org/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | // Moodle is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | // it under the terms of the GNU General Public License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | // the Free Software Foundation, either version 3 of the License, or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | // (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | // Moodle is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | // GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | // You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | // along with Moodle.  If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * Atto recordrtc library functions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @package    atto_recordrtc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @author     Jesus Federico (jesus [at] blindsidenetworks [dt] com) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @author     Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @copyright  2017 Blindside Networks Inc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @module moodle-atto_recordrtc-button | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * Atto text editor recordrtc plugin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @namespace M.atto_recordrtc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * @class button | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @extends M.editor_atto.EditorPlugin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | // JSHint directives. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | /*jshint onevar: false */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | /*jshint unused: false */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | /*global M */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | // Scrutinizer CI directives. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | /** global: Y */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | /** global: M */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | var PLUGINNAME = 'atto_recordrtc', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     TEMPLATE = '' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     '<div class="{{PLUGINNAME}} container-fluid">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |       '<div class="{{bs_row}} hide">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         '<div class="{{bs_col}}12">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |           '<div id="alert-warning" class="alert {{bs_al_warn}}">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             '<strong>{{browseralert_title}}</strong> {{browseralert}}' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |           '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |       '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |       '<div class="{{bs_row}} hide">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         '<div class="{{bs_col}}12">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |           '<div id="alert-danger" class="alert {{bs_al_dang}}">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             '<strong>{{insecurealert_title}}</strong> {{insecurealert}}' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |           '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |       '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |       '<div class="{{bs_row}} hide">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         '{{#if audio}}' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |           '<div class="{{bs_col}}1"></div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |           '<div class="{{bs_col}}10">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             '<audio id="player"></audio>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |           '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |           '<div class="{{bs_col}}1"></div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         '{{else}}' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |           '<div class="{{bs_col}}12">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             '<video id="player"></video>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |           '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         '{{/if}}' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |       '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |       '<div class="{{bs_row}}">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         '<div class="{{bs_col}}1"></div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         '<div class="{{bs_col}}10">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |           '<button id="start-stop" class="{{bs_ss_btn}}">{{startrecording}}</button>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         '<div class="{{bs_col}}1"></div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |       '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |       '<div class="{{bs_row}} hide">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         '<div class="{{bs_col}}3"></div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         '<div class="{{bs_col}}6">' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |           '<button id="upload" class="btn btn-primary btn-block">{{attachrecording}}</button>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         '<div class="{{bs_col}}3"></div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |       '</div>' + | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * The current language by default. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     _lang: 'en', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     initializer: function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         if (this.get('host').canShowFilepicker('media')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             // Add audio and/or video buttons depending on the settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             var allowedtypes = this.get('allowedtypes'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             if (allowedtypes === 'both' || allowedtypes === 'audio') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 this._addButton('audio', this._audio); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             if (allowedtypes === 'both' || allowedtypes === 'video') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                 this._addButton('video', this._video); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             // Initialize the dialogue box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             var dialogue = this.getDialogue({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                 width: 1000, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                 focusAfterHide: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             // If dialogue is closed during recording, do the following. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             var editor = this; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             dialogue.after('visibleChange', function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 var closed = !dialogue.get('visible'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                     m = M.atto_recordrtc.commonmodule; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                 if (closed) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                     window.clearInterval(m.countdownTicker); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                     if (m.mediaRecorder && m.mediaRecorder.state !== 'inactive') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                         m.mediaRecorder.stop(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 130 |  |  |                     if (m.stream) { | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |                         m.stream.getTracks().forEach(function(track) { | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |                             if (track.readyState !== 'ended') { | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |                                 track.stop(); | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |                             } | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |                         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             // Require Bowser and adapter.js libraries. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             require(['atto_recordrtc/adapter'], function(adapter) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 window.adapter = adapter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             require(['atto_recordrtc/bowser'], function(bowser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                 window.bowser = bowser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * Add the buttons to the Atto toolbar. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |      * @method _addButton | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * @param {string} type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      * @param {callback} callback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |      * @private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     _addButton: function(type, callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         this.addButton({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             buttonName: type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             icon: this.get(type + 'rtcicon'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             iconComponent: PLUGINNAME, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             callback: callback, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             title: type + 'rtc', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             tags: type + 'rtc', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             tagMatchRequiresAll: false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * Toggle audiortc and normal display mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * @method _audio | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * @private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     _audio: function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         var dialogue = this.getDialogue(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         dialogue.set('height', 400); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         dialogue.set('headerContent', M.util.get_string('audiortc', 'atto_recordrtc')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         dialogue.set('bodyContent', this._createContent('audio')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         dialogue.show(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         M.atto_recordrtc.audiomodule.init(this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * Toggle videortc and normal display mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @method _video | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     _video: function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         var dialogue = this.getDialogue(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         dialogue.set('height', 850); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         dialogue.set('headerContent', M.util.get_string('videortc', 'atto_recordrtc')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         dialogue.set('bodyContent', this._createContent('video')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         dialogue.show(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         M.atto_recordrtc.videomodule.init(this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      * Create the HTML to be displayed in the dialogue box | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @method _createContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * @param {string} type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * @returns {Object} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     _createContent: function(type) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         var audio = (type === 'audio'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             bsRow = this.get('oldermoodle') ? 'row-fluid' : 'row', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |             bsCol = this.get('oldermoodle') ? 'span' : 'col-xs-', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             bsAlWarn = this.get('oldermoodle') ? '' : 'alert-warning', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |             bsAlDang = this.get('oldermoodle') ? 'alert-error' : 'alert-danger', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |             bsSsBtn = this.get('oldermoodle') ? 'btn btn-large btn-danger btn-block' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                                               : 'btn btn-lg btn-outline-danger btn-block'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         var bodyContent = Y.Handlebars.compile(TEMPLATE)({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             PLUGINNAME: PLUGINNAME, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             audio: audio, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             bs_row: bsRow, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             bs_col: bsCol, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             bs_al_warn: bsAlWarn, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             bs_al_dang: bsAlDang, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             bs_ss_btn: bsSsBtn, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             bs_ul_btn: 'btn btn-primary btn-block', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             browseralert_title: M.util.get_string('browseralert_title', 'atto_recordrtc'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             browseralert: M.util.get_string('browseralert', 'atto_recordrtc'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             insecurealert_title: M.util.get_string('insecurealert_title', 'atto_recordrtc'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             insecurealert: M.util.get_string('insecurealert', 'atto_recordrtc'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             startrecording: M.util.get_string('startrecording', 'atto_recordrtc'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             attachrecording: M.util.get_string('attachrecording', 'atto_recordrtc') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         return bodyContent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |      * Close the dialogue without further action. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |      * @method closeDialogue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      * @param {Object} scope The "this" context of the editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     closeDialogue: function(scope) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         scope.getDialogue().hide(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         scope.editor.focus(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |      * Insert the annotation link in the editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |      * @method setLink | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |      * @param {Object} scope The "this" context of the editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |      * @param {string} annotation The HTML link to the recording. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |     setLink: function(scope, annotation) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         scope.getDialogue().hide(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         scope.editor.focus(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |         scope.get('host').insertContentAtFocusPoint(annotation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |         scope.markUpdated(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | }, { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     ATTRS: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |          * The contextid to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |          * @attribute contextid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |         contextid: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |          * The sesskey to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |          * @attribute sesskey | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         sesskey: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |          * The root to use when loading the recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |          * @attribute recordrtcroot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         recordrtcroot: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |          * The allowedtypes to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |          * @attribute allowedtypes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         allowedtypes: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |          * The audiobitrate to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |          * @attribute audiobitrate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         audiobitrate: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |          * The videobitrate to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |          * @attribute videobitrate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         videobitrate: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |          * The timelimit to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |          * @attribute timelimit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |         timelimit: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |          * The audiortcicon to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |          * @attribute audiortcicon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         audiortcicon: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |          * The videortcicon to use when generating this recordrtc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |          * @attribute videortcicon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         videortcicon: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |          * True if Moodle is version < 3.2. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |          * @attribute oldermoodle | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |          * @type Boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         oldermoodle: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |          * Maximum upload size set on server, in MB. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |          * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |          * @attribute maxrecsize | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |          * @type String | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         maxrecsize: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |             value: null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 381 |  |  | }); | 
            
                                                        
            
                                    
            
            
                | 382 |  |  |  |