Gitlab CSE Unil

Commit 76a58774 authored by M. Chardon's avatar M. Chardon
Browse files

améliration shurtcuts/click sur bande audio et ajout "N" pour ajouter une nouvelle annotation

parent 4b98b107
define(["jquery","mod_audioannotation/justWave","mod_audioannotation/editor","mod_audioannotation/rightMenu"],function(a,b,c,d){function e(a){e.currentUser="userid"in a?a.userid:null,e.courseid="course"in a?a.course:null,e.audioannotation="audioannotation"in a?a.audioannotation:null,e.eval="eval"in a?a.eval:0,e.iswriting="iswriting"in a?a.iswriting:0,e.pairing="pairing"in a?a.pairing:0;var f="repo"in a?a.repo:null,g="assignparts"in a?a.assignparts:null,h=null;if(g)try{h=JSON.parse(g)}catch(i){window.console.error(i)}var j="tags"in a?a.tags:null,k=null;if(j)try{k=JSON.parse(j)}catch(i){window.console.error(i)}if(e.wavePlayer=new b(this),e.editors=[],h)for(var l=0;l<h.length;l++){e.editors[h[l].id]=new c({controler:this,courseid:e.courseid,assignpart:h[l],audioannotation:e.audioannotation,tags:k,repo:f});var m=new b(this,e.editors[h[l].id]);e.editors[h[l].id].setWavePlayer(m),this.initWave(m,"justwave",h[l].id)}this.initTrigger(),e.rightMenu=new d({controler:this}),this.initDisplay()}return e.courseid=-1,e.audioannotation=-1,e.wavePlayer=null,e.prototype.editors=null,e.rightMenu=null,e.lastP=null,e.eval=0,e.iswriting=0,e.pairing=0,e.currentUser=null,e.prototype.initTrigger=function(){1!=e.eval&&1!=e.iswriting||a(".btn_add_annotation").on("click",function(){e.editors[a(this).data("assignpart")].notify("add")}),a(".select_tqs").on("change",function(){var b=a(this).data("assignpart");e.editors[b].notify("displaytqs",{tag:a("#select_tag"+b).val(),question:a("#select_question"+b).val(),statut:a("#select_statut"+b).val(),author:a("#select_author"+b).val()})}),a("li[data-annotation]").on("click",function(){var b=a(this).data("annotation"),c=a(this).parents(".annotationGroupAccordion").data("assignpart");b&&e.editors[c].notify("view",{annotation:b})}),a("#id_grade").on("change",function(){a(this).val()?a("input[name=gradeempty]").val(0):a("input[name=gradeempty]").val(1)}),a("div[data-parent='#accordionAssignPart']").on("show.bs.collapse",function(){var b=a("div[data-target='#"+a(this).attr("id")+"']"),c=b.find("i.fa-caret-right");c.removeClass("fa-caret-right"),c.addClass("fa-caret-down")}),a("div[data-parent='#accordionAssignPart']").on("hide.bs.collapse",function(){var b=a("div[data-target='#"+a(this).attr("id")+"']"),c=b.find("i.fa-caret-down");c.removeClass("fa-caret-down"),c.addClass("fa-caret-right")})},e.prototype.initWave=function(b,c,d){b.init(c),b.drawWaveDisplay(a(".justwave"+d+" audio"))},e.prototype.initAnnotations=function(){for(var a=0;a<e.editors.length;a++)e.editors[a]&&e.editors[a].initAnnotationsDisplay()},e.prototype.initDisplay=function(){function b(){var b=a('input[name="remediation"]:checked').val();1==b?a('input[name="notification"]').parents("div.fitem").show():a('input[name="notification"]').parents("div.fitem").hide()}b(),a('input[name="remediation"]').on("change",function(){b()})},e.prototype.notify=function(a,b,c){switch(a){case"loadedmetadata":this.initAnnotations();break;case"addannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("add");break;case"editannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("edit");break;case"viewannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("view");break;case"deleteannotation":if("rightMenu"===b)for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].notify("delete",c);else for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("delete")}},e.prototype.getEval=function(){return e.eval},e.prototype.isWriting=function(){return e.iswriting},e.prototype.getPairing=function(){return e.pairing},e.prototype.getCurrentUser=function(){return e.currentUser},e});
\ No newline at end of file
define(["jquery","mod_audioannotation/justWave","mod_audioannotation/editor","mod_audioannotation/rightMenu"],function(a,b,c,d){function e(a){e.currentUser="userid"in a?a.userid:null,e.courseid="course"in a?a.course:null,e.audioannotation="audioannotation"in a?a.audioannotation:null,e.eval="eval"in a?a.eval:0,e.iswriting="iswriting"in a?a.iswriting:0,e.pairing="pairing"in a?a.pairing:0;var f="repo"in a?a.repo:null,g="assignparts"in a?a.assignparts:null,h=null;if(g)try{h=JSON.parse(g)}catch(i){window.console.error(i)}var j="tags"in a?a.tags:null,k=null;if(j)try{k=JSON.parse(j)}catch(i){window.console.error(i)}if(e.wavePlayer=new b(this),e.editors=[],h)for(var l=0;l<h.length;l++){e.editors[h[l].id]=new c({controler:this,courseid:e.courseid,assignpart:h[l],audioannotation:e.audioannotation,tags:k,repo:f});var m=new b(this,e.editors[h[l].id]);e.editors[h[l].id].setWavePlayer(m),this.initWave(m,"justwave",h[l].id)}this.initTrigger(),e.rightMenu=new d({controler:this}),this.initDisplay()}return e.courseid=-1,e.audioannotation=-1,e.wavePlayer=null,e.prototype.editors=null,e.rightMenu=null,e.lastP=null,e.eval=0,e.iswriting=0,e.pairing=0,e.currentUser=null,e.prototype.initTrigger=function(){1!=e.eval&&1!=e.iswriting||(a(".btn_add_annotation").on("click",function(){e.editors[a(this).data("assignpart")].notify("add")}),a(".btn_add_annotation").on("mouseout",function(){a(this).blur(),a(this).parents('div[data-parent="#accordionAssignPart"]').focus()})),a(".select_tqs").on("change",function(){var b=a(this).data("assignpart");e.editors[b].notify("displaytqs",{tag:a("#select_tag"+b).val(),question:a("#select_question"+b).val(),statut:a("#select_statut"+b).val(),author:a("#select_author"+b).val()})}),a("li[data-annotation]").on("click",function(){var b=a(this).data("annotation"),c=a(this).parents(".annotationGroupAccordion").data("assignpart");b&&e.editors[c].notify("view",{annotation:b})}),a("#id_grade").on("change",function(){a(this).val()?a("input[name=gradeempty]").val(0):a("input[name=gradeempty]").val(1)}),a("div[data-parent='#accordionAssignPart']").on("show.bs.collapse",function(){var b=a("div[data-target='#"+a(this).attr("id")+"']"),c=b.find("i.fa-caret-right");c.removeClass("fa-caret-right"),c.addClass("fa-caret-down")}),a("div[data-parent='#accordionAssignPart']").on("hide.bs.collapse",function(){var b=a("div[data-target='#"+a(this).attr("id")+"']"),c=b.find("i.fa-caret-down");c.removeClass("fa-caret-down"),c.addClass("fa-caret-right")})},e.prototype.initWave=function(b,c,d){b.init(c),b.drawWaveDisplay(a(".justwave"+d+" audio"))},e.prototype.initAnnotations=function(){for(var a=0;a<e.editors.length;a++)e.editors[a]&&e.editors[a].initAnnotationsDisplay()},e.prototype.initDisplay=function(){function b(){var b=a('input[name="remediation"]:checked').val();1==b?a('input[name="notification"]').parents("div.fitem").show():a('input[name="notification"]').parents("div.fitem").hide()}b(),a('input[name="remediation"]').on("change",function(){b()})},e.prototype.notify=function(a,b,c){switch(a){case"loadedmetadata":this.initAnnotations();break;case"addannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("add");break;case"editannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("edit");break;case"viewannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("view");break;case"deleteannotation":if("rightMenu"===b)for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].notify("delete",c);else for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("delete")}},e.prototype.getEval=function(){return e.eval},e.prototype.isWriting=function(){return e.iswriting},e.prototype.getPairing=function(){return e.pairing},e.prototype.getCurrentUser=function(){return e.currentUser},e});
\ No newline at end of file
This diff is collapsed.
define(["jquery"],function(a){function b(a,c){return this.controler=a,this.assignpart=c,b.clickAnnotation=0,this}b.controler=null,b.assignpart=-1,b.clickAnnotation=0,b.delayBeforeAnnotation=2,b.options=null,b.prototype.drawAnnotation=function(b,c,d){if(b&&b.duration){var e=c.timeposition/b.duration*100,f=a(b).next(),g=c.displayDiv(e,d);f.find(".audio_annotations").append(g)}},b.prototype.goBeforeAnnotation=function(a,d){a&&(a.currentTime=Math.max(d.timeposition-b.delayBeforeAnnotation,0),c(a),b.clickAnnotation=1)},b.prototype.getWaveOpts=function(c){var d={ajax:"justWave/justwave.ajax.php",width:900,height:100,wave_color:"#909296",prog_color:"#74cdd7",back_color:"#FFFFFF",buttoncolor:"#A47655",buttonsize:0,showname:1,namesize:15,showtimes:1,nowaves:0,nocache:!0};a.isPlainObject(b.options)&&a.extend(d,b.options),c.attr("width")&&(d.width=c.attr("width")),c.attr("height")&&(d.height=c.attr("height")),c.attr("poster")&&(d.poster=c.attr("poster"));var e=c.data();return Object.keys(e).map(function(a){d[a]=e[a]}),d},b.prototype.init=function(h,i){var j='<div class="justwave_wrapper">';j+='<img class="justwave_wave" src="" alt="" ondragstart="return false"/>',j+='<div class="justwave_playhead">',j+='<img class="justwave_progress" src="" alt="" ondragstart="return false"/>',j+='<span class="justwave_curpos">00:00</span>',j+="</div>",j+='<span class="justwave_duration">00:00</span>',j+='<span class="justwave_curfocus">00:00</span>',j+='<span class="justwave_songname"></span>',j+='<button type="button" style="left:2px;" ',j+='class="btn justwave_playpause_btn justwave_playpause_before btn-primary btn-lg">',j+='<i class="fa fa-reply fa-lg"></i>',j+="</button>",j+='<button type="button" style="left:65px;" ',j+='class="btn justwave_playpause_btn justwave_playpause btn-primary btn-lg">',j+='<i class="fa fa-play fa-lg"></i>',j+="</button>",j+='<div class="audio_annotations"></div>',j+="</div>";var k=a("audio");null!==this.assignpart&&(k=a(".justwave"+this.assignpart.assignpartid).find("audio")),"string"==typeof h&&(i=h),"string"==typeof i&&(k=k.filter("."+i));var l=this.controler,m=this.assignpart,n=this.getWaveOpts;k.each(function(){var h=this,i=a(this);h.opts=n(i),h.opts.chained&&i.addClass("justwave_chained"),i.after(j),a(h).on("canplay",function(b){var c=b.target,d=a(c).next();c.xduration=c.duration,c.opts.showtimes&&c.opts.showtimes>0?d.find(".justwave_duration, .justwave_curpos").show():d.find(".justwave_duration, .justwave_curpos").hide()}).on("playing",function(b){var c=b.target,d=a(c).next();d.find(".justwave_playpause i.fa").addClass("fa-pause"),d.find(".justwave_playpause i.fa").removeClass("fa-play"),c.opts.chained&&a("audio.justwave_chained").each(function(){this!==c&&this.pause()}),l.notify("playing","player",c)}).on("pause",function(b){var c=a(b.target).next();c.find(".justwave_playpause i.fa").addClass("fa-play"),c.find(".justwave_playpause i.fa").removeClass("fa-pause")}).on("error",function(b){var c=b.target,d=a(c).next();f(c),d.find(".justwave_playpause").prop("disabled",!0),d.find(".justwave_playpause_before").prop("disabled",!0),d.find(".justwave_songname").text(a(c).attr("src").replace(/.+[\\\/]/,"")),d.find(".justwave_duration").text("00:00"),c.xduration=0,d.find(".justwave_duration, .justwave_curpos, .justwave_curfocus").hide(),l.notify("error","player",c)}).on("timeupdate",function(){c(this)}).on("ended",function(){this.pause()}),f(h),g(h);var k=i.next();k.click(function(d){if(!b.clickAnnotation||0===b.clickAnnotation){d.preventDefault();var e=a(this).prev()[0],f=a(this).offset(),g=d.pageX-f.left;e.currentTime=g*e.xduration/this.offsetWidth,c(e),m.notify("click",e.currentTime)}b.clickAnnotation=0}).mousemove(function(b){var c=a(this).offset(),f=b.pageX-c.left,g=b.pageY-c.top,h=this,i=a(this).prev()[0];a(h).find(".justwave_curfocus").text(d(f/this.offsetWidth*i.xduration)).css({top:g-5+"px",left:f+5+"px"}),i.opts.showname&&i.opts.showname>0&&e(a(h).find(".justwave_songname"))}).mouseleave(function(){a(this).find(".justwave_curfocus").hide(),a(this).find(".justwave_playpause").fadeOut(1e3),a(this).find(".justwave_playpause_before").fadeOut(1e3)}).mouseenter(function(){var b=a(this).prev()[0];a(this).find(".justwave_playpause").stop(!1,!0).fadeIn(500),a(this).find(".justwave_playpause_before").stop(!1,!0).fadeIn(500),b.opts.showtimes&&b.opts.showtimes>0&&a(this).find(".justwave_curfocus").show(),l.notify("mouseenter","player",b)}).dblclick(function(){b.clickAnnotation&&0!==b.clickAnnotation||m.notify("dblclick"),b.clickAnnotation=0}),k.find(".justwave_playpause").on("click touchstart",function(b){b.stopPropagation(),b.preventDefault();var c=a(this).parent(),d=c.prev()[0];d.ended&&(d.currentTime=0),d.paused?d.play():d.pause(),l.notify("pause","player",d)}),k.find(".justwave_playpause_before").on("click touchstart",function(d){d.stopPropagation(),d.preventDefault();var e=a(this).parent(),f=e.prev()[0];f.ended&&(f.currentTime=0),f.currentTime=Math.max(f.currentTime-b.delayBeforeAnnotation,0),c(f)}).on("dblclick",function(a){a.stopPropagation(),a.preventDefault()}),k.find(".justwave_playpause_btn").mouseenter(function(){a(this).siblings(".justwave_curfocus").hide()}).mouseleave(function(){var b=a(this).parent().prev()[0];b.opts.showtimes&&b.opts.showtimes>0&&a(this).siblings(".justwave_curfocus").show()}),k.parents("div.card").keypress(function(b){98===b.which&&a("button.justwave_playpause_before").click()}),l.notify("initeach","player",h)})};var c=function(b){var c=b.currentTime/b.xduration*100,e=a(b).next();c<=100.1&&e.find(".justwave_playhead").width(c+"%"),e.find(".justwave_curpos").text(d(b.currentTime))},d=function(a){var b=Math.floor(a/60),c=Math.floor(a%60);return isNaN(a)?"00:00":(b<10?"0":"")+b+":"+(c<10?"0":"")+c},e=function(a,b){b&&a.stop(!0,!0).hide(),a.is(":visible")||a.fadeIn(300,function(){a.fadeOut(7e3,"swing")})},f=function(b){var c=a(b).next();c.find(".justwave_wave").width(0).attr("src",""),c.find(".justwave_progress").width(0).attr("src",""),c.width(b.opts.width).height(b.opts.height).css("background",b.opts.wave_color),b.opts.poster&&c.css("background-image","url("+b.opts.poster+")"),c.find(".justwave_playhead").css("background",b.opts.prog_color)},g=function(b){var c=a(b).next();c.find(".justwave_playpause i.fa").addClass("fa-play"),c.find(".justwave_playpause i.fa").removeClass("fa-pause")};return b.prototype.drawWaveDisplay=function(b){var c=this.assignpart;b.opts=this.getWaveOpts(b);var h=new Audio;a(h).on("loadedmetadata",function(){var h=a(b).next();f(b),g(b),a(b).attr("src")?b.opts.audio=a(b).attr("src"):b.opts.audio=b.currentSrc;var i=h.find(".justwave_songname").css("font-size",b.opts.namesize+"px").text(decodeURIComponent(b.opts.audio.replace(/.+[\\\/]/,"")));b.opts.showname&&b.opts.showname>0&&e(i,!0),+b.opts.nowaves||a.ajax(b.opts.ajax,{dataType:"json",type:"POST",data:b.opts}).done(function(e){var f=a(b).next(),g=f.find(".justwave_wave"),h=f.find(".justwave_progress");"ok"===e.status&&(g.width(b.opts.width),h.width(b.opts.width),f.css("background",""),f.find(".justwave_playhead").css("background",""),b.opts.poster&&f.css("background-image","url("+b.opts.poster+")"),g.attr("src",e.waveurl),b.opts.wave_color===b.opts.prog_color?h.attr("src",e.waveurl):h.attr("src",e.progressurl)),b.xduration=parseFloat(e.duration),b.xduration||(b.xduration=b.duration),b.xduration&&!b.duration&&(b.duration=e.duration),f.find(".justwave_duration").text(d(b.xduration));var i=a(f).prev()[0];i.xduration=b.xduration,i.duration=b.duration,c&&c.notify("loadedmetadata",b)})}),h.src=a(b).attr("src")},b});
\ No newline at end of file
define(["jquery"],function(a){function b(a,c){return this.controler=a,this.assignpart=c,b.clickAnnotation=0,this}b.controler=null,b.assignpart=-1,b.clickAnnotation=0,b.delayBeforeAnnotation=2,b.options=null,b.prototype.drawAnnotation=function(b,c,d){if(b&&b.duration){var e=c.timeposition/b.duration*100,f=a(b).next(),g=c.displayDiv(e,d);f.find(".audio_annotations").append(g)}},b.prototype.goBeforeAnnotation=function(a,d){a&&(a.currentTime=Math.max(d.timeposition-b.delayBeforeAnnotation,0),c(a),b.clickAnnotation=1)},b.prototype.getWaveOpts=function(c){var d={ajax:"justWave/justwave.ajax.php",width:900,height:100,wave_color:"#909296",prog_color:"#74cdd7",back_color:"#FFFFFF",buttoncolor:"#A47655",buttonsize:0,showname:1,namesize:15,showtimes:1,nowaves:0,nocache:!0};a.isPlainObject(b.options)&&a.extend(d,b.options),c.attr("width")&&(d.width=c.attr("width")),c.attr("height")&&(d.height=c.attr("height")),c.attr("poster")&&(d.poster=c.attr("poster"));var e=c.data();return Object.keys(e).map(function(a){d[a]=e[a]}),d},b.prototype.init=function(h,i){var j=a("#player_markup > div.justwave_wrapper").clone(),k=a("audio");null!==this.assignpart&&(k=a(".justwave"+this.assignpart.assignpartid).find("audio")),"string"==typeof h&&(i=h),"string"==typeof i&&(k=k.filter("."+i));var l=this.controler,m=this.assignpart,n=this.getWaveOpts;k.each(function(){var h=this,i=a(this);h.opts=n(i),h.opts.chained&&i.addClass("justwave_chained"),i.after(j),a(h).on("canplay",function(b){var c=b.target,d=a(c).next();c.xduration=c.duration,c.opts.showtimes&&c.opts.showtimes>0?d.find(".justwave_duration, .justwave_curpos").show():d.find(".justwave_duration, .justwave_curpos").hide()}).on("playing",function(b){var c=b.target,d=a(c).next();d.find(".justwave_playpause i.fa").addClass("fa-pause"),d.find(".justwave_playpause i.fa").removeClass("fa-play"),c.opts.chained&&a("audio.justwave_chained").each(function(){this!==c&&this.pause()}),l.notify("playing","player",c)}).on("pause",function(b){var c=a(b.target).next();c.find(".justwave_playpause i.fa").addClass("fa-play"),c.find(".justwave_playpause i.fa").removeClass("fa-pause")}).on("error",function(b){var c=b.target,d=a(c).next();f(c),d.find(".justwave_playpause").prop("disabled",!0),d.find(".justwave_playpause_before").prop("disabled",!0),d.find(".justwave_songname").text(a(c).attr("src").replace(/.+[\\\/]/,"")),d.find(".justwave_duration").text("00:00"),c.xduration=0,d.find(".justwave_duration, .justwave_curpos, .justwave_curfocus").hide(),l.notify("error","player",c)}).on("timeupdate",function(){c(this)}).on("ended",function(){this.pause()}),f(h),g(h);var k=i.next();k.click(function(d){if(!b.clickAnnotation||0===b.clickAnnotation){d.preventDefault();var e=a(this).prev()[0],f=a(this).offset(),g=d.pageX-f.left;e.currentTime=g*e.xduration/this.offsetWidth,c(e),m.notify("click",e.currentTime)}b.clickAnnotation=0}).mousemove(function(b){var c=a(this).offset(),f=b.pageX-c.left,g=b.pageY-c.top,h=this,i=a(this).prev()[0];a(h).find(".justwave_curfocus").text(d(f/this.offsetWidth*i.xduration)).css({top:g-5+"px",left:f+5+"px"}),i.opts.showname&&i.opts.showname>0&&e(a(h).find(".justwave_songname"))}).mouseleave(function(){a(this).find(".justwave_curfocus").hide(),a(this).find(".justwave_playpause").fadeOut(1e3),a(this).find(".justwave_playpause_before").fadeOut(1e3)}).mouseenter(function(){var b=a(this).prev()[0];a(this).find(".justwave_playpause").stop(!1,!0).fadeIn(500),a(this).find(".justwave_playpause_before").stop(!1,!0).fadeIn(500),b.opts.showtimes&&b.opts.showtimes>0&&a(this).find(".justwave_curfocus").show(),l.notify("mouseenter","player",b)}).dblclick(function(){b.clickAnnotation&&0!==b.clickAnnotation||(h.pause(),m.notify("dblclick")),b.clickAnnotation=0}),k.find(".justwave_playpause").on("click touchstart",function(b){b.stopPropagation(),b.preventDefault();var c=a(this).parent(),d=c.prev()[0];d.ended&&(d.currentTime=0),d.paused?d.play():(d.pause(),m.notify("pause",d.currentTime)),l.notify("pause","player",d)}),k.find(".justwave_playpause_before").on("click touchstart",function(d){d.stopPropagation(),d.preventDefault();var e=a(this).parent(),f=e.prev()[0];f.ended&&(f.currentTime=0),f.currentTime=Math.max(f.currentTime-b.delayBeforeAnnotation,0),c(f)}).on("dblclick",function(a){a.stopPropagation(),a.preventDefault()}),k.find(".justwave_playpause_btn").mouseenter(function(){a(this).siblings(".justwave_curfocus").hide()}).mouseleave(function(){var b=a(this).parent().prev()[0];b.opts.showtimes&&b.opts.showtimes>0&&a(this).siblings(".justwave_curfocus").show()});var o=k.parents('div[data-parent="#accordionAssignPart"]');o.attr("tabindex",0),o.on("keydown",function(a){32===a.which&&(a.preventDefault(),k.find("button.justwave_playpause").click()),66===a.which&&(a.preventDefault(),k.find("button.justwave_playpause_before").click()),78===a.which&&(a.preventDefault(),h.pause(),m.notify("pause",h.currentTime),m.notify("dblclick"))}),l.notify("initeach","player",h)})};var c=function(b){var c=b.currentTime/b.xduration*100,e=a(b).next();c<=100.1&&e.find(".justwave_playhead").width(c+"%"),e.find(".justwave_curpos").text(d(b.currentTime))},d=function(a){var b=Math.floor(a/60),c=Math.floor(a%60);return isNaN(a)?"00:00":(b<10?"0":"")+b+":"+(c<10?"0":"")+c},e=function(a,b){b&&a.stop(!0,!0).hide(),a.is(":visible")||a.fadeIn(300,function(){a.fadeOut(7e3,"swing")})},f=function(b){var c=a(b).next();c.find(".justwave_wave").width(0).attr("src",""),c.find(".justwave_progress").width(0).attr("src",""),c.width(b.opts.width).height(b.opts.height).css("background",b.opts.wave_color),b.opts.poster&&c.css("background-image","url("+b.opts.poster+")"),c.find(".justwave_playhead").css("background",b.opts.prog_color)},g=function(b){var c=a(b).next();c.find(".justwave_playpause i.fa").addClass("fa-play"),c.find(".justwave_playpause i.fa").removeClass("fa-pause")};return b.prototype.drawWaveDisplay=function(b){var c=this.assignpart;b.opts=this.getWaveOpts(b);var h=new Audio;a(h).on("loadedmetadata",function(){var h=a(b).next();f(b),g(b),a(b).attr("src")?b.opts.audio=a(b).attr("src"):b.opts.audio=b.currentSrc;var i=h.find(".justwave_songname").css("font-size",b.opts.namesize+"px").text(decodeURIComponent(b.opts.audio.replace(/.+[\\\/]/,"")));b.opts.showname&&b.opts.showname>0&&e(i,!0),+b.opts.nowaves||a.ajax(b.opts.ajax,{dataType:"json",type:"POST",data:b.opts}).done(function(e){var f=a(b).next(),g=f.find(".justwave_wave"),h=f.find(".justwave_progress");"ok"===e.status&&(g.width(b.opts.width),h.width(b.opts.width),f.css("background",""),f.find(".justwave_playhead").css("background",""),b.opts.poster&&f.css("background-image","url("+b.opts.poster+")"),g.attr("src",e.waveurl),b.opts.wave_color===b.opts.prog_color?h.attr("src",e.waveurl):h.attr("src",e.progressurl)),b.xduration=parseFloat(e.duration),b.xduration||(b.xduration=b.duration),b.xduration&&!b.duration&&(b.duration=e.duration),f.find(".justwave_duration").text(d(b.xduration));var i=a(f).prev()[0];i.xduration=b.xduration,i.duration=b.duration,c&&c.notify("loadedmetadata",b)})}),h.src=a(b).attr("src")},b});
\ No newline at end of file
......@@ -119,6 +119,13 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
$(".btn_add_annotation").on('click', function () {
Controler.editors[$(this).data('assignpart')].notify("add");
});
$(".btn_add_annotation").on('mouseout', function () {
//to avoid new annotation (again...) when key space is pressed afer click
//on enleve la sélection
$(this).blur();
//on met le focus sur la div principale
$(this).parents('div[data-parent="#accordionAssignPart"]').focus();
});
}
$(".select_tqs").on('change', function () {
var assignpartid = $(this).data('assignpart');
......
......@@ -386,6 +386,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
$("#annotation_add" + assignpartid).show();
templates.replaceNodeContents('#annotation_add' + assignpartid, html, js);
control.notify('addannotation', "editor", null);
$("#annotation_add" + assignpartid).on('keydown', function (e) {
e.stopPropagation();
});
//init file form
moveFileForm();
//question button
......@@ -452,6 +455,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
$("#annotation_edit" + assignpartid).show();
templates.replaceNodeContents('#annotation_edit' + assignpartid, html, js);
control.notify('editannotation', "editor", null);
$("#annotation_edit" + assignpartid).on('keydown', function (e) {
e.stopPropagation();
});
annotation.refreshDiv(true);
moveFileForm();
//question button
......@@ -621,6 +627,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
this.initAnnotationsDisplay();
} else if (event === "click") {
this.lastP.currentTime = object;
} else if (event === "pause") {
this.lastP.currentTime = object;
} else if (event === "dblclick") {
if (this.isWriting() > 0 || this.getPairing()) {
this.addAnnotation();
......
......@@ -178,25 +178,7 @@ define(['jquery'],
*/
JustWave.prototype.init = function (options, classOnly) {
// player markup
var html = '<div class="justwave_wrapper">';
html += '<img class="justwave_wave" src="" alt="" ondragstart="return false"/>';
html += '<div class="justwave_playhead">';
html += '<img class="justwave_progress" src="" alt="" ondragstart="return false"/>';
html += '<span class="justwave_curpos">00:00</span>';
html += '</div>';
html += '<span class="justwave_duration">00:00</span>';
html += '<span class="justwave_curfocus">00:00</span>';
html += '<span class="justwave_songname"></span>';
html += '<button type="button" style="left:2px;" ';
html += 'class="btn justwave_playpause_btn justwave_playpause_before btn-primary btn-lg">';
html += '<i class="fa fa-reply fa-lg"></i>';
html += '</button>';
html += '<button type="button" style="left:65px;" ';
html += 'class="btn justwave_playpause_btn justwave_playpause btn-primary btn-lg">';
html += '<i class="fa fa-play fa-lg"></i>';
html += '</button>';
html += '<div class="audio_annotations"></div>';
html += '</div>';
var playerMakup = $('#player_markup > div.justwave_wrapper').clone();
var els = $('audio');
if (this.assignpart !== null) {
......@@ -226,7 +208,7 @@ define(['jquery'],
}
// create simple but elegant wave player IMHO
$p.after(html);
$p.after(playerMakup);
$(p).on('canplay', function (e) {
// meta data of audio is loaded
var p = e.target;
......@@ -336,6 +318,7 @@ define(['jquery'],
controlerNot.notify('mouseenter', "player", p);
}).dblclick(function () {
if (!JustWave.clickAnnotation || JustWave.clickAnnotation === 0) {
p.pause();
//notify contoler
assignpartNot.notify("dblclick");
}
......@@ -358,6 +341,7 @@ define(['jquery'],
p.play();
} else {
p.pause();
assignpartNot.notify("pause", p.currentTime);
}
controlerNot.notify('pause', "player", p);
});
......@@ -389,12 +373,28 @@ define(['jquery'],
$(this).siblings('.justwave_curfocus').show();
}
});
song.parents('div.card').keypress(function (e) {
if (e.which === 98) { // touche B
$('button.justwave_playpause_before').click();
var divcard = song.parents('div[data-parent="#accordionAssignPart"]');
divcard.attr('tabindex', 0);
divcard.on('keydown', function (e) {
if (e.which === 32) { // touche espace
e.preventDefault();
//pause ou play
song.find('button.justwave_playpause').click();
}
if (e.which === 66) { // touche B
e.preventDefault();
//retour arriere
song.find('button.justwave_playpause_before').click();
}
if (e.which === 78) { // touche N
e.preventDefault();
//pause + maj current cursor
p.pause();
assignpartNot.notify("pause", p.currentTime);
//on simule un double click pour ajouter une nouvelle annot
assignpartNot.notify("dblclick");
}
});
controlerNot.notify('initeach', "player", p);
}); // each
......
......@@ -105,6 +105,7 @@ $string['status'] = 'Statut';
$string['question'] = 'Question';
$string['filter_annotations'] = 'Filter annotations by';
$string['add'] = 'Add';
$string['add_help'] = 'Add a new annotation (shortcut: \'N\')';
$string['deadline_exceeded'] = 'Warning, deadline of delivery exceeded';
$string['recording'] = 'Recording';
$string['error_sendfile'] = 'Error sending file';
......@@ -169,6 +170,8 @@ $string['required'] = 'Required';
$string['record_limit'] = '<b>Info!</b> New records are limited to {$a}sec.';
$string['delete_record_question'] = 'Do you realy want to delete this record?';
$string['annot_already_here'] = 'An annotation is already here';
$string['back_help'] = 'Back few seconds before (shortcut: \'B\')';
$string['play_help'] = 'Play/Pause (shortcut: \'space\')';
$string['audioannotation'] = 'Audio annotation';
$string['pluginadministration'] = 'Audio annotation administration';
......
......@@ -105,6 +105,7 @@ $string['status'] = 'Statut';
$string['question'] = 'Question';
$string['filter_annotations'] = 'Filter les annotations par ';
$string['add'] = 'Ajouter';
$string['add_help'] = 'Ajouter une nouvelle annotation (raccourci: \'N\')';
$string['deadline_exceeded'] = 'Attention, date limite de remise dépassée ';
$string['recording'] = 'Enregistrement';
$string['error_sendfile'] = 'Erreur lors de l\'envoi du fichier';
......@@ -170,6 +171,8 @@ $string['required'] = 'Requis';
$string['record_limit'] = '<b>Info!</b> Temps d\'enregistrement limité à {$a} secondes';
$string['delete_record_question'] = 'Êtes-vous sûr de vouloir supprimer cet enregistrement ?';
$string['annot_already_here'] = 'Une annotation existe déjà à cet emplacement';
$string['back_help'] = 'Revenir quelques secondes avant (raccourci: \'B\')';
$string['play_help'] = 'Jouer/Pause (raccourci: \'espace\')';
$string['audioannotation'] = 'Audio annotation';
$string['pluginadministration'] = 'Audio annotation administration';
......
......@@ -36,6 +36,8 @@
<div class="d-flex">
<div class="btn-group">
<button type="button" class="btn btn-default btn_add_annotation" data-assignpart="{{id}}"><i class="fa fa-plus"></i> {{# str }} add, audioannotation {{/ str }}</button>
<button type="button" class="btn btn-default btn_add_annotation" data-assignpart="{{id}}" title="{{# str }} add_help, audioannotation {{/ str }}">
<i class="fa fa-plus"></i> {{# str }} add, audioannotation {{/ str }}
</button>
</div>
</div>
\ No newline at end of file
......@@ -350,6 +350,8 @@
{{/iswriting}}
{{/eval}}
</nav>
{{> mod_audioannotation/player_markup}}
{{# js }}
......
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_audioannotation/player_markup
Template for teacher to eval a student work, or see feedback in readonly.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* none
}}
<div style="display:none;" id="player_markup">
<div class="justwave_wrapper">
<img class="justwave_wave" src="" alt="" ondragstart="return false"/>
<div class="justwave_playhead">
<img class="justwave_progress" src="" alt="" ondragstart="return false"/>
<span class="justwave_curpos">00:00</span>
</div>
<span class="justwave_duration">00:00</span>
<span class="justwave_curfocus">00:00</span>
<span class="justwave_songname"></span>
<button type="button" style="left:2px;" title="{{# str }} back_help, audioannotation {{/ str }}" class="btn justwave_playpause_btn justwave_playpause_before btn-primary btn-lg">
<i class="fa fa-reply fa-lg"></i>
</button>
<button type="button" style="left:65px;" title="{{# str }} play_help, audioannotation {{/ str }}" class="btn justwave_playpause_btn justwave_playpause btn-primary btn-lg">
<i class="fa fa-play fa-lg"></i>
</button>
<div class="audio_annotations"></div>
</div>
</div>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment