src/widgets/Mediafragment.js
branchnew-model
changeset 882 61c384dda19e
parent 881 f11b234497f7
child 883 d35ad8111c5e
--- a/src/widgets/Mediafragment.js	Fri Apr 27 19:18:21 2012 +0200
+++ b/src/widgets/Mediafragment.js	Thu May 03 17:52:52 2012 +0200
@@ -2,6 +2,13 @@
     IriSP.Widgets.Widget.call(this, player, config);
     this.last_hash = "";
     window.onhashchange = this.functionWrapper("goToHash");
+    if (typeof window.addEventListener !== "undefined") {
+        window.addEventListener('message', function(_msg) {
+            if (_msg.data.type === "hashchange") {
+                document.location.hash = _msg.data.hash;
+            }
+        })
+    };
     this.bindPopcorn("pause","setHashToTime");
     this.bindPopcorn("seeked","setHashToTime");
     this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation");
@@ -43,6 +50,12 @@
     if (!this.blocked && this.last_hash !== _hash) {
         this.last_hash = _hash;
         document.location.hash = _hash;
+        if (window.parent !== window) {
+            window.parent.postMessage({
+                type: "hashchange",
+                hash: _hash
+            })
+        }
         this.block();
     }
 }