src/js/modules/embed.js
author hamidouk
Fri, 17 Feb 2012 11:57:27 +0100
branchpopcorn-port
changeset 817 e9599ee285ab
parent 809 1997dae651c6
permissions -rw-r--r--
implements the most asked for feature ever : placeholder text in the annotation creation textfield.

/* embed module - listens and relay hash changes to a parent window. */

IriSP.EmbedModule = function(Popcorn, config, Serializer) {
  IriSP.Module.call(this, Popcorn, config, Serializer);

  window.addEventListener('message', IriSP.wrap(this, this.handleMessages), false);
  this._Popcorn.listen("IriSP.Mediafragment.hashchange", IriSP.wrap(this, this.relayChanges));
};

IriSP.EmbedModule.prototype = new IriSP.Module();

IriSP.EmbedModule.prototype.handleMessages = function(e) {
  if (e.data.type === "hashchange") {
    window.location.hash = e.data.value;    
  }  
};

IriSP.EmbedModule.prototype.relayChanges = function(newHash) {
  window.parent.postMessage({type: "hashchange", value: newHash}, "*"); 
  return;
};