Gitlab CSE Unil

Commit 968944f0 authored by M. Chardon's avatar M. Chardon
Browse files

correction bug click/double click poour nouvelle annotation

parent 02808b78
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),l.notify("click","player",e)}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(){m.notify("dblclick",h)}),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()}),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,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='<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()}),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
......@@ -202,12 +202,6 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
case "loadedmetadata" :
this.initAnnotations();
break;
/*case "drawannotation_draft":
Controler.wavePlayer.drawAnnotation(Controler.lastP, object, 1);
break;*/
/*case "drawannotation":
Controler.wavePlayer.drawAnnotation(Controler.lastP, object, 0);
break;*/
case "addannotation":
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
......
......@@ -619,9 +619,10 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
if (event === "loadedmetadata") {
this.lastP = object;
this.initAnnotationsDisplay();
} else if (event === "click") {
this.lastP.currentTime = object;
} else if (event === "dblclick") {
if (this.isWriting() > 0 || this.getPairing()) {
this.lastP = object;
this.addAnnotation();
}
} else if (event === "edit") {
......
......@@ -306,7 +306,7 @@ define(['jquery'],
// update cursor
updatePlayhead(p);
//notify contoler
controlerNot.notify('click', "player", p);
assignpartNot.notify("click", p.currentTime);
}
JustWave.clickAnnotation = 0;
}).mousemove(function (e) {
......@@ -335,7 +335,11 @@ define(['jquery'],
}
controlerNot.notify('mouseenter', "player", p);
}).dblclick(function () {
assignpartNot.notify("dblclick", p);
if (!JustWave.clickAnnotation || JustWave.clickAnnotation === 0) {
//notify contoler
assignpartNot.notify("dblclick");
}
JustWave.clickAnnotation = 0;
});
// bind play/pause button
......@@ -547,6 +551,7 @@ define(['jquery'],
//set duration on audio dom
var psong = $(song).prev()[0];
psong.xduration = p.xduration;
psong.duration = p.duration;
if (assignpart) {
assignpart.notify("loadedmetadata", p);
......
......@@ -75,7 +75,7 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true"/>
<FIELD NAME="user" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT=""/>
<FIELD NAME="assignementpart" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Course audioannotation assignement part belongs to"/>
<FIELD NAME="timeposition" TYPE="float" LENGTH="10" DECIMALS="5" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT=""/>
<FIELD NAME="timeposition" TYPE="float" LENGTH="15" DECIMALS="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT=""/>
<FIELD NAME="validation" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT=""/>
<FIELD NAME="statut" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT=""/>
<FIELD NAME="mainmessage" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT=""/>
......
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