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 this.elements.title.text(node.title); 48 } 49 50 // Load the thumbnail image if it exists. 51 if (node.mediafiles && node.mediafiles.image) { 52 var image = osmplayer.getImage(node.mediafiles, 'thumbnail'); 53 if (image) { 54 if (this.elements.image) { 55 this.preview = new minplayer.image(this.elements.image); 56 this.preview.load(image); 57 } 58 } 59 } 60 61 // Bind when they click on this teaser. 62 this.display.unbind('click').click((function(teaser) { 63 return function(event) { 64 event.preventDefault(); 65 teaser.trigger('nodeLoad', teaser.node); 66 }; 67 })(this)); 68 }; 69