JQuery - crear una galeria de video

 
Vista:
sin imagen de perfil
Val: 15
Ha mantenido su posición en JQuery (en relación al último mes)
Gráfica de JQuery

crear una galeria de video

Publicado por informatic (8 intervenciones) el 14/10/2016 03:42:24
Hola buen dia,
Quisiera realizar una galeria de videos, el cual tenga solo iframe de youtube.
Descargue desde otra web una galeria de imagenes y me gusto bastante y quisiera esta misma transformarla a una galeria de video. Pero me encuentro estancado en la parte de jquery y javascript. A ver si me pueden ayudar.
Este codigo ya lo he modificado

videos.php

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
<section>
    <div>
        <h2>Imágenes preseleccionadas</h2>
        <h3>Evento: Numero X</h3>
    </div>
 
    <ul class="uls" id="gallery">
        <li id="fullPreview"></li>
        <li>
            <a href="https://www.youtube.com/embed/NCtzkaL2t_Y"></a>
           <!-- <img data-original="img/fotos/foto.jpg" src="img/effects/white.gif" width="240" height="150" alt="Ocean" /> -->
           <iframe data-original="https://www.youtube.com/embed/NCtzkaL2t_Y" src="img/effects/white.gif" width="240" height="150" frameborder="0" allowfullscreen ></iframe>
 
            <div class="overLayer"></div>
            <div class="infoLayer">
                <ul>
                    <li>
                        <h2 class="h2s">
                            Galería
                        </h2>
                    </li>
                    <li>
                        <p class="par">
                            Videos
                        </p>
                    </li>
                </ul>
            </div>
 
            <div class="projectInfo">
                <strong>
                    Day, Month, Year:
                </strong> sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
            </div>
        </li>
    </ul>
</section>
 
$(document).ready(function(){
    $('#gallery').leastvid();
});

leastvid.min.css

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
*{
	border:0;margin:0;padding:0;outline:0
}
 
.uls{
	list-style:none
}
.h2s{
	font-family:Arvo,Arial,sans-serif;
	font-size:30px;
	line-height:25px;
	font-weight:500;
	text-transform:uppercase;
	color:#fff;
	letter-spacing:1px;
}
.par{
	font-family:Georgia,Arial,sans-serif;
	font-size:15px;
	line-height:15px;
	font-weight:100;
	color:#fff;
}
section{
	min-width: 100%;
	width:100%;
	min-height:100%;
	text-align:center;
	padding:30px 0;
	margin-bottom:30px;background-color:#333;
	box-shadow:0 0 10px;
}
 
section div h2{
	color: #fff;
	text-align: left;
	margin-left: 35px;
	font-size: 23px;
}
 
