padmaAPI/static/js/padmaVideo.js

107 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

2010-07-12 19:09:53 +00:00
var padmaVideo = function(json, index) {
this.id = json.id;
this.index = index;
this.title = json.title;
this.jq = {};
2010-07-15 00:02:35 +00:00
this.poster = PADMA_BASE_URL + "/" + this.id + "/poster.jpg";
this.timeline = PADMA_BASE_URL + "/" + this.id + "/timeline.png";
2010-07-12 19:09:53 +00:00
this.wrapperHtml = this.getWrapperHtml()
this.init();
this.dataLoaded = false;
this.layers = [];
2010-07-13 12:08:50 +00:00
}
2010-07-12 19:09:53 +00:00
padmaVideo.prototype.getWrapperHtml = function() {
var that = this;
var videoElem = $('<div />');
videoElem.attr('id', that.id);
videoElem.addClass("videoWrapper");
var html = '';
html += "<div class='videoTitle'>";
html += this.title;
html += "</div>";
html += "<div class='videoPoster'>";
html += "<img src='" + this.poster + "' />";
html += "</div>";
/*
html += "<div class='videoTimeline' data-index='" + this.index + "'>";
html += "<img src='" + this.timeline + "' class='timeline' />";
html += "</div>";
*/
html += "<div class='videoMeta'>";
html += "Loading...";
html += "</div>";
html += "<div class='searchResults'></div>";
videoElem.html(html);
return videoElem;
2010-07-13 12:08:50 +00:00
}
2010-07-12 19:09:53 +00:00
/*
var Timeline = function(padmaVideo) {
this.videoId = padmaVideo.id;
this.layers = padmaVideo.layers;
this.url = padmaVideo.timeline;
this.e = $('.videoTimeline').find('@attr
}
*/
padmaVideo.prototype.init = function() {
var that = this;
$('#videos').append(that.wrapperHtml);
this.jq = $('#' + that.id);
this.loadData();
2010-07-15 00:02:35 +00:00
// console.log("hi");
return;
2010-07-13 12:08:50 +00:00
}
2010-07-12 19:09:53 +00:00
padmaVideo.prototype.getLayerById = function(id) {
var that = this;
for (var i=0; i < that.layers.length; i++) {
var thisLayer = that.layers[i];
if (thisLayer.id == id) {
return thisLayer;
}
}
return false;
}
padmaVideo.prototype.metaLoaded = function() {
var that = this;
$('#' + that.id + ' .videoMeta').html(that.meta.description_html);
2010-07-13 12:08:50 +00:00
}
2010-07-12 19:09:53 +00:00
padmaVideo.prototype.layersLoaded = function() {
this.dataLoaded = true;
$('#bottomBar').fadeIn();
/* $('.videoTimeline').mousemove(function(e) {
var offset = $(this).offset();
var x = e.pageX - offset.left;
var y = e.pageY - offset.top;
var index = $(this).attr('data-id');
var thisVideo = padmaVideos[index];
});
*/
2010-07-13 12:08:50 +00:00
}
2010-07-12 19:09:53 +00:00
padmaVideo.prototype.loadData = function() {
var that = this;
2010-07-15 00:02:35 +00:00
var metaUrl = PADMA_BASE_URL + "/" + that.id + "/video.js";
// console.log(metaUrl);
2010-07-12 19:09:53 +00:00
$.getScript(metaUrl, function() {
that.meta = video;
that.metaLoaded();
2010-07-15 00:02:35 +00:00
var layersUrl = PADMA_BASE_URL + "/" + that.id + "/layers.js";
2010-07-12 19:09:53 +00:00
$.getScript(layersUrl, function() {
var theseLayers = layers;
for (var i=0; i < theseLayers.length; i++) {
var thisLayer = new padmaLayer(theseLayers[i], that);
that.layers.push(thisLayer);
}
that.layersLoaded();
});
2010-07-13 12:08:50 +00:00
});
}
2010-07-12 19:09:53 +00:00