sanj
14 years ago
2 changed files with 62 additions and 1 deletions
@ -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); |
Loading…
Reference in new issue