section div h3{
	color: #fff;
	text-align: left;
	margin-left: 35px;
	font-size: 18px;
}
 
 
section #fullPreview{
	background-color:#333;
	border-top:2px solid #333;
	border-bottom:2px solid #333;
	padding:50px 0 30px 0;
	display:none;
}
section #fullPreview iframe,section #fullPreview .fullCaption{
	max-width:960px;
	width:70%;
	margin:0 auto;
	display:block;
}
section #fullPreview .fullCaption{
	font-family:Helvetica,Arial,sans-serif;
	font-size:13px;
	line-height:15px;
	font-weight:300;
	color:#fff;
	margin:15px auto 0 auto;
}
section #fullPreview figure{
	background-image:url("../img/effects/close.png");
	background-size:100%;
	width:30px;
	height:30px;
	position:absolute;
	top:10px;right:20px;
	cursor:pointer;
}
section li{
	display:inline-block;
	vertical-align:top;
	position:relative;
	margin-left: 1px;
}
section li:hover .overLayer{
	-webkit-transition:opacity 0.3s linear;
	-moz-transition:opacity 0.3s linear;
	-ms-transition:opacity 0.3s linear;
	-o-transition:opacity 0.3s linear;
	transition:opacity 0.3s linear;
	opacity:0.6;
	display:block;
	background:gray;
}
section li:hover .infoLayer{
	-webkit-transition:opacity 0.3s linear;
	-moz-transition:opacity 0.3s linear;
	-ms-transition:opacity 0.3s linear;
	-o-transition:opacity 0.3s linear;
	transition:opacity 0.3s linear;
	opacity:1;
	display:block;
}
section li a{
	display:block;
	width:240px;
	height:150px;
	position:absolute;
	top:10px;
	left:0;
	z-index:6;
}
section li iframe{
	border:none;
	margin:10px 10px 0 0;
}
section li .overLayer,section li .infoLayer{
	-webkit-transition:opacity 0.3s linear;
	-moz-transition:opacity 0.3s linear;
	-ms-transition:opacity 0.3s linear;
	-o-transition:opacity 0.3s linear;
	transition:opacity 0.3s linear;
	width:240px;height:150px;
	position:absolute;
	text-align:center;
	opacity:0;top:10px;
	left:0;z-index:4;
}
section li .overLayer ul,section li .infoLayer ul{
	padding:50px 0 0 0;
}
section li .overLayer ul li,section li .infoLayer ul li{
	display:block;
	margin:0 auto;
	width:200px;
	padding:0 0 5px 0;
}
section li .overLayer ul li:first-child,section li .infoLayer ul li:first-child{
	border-bottom:2px #fff solid;
}
section li .overLayer ul li:last-child,section li .infoLayer ul li:last-child{
	padding:5px 0 0 0;
	text-transform:lowercase;
}
section li .overLayer ul li h2,section li .infoLayer ul li h2{
	font-size:25px;
}
section li .projectInfo{
	display:none;
}

leastvid.min.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
$(function(){
function e(e,t,n){
	var r=$('<figure class="close"></figure>'),
	i=$('<iframe src="'+t+'"></iframe>');
	i.load(function(){
		e.html('<div class="fullCaption">'+n+"</div>").prepend(i).append(r).slideDown("slow")});
	r.on("click",function(){$("#fullPreview").slideToggle("slow")})}
 
	$("iframe").lazyloadvid({effect:"fadeIn"});
 
	$("#gallery li a").click(function(t){
		t.preventDefault();
		var n=$(this),
		r=n.attr("href"),i=$("#fullPreview"),
		s=i.children("iframe"),
		o=n.nextAll(".projectInfo").html()||"";
		if(s.length&&r===s.attr("src")){i.slideToggle("slow");
		return}s.length?i.slideUp("slow",function(){
			e(i,r,o)}):e(i,r,o);
		$("html, body").animate({scrollTop:0},500)});
	$("#gallery").each(function(){
		var e=$(this),t=e.children("li").not(":first-child");
		t.sort(function(){
			var e=parseInt(Math.random()*8,null),
			t=e%4,n=e>2?1:-1;return t*n
		}).appendTo(e)
	})
});

