This commit is contained in:
sanj 2011-01-02 14:52:15 +05:30
parent 9019a05ab1
commit 76979b60b0
2 changed files with 62 additions and 1 deletions

View File

@ -20,6 +20,7 @@
if (linkData && $.inArray(linkData.type, ['info', 'tcRange', 'editor', 'tc', 'layer'])) { if (linkData && $.inArray(linkData.type, ['info', 'tcRange', 'editor', 'tc', 'layer'])) {
//Don't fetch data twice if video id already exists //Don't fetch data twice if video id already exists
$(that).addClass('padmaLink'); $(that).addClass('padmaLink');
var videoId = linkData.videoId; var videoId = linkData.videoId;
/* /*
var cacheVideo = padmaVideo.getFromCache(videoId); var cacheVideo = padmaVideo.getFromCache(videoId);
@ -30,7 +31,9 @@
} }
*/ */
var videoObj = new padmaVideo(videoId); var videoObj = new padmaVideo(videoId);
$(this).data({
'videoObj': videoObj
});
// console.log(linkData); // console.log(linkData);
videoObj.getAllData(setupPadmaLink, {'linkData': linkData, 'jq': that}); videoObj.getAllData(setupPadmaLink, {'linkData': linkData, 'jq': that});
@ -39,6 +42,10 @@
} }
} }
}); });
if ($('#leftBar').length > 0) {
var playlist = new PadmaPlaylist($('#leftBar'));
}
// FOO = new PadmaPlaylist($('#essay'));
}); });
// D = parsePadmaUrl; // D = parsePadmaUrl;
})(jQuery); })(jQuery);

54
padma.playlist.js Normal file
View File

@ -0,0 +1,54 @@
/*
Padma Playlist -
Pass it a jquery object - it will find all a elements within it which are padma links and make them a playlist
eg. var playlist = new PadmaPlaylist($('
*/
(function($) {
var PadmaPlaylist = window.PadmaPlaylist = function(jq) {
this.videos = [];
this.elements = [];
this.position = 0;
this.len = function() { return this.elements.length };
this.jq = jq;
this.init();
};
PadmaPlaylist.prototype.init = function() {
var that = this;
var i = 0;
$('a', that.jq).each(function() {
var t = $(this);
var href = t.attr("href");
if (href.indexOf(padmaConfig.links_url) != -1) {
that.elements.push(t);
t.data("playlist", that);
t.data("inPlaylist", true);
t.data("playlistPosition", i);
t.click(function() {
var playlist = $(this).data("playlist");
var position = $(this).data("playlistPosition");
playlist.position = position;
});
i++;
}
});
};
PadmaPlaylist.prototype.next = function() {
var pos = this.position;
if (pos < (this.len() - 1)) {
var nextElem = this.elements[pos + 1];
nextElem.click();
}
};
PadmaPlaylist.prototype.previous = function() {
var pos = this.position;
if (pos > 0) {
var prevElem = this.elements[pos - 1];
prevElem.click();
}
};
})(jQuery);