Skip to content

Commit

Permalink
Allow dist dir in repo, and move jQuery plugin files into it
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvanatikku committed Dec 2, 2016
1 parent 7057648 commit 866af46
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 76 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
dist/
node_modules
node_modules
105 changes: 31 additions & 74 deletions jQuery.tubeplayer.js → dist/jQuery.tubeplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@

OPTS = "opts" + TUBEPLAYER;

//
//
//
// TubePlayer package
// TubePlayer package
//
//
var TP = {

inited: false, // tubeplayer inited flag - for destroy/re-init

ytplayers: {}, // all the instances that exist

inits: [], // local init functions for multiple iframe players

iframeScriptInited: false, // no need to import the iframe script multiple times

State: {
State: {
'UNSTARTED': -1,
'ENDED': 0,
'PLAYING': 1,
'PAUSED': 2,
'BUFFERING': 3,
'CUED': 5
},

Error: {
'BAD_INIT': 0,
'INVALID_PARAM': 2,
'NOT_FOUND': 100,
'NOT_EMBEDDABLE': 101,
'CANT_PLAY': 150
}

};

//
Expand All @@ -54,11 +54,11 @@
//
//
$.tubeplayer = {

events: {}, // events cache -- used by flashplayer version of video player

TubePlayer: TP // reference to the internal TubePlayer object. primarily exposed for testing.

};

/**
Expand All @@ -80,7 +80,7 @@
return function(state) {

var _player = $('#'+player).parent();

if (typeof(state) === "object") {
state = state.data;
}
Expand Down Expand Up @@ -118,7 +118,7 @@
var _ret = this.onErr;

return function(errorCode) {

var _player = $('#'+player).parent();

if (typeof(errorCode) === "object") {
Expand Down Expand Up @@ -152,7 +152,7 @@
var _this = this;

return function(suggested) {

var _player = $('#'+player).parent();

if (typeof(suggested) === "object") {
Expand Down Expand Up @@ -267,58 +267,15 @@
if (arguments.length === 0 || type === "object") {

return $this.each(function() {
$this = $(this);
// check if the current element is an iframe and if so replace it with a div
// Mihai Ionut Vilcu - 26/Oct/2013
if($this.prop('tagName') == "IFRAME") {
// make sure we have a valid YT url
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;

var match = $this.attr('src').match(regExp);

if (match&&match[7].length==11) { // we have the id

var settings = {initialVideo : match[7]},
class_name = $this.attr('class'),
ids = $this.attr('id');

// check for extra settings
if($this.attr('width'))
settings.width = $this.attr('width');

if($this.attr('height'))
settings.height = $this.attr('height');

if($this.attr('allowfullscreen') != undefined)
settings.allowFullScreen = "true";
else
settings.allowFullScreen = false;

var newDiv = $("<div></div>").attr({
'class' : class_name ? class_name : '',
'id' : ids ? ids : '',
});
TP.init($(this), input);

$this.replaceWith(newDiv);

var new_input = $.extend({}, defaults, settings, input);

TP.init(newDiv, new_input);

}

} else {

TP.init($(this), input);
}
});

} else if (type === "string") {

return $this.each(function(index, el) { // handle multiple elemnts
$(this).triggerHandler(input + TUBEPLAYER, (typeof xtra !== 'undefined' ? xtra : null));
});

return $this.triggerHandler(input + TUBEPLAYER, (typeof xtra !== 'undefined' ? xtra : null));

}

};
Expand Down Expand Up @@ -629,9 +586,9 @@
TP.init_flash_player = function(o) {

return function() {

if(!window.swfobject){
// no swfobject
// no swfobject
alert("YouTube Player couldn't be initialized. Please include swfobject.");
return;
}
Expand Down Expand Up @@ -718,11 +675,11 @@
* All the events that are bound to a TubePlayer instance
*/
var PLAYER = {

opts: wrap_fn(function(evt,param,p){

return p.opts;

}),

cue: wrap_fn(function(evt, param, p) {
Expand Down Expand Up @@ -812,7 +769,7 @@
} else {

return p.ytplayer.getVolume() || 0; // 0 because iframe's currently in labs

}

}),
Expand All @@ -824,13 +781,13 @@
else return p.ytplayer.getPlaybackQuality();

}),

playbackRate: wrap_fn(function(evt, param, p){

if(typeof param !== "undefined") p.ytplayer.setPlaybackRate(param);

else return p.ytplayer.getPlaybackRate();

}),

data: wrap_fn(function(evt, param, p) {
Expand Down Expand Up @@ -860,7 +817,7 @@
ret.videoID = TP.getVideoIDFromURL(ret.videoURL);

ret.availableQualityLevels = P.getAvailableQualityLevels();

ret.availablePlaybackRates = P.getAvailablePlaybackRates();

return ret;
Expand All @@ -886,7 +843,7 @@
}),

destroy: wrap_fn(function(evt, param, p) {

p.$player.removeClass(TUBEPLAYER_CLASS).data(OPTS, null).unbind(TUBEPLAYER).html("");

delete TP.ytplayers[p.opts.playerID];
Expand Down
File renamed without changes.

0 comments on commit 866af46

Please sign in to comment.