jquery.lazyloadvid.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
(function($, window) {
 
    $window = $(window);
 
    $.fn.lazyloadvid = function(options) {
        var elements = this;
        var settings = {
            threshold       : 0,
            failure_limit   : 0,
            event           : "scroll",
            effect          : "show",
            container       : window,
            data_attribute  : "original",
            skip_invisible  : true,
            appear          : null,
            load            : null
        };
 
        function update() {
            var counter = 0;
 
            elements.each(function() {
                var $this = $(this);
                if (settings.skip_invisible && !$this.is(":visible")) {
                    return;
                }
                if ($.abovethetop(this, settings) ||
                    $.leftofbegin(this, settings)) {
                        /* Nothing. */
                } else if (!$.belowthefold(this, settings) &&
                    !$.rightoffold(this, settings)) {
                        $this.trigger("appear");
                } else {
                    if (++counter > settings.failure_limit) {
                        return false;
                    }
                }
            });
 
        }
 
        if(options) {
            /* Maintain BC for a couple of versions. */
            if (undefined !== options.failurelimit) {
                options.failure_limit = options.failurelimit;
                delete options.failurelimit;
            }
            if (undefined !== options.effectspeed) {
                options.effect_speed = options.effectspeed;
                delete options.effectspeed;
            }
 
            $.extend(settings, options);
        }
 
        /* Cache container as jQuery as object. */
        $container = (settings.container === undefined ||
                      settings.container === window) ? $window : $(settings.container);
 
        /* Fire one scroll event per scroll. Not one scroll event per image. */
        if (0 === settings.event.indexOf("scroll")) {
            $container.bind(settings.event, function(event) {
                return update();
            });
        }
 
        this.each(function() {
            var self = this;
            var $self = $(self);
 
            self.loaded = false;
 
            /* When appear is triggered load original image. */
            $self.one("appear", function() {
                if (!this.loaded) {
                    if (settings.appear) {
                        var elements_left = elements.length;
                        settings.appear.call(self, elements_left, settings);
                    }
                    $("<iframe />")
                        .bind("load", function() {
                            $self
                                .hide()
                                .attr("src", $self.data(settings.data_attribute))
                                [settings.effect](settings.effect_speed);
                            self.loaded = true;
 
                            /* Remove image from array so it is not looped next time. */
                            var temp = $.grep(elements, function(element) {
                                return !element.loaded;
                            });
                            elements = $(temp);
 
                            if (settings.load) {
                                var elements_left = elements.length;
                                settings.load.call(self, elements_left, settings);
                            }
                        })
                        .attr("src", $self.data(settings.data_attribute));
                }
            });
 
            /* When wanted event is triggered load original image */
            /* by triggering appear.                              */
            if (0 !== settings.event.indexOf("scroll")) {
                $self.bind(settings.event, function(event) {
                    if (!self.loaded) {
                        $self.trigger("appear");
                    }
                });
            }
        });
 
        /* Check if something appears when window is resized. */
        $window.bind("resize", function(event) {
            update();
        });
 
        /* Force initial check if images should appear. */
        update();
 
        return this;
    };
 
    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */
 
    $.belowthefold = function(element, settings) {
        var fold;
 
        if (settings.container === undefined || settings.container === window) {
            fold = $window.height() + $window.scrollTop();
        } else {
            fold = $container.offset().top + $container.height();
        }
 
        return fold <= $(element).offset().top - settings.threshold;
    };
 
    $.rightoffold = function(element, settings) {
        var fold;
 
        if (settings.container === undefined || settings.container === window) {
            fold = $window.width() + $window.scrollLeft();
        } else {
            fold = $container.offset().left + $container.width();
        }
 
        return fold <= $(element).offset().left - settings.threshold;
    };
 
    $.abovethetop = function(element, settings) {
        var fold;
 
        if (settings.container === undefined || settings.container === window) {
            fold = $window.scrollTop();
        } else {
            fold = $container.offset().top;
        }
 
        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };
 
    $.leftofbegin = function(element, settings) {
        var fold;
 
        if (settings.container === undefined || settings.container === window) {
            fold = $window.scrollLeft();
        } else {
            fold = $container.offset().left;
        }
 
        return fold >= $(element).offset().left + settings.threshold + $(element).width();
    };
 
    $.inviewport = function(element, settings) {
         return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) &&
                !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
     };
 
    /* Custom selectors for your convenience.   */
    /* Use as $("img:below-the-fold").something() */
 
    $.extend($.expr[':'], {
        "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0, container: window}); },
        "above-the-top"  : function(a) { return !$.belowthefold(a, {threshold : 0, container: window}); },
        "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0, container: window}); },
        "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0, container: window}); },
        "in-viewport"    : function(a) { return !$.inviewport(a, {threshold : 0, container: window}); },
        /* Maintain BC for couple of versions. */
        "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0, container: window}); },
        "right-of-fold"  : function(a) { return $.rightoffold(a, {threshold : 0, container: window}); },
        "left-of-fold"   : function(a) { return !$.rightoffold(a, {threshold : 0, container: window}); }
    });
 
})(jQuery, window);

Si alguien pudiera ayudarme a que en ves de img sea iframes
adjunto los archivos originales
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder