diff -r 4c7b33bf2795 -r f11b234497f7 src/widgets/Mediafragment.js --- a/src/widgets/Mediafragment.js Thu Apr 26 19:18:57 2012 +0200 +++ b/src/widgets/Mediafragment.js Fri Apr 27 19:18:21 2012 +0200 @@ -2,7 +2,10 @@ IriSP.Widgets.Widget.call(this, player, config); this.last_hash = ""; window.onhashchange = this.functionWrapper("goToHash"); - this.player.bindPopcorn("pause","setHashToTime"); + this.bindPopcorn("pause","setHashToTime"); + this.bindPopcorn("seeked","setHashToTime"); + this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation"); + this.blocked = false; } IriSP.Widgets.Mediafragment.prototype = new IriSP.Widgets.Widget(); @@ -28,17 +31,34 @@ } IriSP.Widgets.Mediafragment.prototype.setHashToAnnotation = function(_annotationId) { - this.last_hash = '#id=' + this.source.unNamespace(_annotationId); - + this.setHash( '#id=' + this.source.unNamespace(_annotationId) ); } -IriSP.Widgets.Mediafragment.prototype.setHashToTime = function() { - this.last_hash = '#t=' + this.source.popcorn.currentTime(); +IriSP.Widgets.Mediafragment.prototype.setHashToTime = function(_time) { + _time = (typeof _time !== "undefined" ? _time : this.player.popcorn.currentTime() ); + this.setHash( '#t=' + _time ); } IriSP.Widgets.Mediafragment.prototype.setHash = function(_hash) { - if (this.last_hash !== _hash) { + if (!this.blocked && this.last_hash !== _hash) { this.last_hash = _hash; document.location.hash = _hash; + this.block(); } -} \ No newline at end of file +} + +IriSP.Widgets.Mediafragment.prototype.unblock = function() { + if (typeof this.blockTimeout !== "undefined") { + window.clearTimeout(this.blockTimeout); + } + this.blockTimeout = undefined; + this.blocked = false; +} + +IriSP.Widgets.Mediafragment.prototype.block = function() { + if (typeof this.blockTimeout !== "undefined") { + window.clearTimeout(this.blockTimeout); + } + this.blocked = true; + this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1000); +}