@@ 3831-3916 (lines=86) @@ | ||
3828 | ||
3829 | })(UIkit2); |
|
3830 | ||
3831 | (function(UI){ |
|
3832 | ||
3833 | "use strict"; |
|
3834 | ||
3835 | UI.component('cover', { |
|
3836 | ||
3837 | defaults: { |
|
3838 | automute : true |
|
3839 | }, |
|
3840 | ||
3841 | boot: function() { |
|
3842 | ||
3843 | // auto init |
|
3844 | UI.ready(function(context) { |
|
3845 | ||
3846 | UI.$('[data-uk-cover]', context).each(function(){ |
|
3847 | ||
3848 | var ele = UI.$(this); |
|
3849 | ||
3850 | if(!ele.data('cover')) { |
|
3851 | var plugin = UI.cover(ele, UI.Utils.options(ele.attr('data-uk-cover'))); |
|
3852 | } |
|
3853 | }); |
|
3854 | }); |
|
3855 | }, |
|
3856 | ||
3857 | init: function() { |
|
3858 | ||
3859 | this.parent = this.element.parent(); |
|
3860 | ||
3861 | UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){ |
|
3862 | this.check(); |
|
3863 | }.bind(this), 100)); |
|
3864 | ||
3865 | this.on('display.uk.check', function(e) { |
|
3866 | if (this.element.is(':visible')) this.check(); |
|
3867 | }.bind(this)); |
|
3868 | ||
3869 | this.check(); |
|
3870 | ||
3871 | if (this.element.is('iframe') && this.options.automute) { |
|
3872 | ||
3873 | var src = this.element.attr('src'); |
|
3874 | ||
3875 | this.element.attr('src', '').on('load', function(){ |
|
3876 | this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*'); |
|
3877 | }).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join('')); |
|
3878 | } |
|
3879 | }, |
|
3880 | ||
3881 | check: function() { |
|
3882 | ||
3883 | this.element.css({ width : '', height : '' }); |
|
3884 | ||
3885 | this.dimension = {w: this.element.width(), h: this.element.height()}; |
|
3886 | ||
3887 | if (this.element.attr('width') && !isNaN(this.element.attr('width'))) { |
|
3888 | this.dimension.w = this.element.attr('width'); |
|
3889 | } |
|
3890 | ||
3891 | if (this.element.attr('height') && !isNaN(this.element.attr('height'))) { |
|
3892 | this.dimension.h = this.element.attr('height'); |
|
3893 | } |
|
3894 | ||
3895 | this.ratio = this.dimension.w / this.dimension.h; |
|
3896 | ||
3897 | var w = this.parent.width(), h = this.parent.height(), width, height; |
|
3898 | ||
3899 | // if element height < parent height (gap underneath) |
|
3900 | if ((w / this.ratio) < h) { |
|
3901 | ||
3902 | width = Math.ceil(h * this.ratio); |
|
3903 | height = h; |
|
3904 | ||
3905 | // element width < parent width (gap to right) |
|
3906 | } else { |
|
3907 | ||
3908 | width = w; |
|
3909 | height = Math.ceil(w / this.ratio); |
|
3910 | } |
|
3911 | ||
3912 | this.element.css({ width : width, height : height }); |
|
3913 | } |
|
3914 | }); |
|
3915 | ||
3916 | })(UIkit2); |
|
3917 |
@@ 2-87 (lines=86) @@ | ||
1 | /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ |
|
2 | (function(UI){ |
|
3 | ||
4 | "use strict"; |
|
5 | ||
6 | UI.component('cover', { |
|
7 | ||
8 | defaults: { |
|
9 | automute : true |
|
10 | }, |
|
11 | ||
12 | boot: function() { |
|
13 | ||
14 | // auto init |
|
15 | UI.ready(function(context) { |
|
16 | ||
17 | UI.$('[data-uk-cover]', context).each(function(){ |
|
18 | ||
19 | var ele = UI.$(this); |
|
20 | ||
21 | if(!ele.data('cover')) { |
|
22 | var plugin = UI.cover(ele, UI.Utils.options(ele.attr('data-uk-cover'))); |
|
23 | } |
|
24 | }); |
|
25 | }); |
|
26 | }, |
|
27 | ||
28 | init: function() { |
|
29 | ||
30 | this.parent = this.element.parent(); |
|
31 | ||
32 | UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){ |
|
33 | this.check(); |
|
34 | }.bind(this), 100)); |
|
35 | ||
36 | this.on('display.uk.check', function(e) { |
|
37 | if (this.element.is(':visible')) this.check(); |
|
38 | }.bind(this)); |
|
39 | ||
40 | this.check(); |
|
41 | ||
42 | if (this.element.is('iframe') && this.options.automute) { |
|
43 | ||
44 | var src = this.element.attr('src'); |
|
45 | ||
46 | this.element.attr('src', '').on('load', function(){ |
|
47 | this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*'); |
|
48 | }).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join('')); |
|
49 | } |
|
50 | }, |
|
51 | ||
52 | check: function() { |
|
53 | ||
54 | this.element.css({ width : '', height : '' }); |
|
55 | ||
56 | this.dimension = {w: this.element.width(), h: this.element.height()}; |
|
57 | ||
58 | if (this.element.attr('width') && !isNaN(this.element.attr('width'))) { |
|
59 | this.dimension.w = this.element.attr('width'); |
|
60 | } |
|
61 | ||
62 | if (this.element.attr('height') && !isNaN(this.element.attr('height'))) { |
|
63 | this.dimension.h = this.element.attr('height'); |
|
64 | } |
|
65 | ||
66 | this.ratio = this.dimension.w / this.dimension.h; |
|
67 | ||
68 | var w = this.parent.width(), h = this.parent.height(), width, height; |
|
69 | ||
70 | // if element height < parent height (gap underneath) |
|
71 | if ((w / this.ratio) < h) { |
|
72 | ||
73 | width = Math.ceil(h * this.ratio); |
|
74 | height = h; |
|
75 | ||
76 | // element width < parent width (gap to right) |
|
77 | } else { |
|
78 | ||
79 | width = w; |
|
80 | height = Math.ceil(w / this.ratio); |
|
81 | } |
|
82 | ||
83 | this.element.css({ width : width, height : height }); |
|
84 | } |
|
85 | }); |
|
86 | ||
87 | })(UIkit2); |
|
88 |