-
Notifications
You must be signed in to change notification settings - Fork 34
/
jquery.fs.wallpaper.js
894 lines (763 loc) · 21.7 KB
/
jquery.fs.wallpaper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
/*
* Wallpaper v3.1.19 - 2015-04-04
* A jQuery plugin for smooth-scaling image and video backgrounds. Part of the Formstone Library.
* http://classic.formstone.it/wallpaper/
*
* Copyright 2015 Ben Plum; MIT Licensed
*/
;(function ($, window) {
"use strict";
var $window = $(window),
$body,
$responders = null,
nativeSupport = ("backgroundSize" in document.documentElement.style),
guid = 0,
youTubeReady = false,
youTubeQueue = [],
UA = (window.navigator.userAgent||window.navigator.vendor||window.opera),
isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(UA),
isSafari = (UA.toLowerCase().indexOf('safari') >= 0) && (UA.toLowerCase().indexOf('chrome') < 0),
transitionEvent,
transitionSupported,
respondTimer;
/**
* @options
* @param autoPlay [boolean] <true> "Autoplay video"
* @param embedRatio [number] <1.777777> "Video / embed ratio (16/9)"
* @param hoverPlay [boolean] <false> "Play video on hover"
* @param loop [boolean] <true> "Loop video"
* @param mute [boolean] <true> "Mute video"
* @param onLoad [function] <$.noop> "On load callback"
* @param onReady [function] <$.noop> "On ready callback"
* @param source [string | object] <null> "Source image (string or object) or video (object) or YouTube (object)"
*/
var options = {
autoPlay: true,
embedRatio: 1.777777,
hoverPlay: false,
loop: true,
mute: true,
onLoad: $.noop,
onReady: $.noop,
source: null
};
/**
* @events
* @event wallpaper.loaded "Source media loaded"
*/
var pub = {
/**
* @method
* @name defaults
* @description Sets default plugin options
* @param opts [object] <{}> "Options object"
* @example $.wallpaper("defaults", opts);
*/
defaults: function(opts) {
options = $.extend(options, opts || {});
return (typeof this === 'object') ? $(this) : true;
},
/**
* @method
* @name destroy
* @description Removes instance of plugin
* @example $(".target").wallpaper("destroy");
*/
destroy: function() {
var $targets = $(this).each(function() {
var data = $(this).data("wallpaper");
if (data) {
data.$container.remove();
data.$target.removeClass("wallpaper")
.off(".boxer")
.data("wallpaper", null);
}
});
if (typeof $body !== "undefined" && typeof $window !== "undefined" && $(".wallpaper").length < 1) {
$body.removeClass("wallpaper-inititalized");
$window.off(".wallpaper");
}
return $targets;
},
/**
* @method
* @name load
* @description Loads source media
* @param source [string | object] "Source image (string) or video (object) or YouTube (object); { source: { poster: <"">, video: <"" or {}> } }"
* @example $(".target").wallpaper("load", "path/to/image.jpg");
*/
load: function(source) {
return $(this).each(function() {
var data = $(this).data("wallpaper");
if (data) {
_loadMedia(source, data);
}
});
},
/**
* @method
* @name pause
* @description Pauses target video
* @example $(".target").wallpaper("stop");
*/
pause: function() {
return $(this).each(function() {
var data = $(this).data("wallpaper");
if (data) {
if (data.isYouTube && data.playerReady) {
data.player.pauseVideo();
} else {
var $video = data.$container.find("video");
if ($video.length) {
$video[0].pause();
}
}
}
});
},
/**
* @method
* @name play
* @description Plays target video
* @example $(".target").wallpaper("play");
*/
play: function() {
return $(this).each(function() {
var data = $(this).data("wallpaper");
if (data) {
if (data.isYouTube && data.playerReady) {
data.player.playVideo();
} else {
var $video = data.$container.find("video");
if ($video.length) {
$video[0].play();
}
}
}
});
},
/**
* @method private
* @name stop
* @description Deprecated; Aliased to "pause"
* @example $(".target").wallpaper("stop");
*/
stop: function() {
pub.pause.apply(this);
},
/**
* @method
* @name unload
* @description Unloads current media
* @example $(".target").wallpaper("unload");
*/
unload: function() {
return $(this).each(function() {
var data = $(this).data("wallpaper");
if (data) {
_unloadMedia(data);
}
});
}
};
/**
* @method private
* @name _init
* @description Initializes plugin instances
* @param opts [object] "Initialization options"
*/
function _init(opts) {
var data = $.extend({}, options, opts);
$body = $("body");
transitionEvent = _getTransitionEvent();
transitionSupported = (transitionEvent !== false);
// no transitions :(
if (!transitionSupported) {
transitionEvent = "transitionend.wallpaper";
}
// Apply to each
var $targets = $(this);
for (var i = 0, count = $targets.length; i < count; i++) {
_build.apply($targets.eq(i), [ $.extend({}, data) ]);
}
// Global events
if (!$body.hasClass("wallpaper-inititalized")) {
$body.addClass("wallpaper-inititalized");
$window.on("resize.wallpaper", data, _onResizeAll);
}
// Maintain chainability
return $targets;
}
/**
* @method private
* @name _build
* @description Builds each instance
* @param data [object] "Instance data"
*/
function _build(data) {
var $target = $(this);
if (!$target.hasClass("wallpaper")) {
$.extend(data, $target.data("wallpaper-options"));
$target.addClass("wallpaper")
.append('<div class="wallpaper-container"></div>');
data.guid = "wallpaper-" + (guid++);
data.youTubeGuid = 0;
data.$target = $target;
data.$container = data.$target.find(".wallpaper-container");
// Bind data & events
data.$target.data("wallpaper", data)
.on("resize.wallpaper", data, _onResize);
var source = data.source;
data.source = null;
_loadMedia(source, data, true);
data.onReady.call();
}
}
/**
* @method private
* @name _loadMedia
* @description Determines how to handle source media
* @param source [string | object] "Source image (string) or video (object)"
* @param data [object] "Instance data"
* @param firstLoad [boolean] "Flag for first load"
*/
function _loadMedia(source, data, firstLoad) {
// Check if the source is new
if (source !== data.source) {
data.source = source;
data.isYouTube = false;
// Check YouTube
if (typeof source === "object" && typeof source.video === "string") {
// var parts = source.match( /^.*(?:youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#\&\?]*).*/ );
var parts = source.video.match( /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i );
if (parts && parts.length >= 1) {
data.isYouTube = true;
data.videoId = parts[1];
}
}
if (data.isYouTube) {
// youtube video
data.playing = false;
data.playerReady = false;
data.posterLoaded = false;
_loadYouTube(source, data, firstLoad);
} else if (typeof source === "object" && !source.hasOwnProperty("fallback")) {
// html5 video
_loadVideo(source, data, firstLoad);
} else {
// regular old image
if (data.responsiveSource) {
for (var i in data.responsiveSource) {
if (data.responsiveSource.hasOwnProperty(i)) {
data.responsiveSource[i].mq.removeListener(_onRespond);
}
}
}
data.responsive = false;
data.responsiveSource = null;
// Responsive image handling
if (typeof source === "object") {
var sources = [],
newSource;
for (var j in source) {
if (source.hasOwnProperty(j)) {
var media = (j === "fallback") ? "(min-width: 0px)" : j;
if (media) {
var _mq = window.matchMedia(media.replace(Infinity, "100000px"));
_mq.addListener(_onRespond);
sources.push({
mq: _mq,
source: source[j]
});
if (_mq.matches) {
newSource = source[j];
}
}
}
}
data.responsive = true;
data.responsiveSource = sources;
source = newSource;
}
// single or responsive set
_loadImage(source, data, false, firstLoad);
}
} else {
data.$target.trigger("wallpaper.loaded");
data.onLoad.call(data.$target);
}
}
/**
* @method private
* @name _loadImage
* @description Loads source image
* @param source [string] "Source image"
* @param data [object] "Instance data",
* @param poster [boolean] "Flag for video poster"
*/
function _loadImage(source, data, poster, firstLoad) {
var $imgContainer = $('<div class="wallpaper-media wallpaper-image' + ((firstLoad !== true) ? ' animated' : '') + '"><img alt="" /></div>'),
$img = $imgContainer.find("img"),
newSource = source;
// Load image
$img.one("load.wallpaper", function() {
if (nativeSupport) {
$imgContainer.addClass("native")
.css({ backgroundImage: "url('" + newSource + "')" });
}
// Append
$imgContainer.on(transitionEvent, function(e) {
_killEvent(e);
if ($(e.target).is($imgContainer)) {
$imgContainer.off(transitionEvent);
if (!poster) {
_cleanMedia(data);
}
}
});
setTimeout( function() {
$imgContainer.css({ opacity: 1 });
if (data.responsive && firstLoad) {
_cleanMedia(data);
}
}, 0);
// Resize
_onResize({ data: data });
if (!poster || firstLoad) {
data.$target.trigger("wallpaper.loaded");
data.onLoad.call(data.$target);
}
// caches responsive images
$responders = $(".wallpaper-responsive");
}).attr("src", newSource);
if (data.responsive) {
$imgContainer.addClass("wallpaper-responsive");
}
data.$container.append($imgContainer);
// Check if image is cached
if ($img[0].complete || $img[0].readyState === 4) {
$img.trigger("load.wallpaper");
}
}
/**
* @method private
* @name _loadVideo
* @description Loads source video
* @param source [object] "Source video"
* @param data [object] "Instance data"
*/
function _loadVideo(source, data, firstLoad) {
if (data.source.poster) {
_loadImage(data.source.poster, data, true, true);
firstLoad = false;
}
if (!isMobile) {
var html = '<div class="wallpaper-media wallpaper-video' + ((firstLoad !== true) ? ' animated' : '') +'">';
html += '<video';
if (data.loop) {
html += ' loop';
}
if (data.mute) {
html += ' muted';
}
html += '>';
if (data.source.webm) {
html += '<source src="' + data.source.webm + '" type="video/webm" />';
}
if (data.source.mp4) {
html += '<source src="' + data.source.mp4 + '" type="video/mp4" />';
}
if (data.source.ogg) {
html += '<source src="' + data.source.ogg + '" type="video/ogg" />';
}
html += '</video>';
html += '</div>';
var $videoContainer = $(html),
$video = $videoContainer.find("video");
$video.one("loadedmetadata.wallpaper", function(e) {
$videoContainer.on(transitionEvent, function(e) {
_killEvent(e);
if ($(e.target).is($videoContainer)) {
$videoContainer.off(transitionEvent);
_cleanMedia(data);
}
});
setTimeout( function() { $videoContainer.css({ opacity: 1 }); }, 0);
// Resize
_onResize({ data: data });
data.$target.trigger("wallpaper.loaded");
data.onLoad.call(data.$target);
// Events
if (data.hoverPlay) {
data.$target.on("mouseover.boxer", pub.play)
.on("mouseout.boxer", pub.pause);
} else if (data.autoPlay) {
this.play();
}
});
data.$container.append($videoContainer);
}
}
/**
* @method private
* @name _loadYouTube
* @description Loads YouTube video
* @param source [string] "YouTube URL"
* @param data [object] "Instance data"
*/
function _loadYouTube(source, data, firstLoad) {
if (!data.videoId) {
var parts = source.match( /^.*(?:youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#\&\?]*).*/ );
data.videoId = parts[1];
}
if (!data.posterLoaded) {
if (!data.source.poster) {
// data.source.poster = "http://img.youtube.com/vi/" + data.videoId + "/maxresdefault.jpg";
data.source.poster = "http://img.youtube.com/vi/" + data.videoId + "/0.jpg";
}
data.posterLoaded = true;
_loadImage(data.source.poster, data, true, firstLoad);
firstLoad = false;
}
if (!isMobile) {
if (!$("script[src*='youtube.com/iframe_api']").length) {
// $("head").append('<script src="' + window.location.protocol + '//www.youtube.com/iframe_api"></script>');
$("head").append('<script src="//www.youtube.com/iframe_api"></script>');
}
if (!youTubeReady) {
youTubeQueue.push({
source: source,
data: data
});
} else {
var guid = data.guid + "_" + (data.youTubeGuid++),
html = '';
html += '<div class="wallpaper-media wallpaper-embed' + ((firstLoad !== true) ? ' animated' : '') + '">';
html += '<div id="' + guid + '"></div>';
html += '</div>';
var $embedContainer = $(html);
data.$container.append($embedContainer);
if (data.player) {
data.oldPlayer = data.player;
data.player = null;
}
data.player = new window.YT.Player(guid, {
videoId: data.videoId,
playerVars: {
controls: 0,
rel: 0,
showinfo: 0,
wmode: "transparent",
enablejsapi: 1,
version: 3,
playerapiid: guid,
loop: (data.loop) ? 1 : 0,
autoplay: 1,
origin: window.location.protocol + "//" + window.location.host
},
events: {
onReady: function (e) {
/* console.log("onReady", e); */
data.playerReady = true;
/* data.player.setPlaybackQuality("highres"); */
if (data.mute) {
data.player.mute();
}
if (data.hoverPlay) {
data.$target.on("mouseover.boxer", pub.play)
.on("mouseout.boxer", pub.pause);
} else if (data.autoPlay) {
// make sure the video plays
data.player.playVideo();
}
},
onStateChange: function (e) {
/* console.log("onStateChange", e); */
if (!data.playing && e.data === window.YT.PlayerState.PLAYING) {
data.playing = true;
if (data.hoverPlay || !data.autoPlay) {
data.player.pauseVideo();
}
data.$target.trigger("wallpaper.loaded");
data.onLoad.call(data.$target);
$embedContainer.on(transitionEvent, function(e) {
_killEvent(e);
if ($(e.target).is($embedContainer)) {
$embedContainer.off(transitionEvent);
_cleanMedia(data);
}
});
$embedContainer.css({ opacity: 1 });
} else if (data.loop && data.playing && e.data === window.YT.PlayerState.ENDED) {
// fix looping option
data.player.playVideo();
}
/* if (!isSafari) { */
// Fix for Safari's overly secure security settings...
data.$target.find(".wallpaper-embed").addClass("ready");
/* } */
},
onPlaybackQualityChange: function(e) {
/* console.log("onPlaybackQualityChange", e); */
},
onPlaybackRateChange: function(e) {
/* console.log("onPlaybackRateChange", e); */
},
onError: function(e) {
/* console.log("onError", e); */
},
onApiChange: function(e) {
/* console.log("onApiChange", e); */
}
}
});
// Resize
_onResize({ data: data });
}
}
}
/**
* @method private
* @name _cleanMedia
* @description Cleans up old media
* @param data [object] "Instance data"
*/
function _cleanMedia(data) {
var $mediaContainer = data.$container.find(".wallpaper-media");
if ($mediaContainer.length >= 1) {
$mediaContainer.not(":last").remove();
data.oldPlayer = null;
}
$responders = $(".wallpaper-responsive");
}
/**
* @method private
* @name _uploadMedia
* @description Unloads current media
* @param data [object] "Instance data"
*/
function _unloadMedia(data) {
var $mediaContainer = data.$container.find(".wallpaper-media");
if ($mediaContainer.length >= 1) {
$mediaContainer.on(transitionEvent, function(e) {
_killEvent(e);
if ($(e.target).is($mediaContainer)) {
$(this).remove();
delete data.source;
}
}).css({ opacity: 0 });
}
}
/**
* @method private
* @name _onResize
* @description Resize target instance
* @param e [object] "Event data"
*/
function _onResize(e) {
_killEvent(e);
var data = e.data;
// Target all media
var $mediaContainers = data.$container.find(".wallpaper-media");
for (var i = 0, count = $mediaContainers.length; i < count; i++) {
var $mediaContainer = $mediaContainers.eq(i),
type = (data.isYouTube) ? "iframe" : ($mediaContainer.find("video").length ? "video" : "img"),
$media = $mediaContainer.find(type);
// If media found and scaling is not natively support
if ($media.length && !(type === "img" && data.nativeSupport)) {
var frameWidth = data.$target.outerWidth(),
frameHeight = data.$target.outerHeight(),
frameRatio = frameWidth / frameHeight,
naturalSize = _naturalSize(data, $media);
data.width = naturalSize.naturalWidth;
data.height = naturalSize.naturalHeight;
data.left = 0;
data.top = 0;
var mediaRatio = (data.isYouTube) ? data.embedRatio : (data.width / data.height);
// First check the height
data.height = frameHeight;
data.width = data.height * mediaRatio;
// Next check the width
if (data.width < frameWidth) {
data.width = frameWidth;
data.height = data.width / mediaRatio;
}
// Position the media
data.left = -(data.width - frameWidth) / 2;
data.top = -(data.height - frameHeight) / 2;
$mediaContainer.css({
height: data.height,
width: data.width,
left: data.left,
top: data.top
});
}
}
}
/**
* @method private
* @name _onResizeAll
* @description Resizes all target instances
*/
function _onResizeAll() {
$(".wallpaper").each(function() {
var data = $(this).data("wallpaper");
_onResize({ data: data });
});
}
/**
* @method private
* @name _onRespond
* @description Handle media query changes
*/
function _onRespond() {
respondTimer = _startTimer(respondTimer, 5, _doRespond);
}
/**
* @method private
* @name _doRespond
* @description Handle media query changes
*/
function _doRespond() {
_clearTimer(respondTimer);
$responders.each(function() {
var $target = $(this),
$image = $target.find("img"),
data = $target.parents(".wallpaper").data("wallpaper"),
sources = data.responsiveSource,
index = 0;
for (var i = 0, count = sources.length; i < count; i++) {
if (sources.hasOwnProperty(i)) {
var match = sources[i].mq;
if (match && match.matches) {
index = i;
}
}
}
_loadImage(sources[index].source, data, false, true);
$target.trigger("change.wallpaper");
});
}
/**
* @method private
* @name _startTimer
* @description Starts an internal timer
* @param timer [int] "Timer ID"
* @param time [int] "Time until execution"
* @param callback [int] "Function to execute"
* @param interval [boolean] "Flag for recurring interval"
*/
function _startTimer(timer, time, func, interval) {
_clearTimer(timer, interval);
return setTimeout(func, time);
}
/**
* @method private
* @name _clearTimer
* @description Clears an internal timer
* @param timer [int] "Timer ID"
*/
function _clearTimer(timer) {
if (timer !== null) {
clearInterval(timer);
timer = null;
}
}
/**
* @method private
* @name _naturalSize
* @description Determines natural size of target media
* @param data [object] "Instance data"
* @param $media [jQuery object] "Source media object"
* @return [object | boolean] "Object containing natural height and width values or false"
*/
function _naturalSize(data, $media) {
if (data.isYouTube) {
return {
naturalHeight: 500,
naturalWidth: 500 / data.embedRatio
};
} else if ($media.is("img")) {
var node = $media[0];
if (typeof node.naturalHeight !== "undefined") {
return {
naturalHeight: node.naturalHeight,
naturalWidth: node.naturalWidth
};
} else {
var img = new Image();
img.src = node.src;
return {
naturalHeight: img.height,
naturalWidth: img.width
};
}
} else {
return {
naturalHeight: $media[0].videoHeight,
naturalWidth: $media[0].videoWidth
};
}
return false;
}
/**
* @method private
* @name _killEvent
* @description Prevents default and stops propagation on event
* @param e [object] "Event data"
*/
function _killEvent(e) {
if (e.preventDefault) {
e.stopPropagation();
e.preventDefault();
}
}
/**
* @method private
* @name _getTransitionEvent
* @description Retuns a properly prefixed transitionend event
* @return [string] "Properly prefixed event"
*/
function _getTransitionEvent() {
var transitions = {
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'oTransitionEnd',
'transition': 'transitionend'
},
test = document.createElement('div');
for (var type in transitions) {
if (transitions.hasOwnProperty(type) && type in test.style) {
return transitions[type] + ".wallpaper";
}
}
return false;
}
/**
* @method global
* @name window.onYouTubeIframeAPIReady
* @description Attaches YouTube players to active instances
*/
window.onYouTubeIframeAPIReady = function() {
youTubeReady = true;
for (var i in youTubeQueue) {
if (youTubeQueue.hasOwnProperty(i)) {
_loadYouTube(youTubeQueue[i].source, youTubeQueue[i].data);
}
}
youTubeQueue = [];
};
$.fn.wallpaper = function(method) {
if (pub[method]) {
return pub[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return _init.apply(this, arguments);
}
return this;
};
$.wallpaper = function(method) {
if (method === "defaults") {
pub.defaults.apply(this, Array.prototype.slice.call(arguments, 1));
}
};
})(jQuery, window);