1 /** The osmplayer namespace. */
  2 var osmplayer = osmplayer || {};
  3 
  4 /**
  5  * @constructor
  6  * @extends minplayer.display
  7  * @class This class provides teaser functionality.
  8  *
  9  * @param {object} context The jQuery context.
 10  * @param {object} options This components options.
 11  */
 12 osmplayer.teaser = function(context, options) {
 13 
 14   /** The preview image. */
 15   this.preview = null;
 16 
 17   // Derive from display
 18   minplayer.display.call(this, 'teaser', context, options);
 19 };
 20 
 21 /** Derive from minplayer.display. */
 22 osmplayer.teaser.prototype = new minplayer.display();
 23 
 24 /** Reset the constructor. */
 25 osmplayer.teaser.prototype.constructor = osmplayer.teaser;
 26 
 27 /**
 28  * Selects the teaser.
 29  *
 30  * @param {boolean} selected TRUE if selected, FALSE otherwise.
 31  */
 32 osmplayer.teaser.prototype.select = function(selected) {
 33 };
 34 
 35 /**
 36  * Sets the node.
 37  *
 38  * @param {object} node The node object to set.
 39  */
 40 osmplayer.teaser.prototype.setNode = function(node) {
 41 
 42   // Add this to the node info for this teaser.
 43   this.node = node;
 44 
 45   // Set the title of the teaser.
 46   if (this.elements.title) {
 47     if (node.title) {
 48       this.elements.title.text(node.title);
 49     }
 50     else {
 51       osmplayer.getNode(node, (function(teaser) {
 52         return function(node) {
 53           teaser.elements.title.text(node.title);
 54         };
 55       })(this));
 56     }
 57   }
 58 
 59   // Load the thumbnail image if it exists.
 60   if (node.mediafiles) {
 61     osmplayer.getImage(node.mediafiles, 'thumbnail', (function(teaser) {
 62       return function(image) {
 63         if (image && teaser.elements.image) {
 64           teaser.preview = new minplayer.image(teaser.elements.image);
 65           teaser.preview.load(image.path);
 66         }
 67       };
 68     })(this));
 69   }
 70 
 71   // Bind when they click on this teaser.
 72   this.display.unbind('click').click((function(teaser) {
 73     return function(event) {
 74       event.preventDefault();
 75       teaser.trigger('nodeLoad', teaser.node);
 76     };
 77   })(this));
 78 };
 79