|
24 | 24 | } |
25 | 25 | // ,onVideoInitialized : function(base){} |
26 | 26 | }; |
27 | | - |
28 | 27 |
|
29 | 28 | return this.each(function(){ |
30 | 29 | // make sure a AnythingSlider is attached |
31 | | - var video, tmp, service, sel, base = $(this).data('AnythingSlider'); |
| 30 | + var video, tmp, service, sel, panel, |
| 31 | + base = $(this).data('AnythingSlider'); |
32 | 32 | if (!base) { return; } |
33 | | - //if anythingSliderVideo was initialized before, don't overwrite it |
| 33 | + // if anythingSliderVideo was initialized before, don't overwrite it |
34 | 34 | if(typeof base.video == 'undefined'){ |
35 | 35 | video = base.video = {}; |
36 | | - // Next update, I may just force users to call the video extension instead of it auto-running on window load |
37 | | - // then they can change the video options in that call instead of the base defaults, and maybe prevent the |
38 | | - // videos being initialized twice on startup (once as a regular video and second time with the API string) |
39 | 36 | video.options = $.extend({}, defaults, options); |
40 | | - |
| 37 | + |
41 | 38 | // check if SWFObject is loaded |
42 | 39 | video.hasSwfo = (typeof(swfobject) !== 'undefined' && swfobject.hasOwnProperty('embedSWF') && typeof(swfobject.embedSWF) === 'function' && swfobject.hasFlashPlayerVersion('1')); |
43 | 40 | video.list = {}; |
|
51 | 48 | video = base.video; |
52 | 49 | video.$items = base.$items.filter(':not(.cloned)'); |
53 | 50 | } |
54 | | - |
| 51 | + |
55 | 52 | // find and save all known videos |
56 | 53 | for (service in video.services) { /*jshint loopfunc:true */ |
57 | 54 | if (typeof(service) === 'string') { |
58 | 55 | sel = video.services[service].selector; |
59 | 56 | video.$items.find(sel).each(function(){ |
60 | 57 | tmp = $(this); |
61 | | - var pan = tmp.closest('.panel'); |
62 | | - if(pan.data('AnythingSliderVideoInitialized') != true){ |
| 58 | + panel = tmp.closest('.panel'); |
| 59 | + if (panel.data('AnythingSliderVideoInitialized') != true){ |
63 | 60 | // save panel and video selector in the list |
64 | 61 | tmp.attr('id', video.options.videoId + $.fn.anythingSliderVideo.videoIndex); |
65 | 62 | video.list[$.fn.anythingSliderVideo.videoIndex] = { |
66 | 63 | id : video.options.videoId + $.fn.anythingSliderVideo.videoIndex++, |
67 | | - panel : pan[0], |
| 64 | + panel : panel[0], |
68 | 65 | service : service, |
69 | 66 | selector : sel, |
70 | | - status : -1, // YouTube uses -1 to mean the video is unstarted |
71 | | - isInitialized : false, //Mark as Initialized to prevent double initialisation on adding video to slider |
| 67 | + status : -1, // YouTube uses -1 to mean the video is unstarted |
| 68 | + isInitialized : false, // Mark as Initialized to prevent double initialisation on adding video to slider |
72 | 69 | }; |
73 | 70 |
|
74 | | - //add indicator that this video was already initialized |
75 | | - pan.data('AnythingSliderVideoInitialized', true); |
| 71 | + // add indicator that this video was already initialized |
| 72 | + panel.data('AnythingSliderVideoInitialized', true); |
76 | 73 | video.hasVid = true; |
77 | 74 | if (sel.match('embed|object')) { |
78 | 75 | video.hasEmbed = true; |
|
84 | 81 | }); |
85 | 82 | } |
86 | 83 | } |
87 | | - |
| 84 | + |
88 | 85 | // Initialize each video, as needed |
89 | 86 | $.each(video.list, function(i,s){ |
90 | 87 | // s.id = ID, s.panel = slider panel (DOM), s.selector = 'jQuery selector' |
@@ -275,7 +272,7 @@ $.fn.anythingSliderVideo.services = { |
275 | 272 | $vid.attr('src', function(i,r){ |
276 | 273 | // initialze api and add wmode parameter |
277 | 274 | return r + (vidsrc.match(/\?/g) ? '' : '?') + '&wmode=' + (base.video.options.wmode || base.options.addWmodeToObject) + |
278 | | - '&api=1&player_id=' + $vid[0].id; |
| 275 | + '&api=1&player_id=' + $vid[0].id; |
279 | 276 | }); |
280 | 277 | }, |
281 | 278 | cont : function(base, $vid, index){ |
|
0 commit comments