equal
deleted
inserted
replaced
1 IriSP.Widgets.Mediafragment = function(player, config) { |
1 IriSP.Widgets.Mediafragment = function(player, config) { |
2 IriSP.Widgets.Widget.call(this, player, config); |
2 IriSP.Widgets.Widget.call(this, player, config); |
3 this.last_hash = ""; |
3 this.last_hash = ""; |
4 window.onhashchange = this.functionWrapper("goToHash"); |
4 window.onhashchange = this.functionWrapper("goToHash"); |
|
5 if (typeof window.addEventListener !== "undefined") { |
|
6 window.addEventListener('message', function(_msg) { |
|
7 if (_msg.data.type === "hashchange") { |
|
8 document.location.hash = _msg.data.hash; |
|
9 } |
|
10 }) |
|
11 }; |
5 this.bindPopcorn("pause","setHashToTime"); |
12 this.bindPopcorn("pause","setHashToTime"); |
6 this.bindPopcorn("seeked","setHashToTime"); |
13 this.bindPopcorn("seeked","setHashToTime"); |
7 this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation"); |
14 this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation"); |
8 this.blocked = false; |
15 this.blocked = false; |
9 } |
16 } |
41 |
48 |
42 IriSP.Widgets.Mediafragment.prototype.setHash = function(_hash) { |
49 IriSP.Widgets.Mediafragment.prototype.setHash = function(_hash) { |
43 if (!this.blocked && this.last_hash !== _hash) { |
50 if (!this.blocked && this.last_hash !== _hash) { |
44 this.last_hash = _hash; |
51 this.last_hash = _hash; |
45 document.location.hash = _hash; |
52 document.location.hash = _hash; |
|
53 if (window.parent !== window) { |
|
54 window.parent.postMessage({ |
|
55 type: "hashchange", |
|
56 hash: _hash |
|
57 }) |
|
58 } |
46 this.block(); |
59 this.block(); |
47 } |
60 } |
48 } |
61 } |
49 |
62 |
50 IriSP.Widgets.Mediafragment.prototype.unblock = function() { |
63 IriSP.Widgets.Mediafragment.prototype.unblock = function() { |