optimize instantiation of .pandoravideo()s

This commit is contained in:
Sanj 2012-05-15 03:17:34 +05:30
parent ff4a28b8b2
commit 0fa7ca5c71

View File

@ -250,13 +250,24 @@
(function() { (function() {
var $video; var $video;
$('.padmaVideo').hide(); $('.padmaVideo').hide();
/*
$('.padmaVideo').each(function() { $('.padmaVideo').each(function() {
$(this).pandoravideo(); $(this).pandoravideo();
}); });
*/
$('a.padmaLink').toggle(function() { $('a.padmaLink').toggle(function() {
var index = $(this).index('.padmaLink'); var index = $(this).index('.padmaLink');
var $video = $('.padmaVideo').eq(index); var $video = $('.padmaVideo').eq(index);
$video.slideDown(); if ($video.data("padmaLoaded")) {
$video.slideDown();
} else {
$video.text("Loading video...");
$video.pandoravideo({
callback: function(videoObject) {
$video.data("padmaLoaded", true);
}
});
}
}, function() { }, function() {
var index = $(this).index('.padmaLink'); var index = $(this).index('.padmaLink');
var $video = $('.padmaVideo').eq(index); var $video = $('.padmaVideo').eq(index);