/* MediaElement
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') {
VMM.MediaElement = ({
init: function() {
return this;
},
// somestring = VMM.MediaElement.thumbnail(data);
thumbnail: function(data, w, h) {
_w = 32;
_h = 32;
if (w != null && w != "") {
_w = w;
}
if (h != null && h != "") {
_h = h;
}
if (data.media != null && data.media != "") {
_valid = true;
var mediaElem = "";
var m = {};
// MEDIA TYPE
m = VMM.MediaType(data.media); //returns an object with .type and .id
// CREATE MEDIA CODE
if (m.type == "image") {
mediaElem = "
";
return mediaElem;
} else if (m.type == "flickr") {
mediaElem = "";
return mediaElem;
} else if (m.type == "youtube") {
mediaElem = "
";
return mediaElem;
} else if (m.type == "googledoc") {
mediaElem = "";
} else if (m.type == "vimeo") {
mediaElem = "
";
return mediaElem;
} else if (m.type == "twitter"){
mediaElem = "";
return mediaElem;
} else if (m.type == "twitter-ready") {
mediaElem = "";
return mediaElem;
} else if (m.type == "soundcloud") {
mediaElem = "
";
return mediaElem;
} else if (m.type == "google-map") {
mediaElem = "
";
return mediaElem;
} else if (m.type == "unknown") {
mediaElem = "";
return mediaElem;
} else if (m.type == "website") {
mediaElem = "
";
//mediaElem = "";
return mediaElem;
} else {
mediaElem = "
";
return mediaElem;
}
}
},
//VMM.MediaElement.create(element, data, returntrue);
create: function(element, data, __return, w, h) {
_return = __return;
_w = 500;
_h = 400;
$mediacontainer = element;
//VMM.MediaElement.container = element;
var _valid = false;
if (w != null && w != "") {
_w = w;
}
if (h != null && h != "") {
_h = h;
}
if (data.media != null && data.media != "") {
_valid = true;
var mediaElem = "";
var captionElem = "";
var creditElem = "";
var m = {};
var media_height = (_h - 50);
var isTextMedia = false;
// CREDIT
if (data.credit != null && data.credit != "") {
creditElem = "" + VMM.Util.linkify_with_twitter(data.credit, "_blank") + "
";
}
// CAPTION
if (data.caption != null && data.caption != "") {
captionElem = "" + VMM.Util.linkify_with_twitter(data.caption, "_blank") + "
";
}
// MEDIA TYPE
m = VMM.MediaType(data.media); //returns an object with .type and .id
// CREATE MEDIA CODE
if (m.type == "image") {
mediaElem = " ";
} else if (m.type == "flickr") {
var flickr_id = "flickr_" + m.id;
mediaElem = " ";
VMM.ExternalAPI.flickr.getPhoto(m.id, "#" + flickr_id);
} else if (m.type == "googledoc") {
if (m.id.match(/docs.google.com/i)) {
mediaElem = "";
} else {
mediaElem = "";
}
} else if (m.type == "youtube") {
mediaElem = "Loading YouTube video...
";
VMM.ExternalAPI.youtube.init(m.id);
//mediaElem = "VIDEO ";
} else if (m.type == "vimeo") {
mediaElem = "";
} else if (m.type == "twitter"){
mediaElem = "";
//VMM.ExternalAPI.twitter.getHTML(m.id);
trace("TWITTER");
VMM.ExternalAPI.twitter.prettyHTML(m.id);
isTextMedia = true;
} else if (m.type == "twitter-ready") {
mediaElem = m.id;
} else if (m.type == "soundcloud") {
var soundcloud_id = "soundcloud_" + VMM.Util.unique_ID(5);
mediaElem = "Loading Sound
";
VMM.ExternalAPI.soundcloud.getSound(m.id, soundcloud_id)
} else if (m.type == "google-map") {
//mediaElem = ""
var map_id = "googlemap_" + VMM.Util.unique_ID(7);
mediaElem = "Loading Map...
";
VMM.ExternalAPI.googlemaps.getMap(m.id, map_id);
} else if (m.type == "unknown") {
trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML");
mediaElem = VMM.Util.properQuotes(m.id);
} else if (m.type == "website") {
mediaElem = "";
//mediaElem = "" + " ";
} else {
trace("NO KNOWN MEDIA TYPE FOUND");
trace(m.type);
}
// WRAP THE MEDIA ELEMENT
mediaElem = "" + mediaElem + creditElem + captionElem + "
";
if (_return) {
if (isTextMedia) {
return "";
} else {
return "";
}
} else {
VMM.appendElement($mediacontainer, mediaElem);
VMM.appendElement($mediacontainer, creditElem);
VMM.appendElement($mediacontainer, captionElem);
}
};
},
}).init();
}