Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>fitVids bug on Bootstrap collapsed div</title>
- <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
- <style type="text/css" rel="stylesheet">
- body,html { margin:0; padding:0; height:100%; width:100%;}
- #wrapper {
- position: fixed; top:50px; left:0; right:0; bottom:0;
- transition: all 0.4s ease 0s;
- background-color: #8AB746;
- display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex;
- flex-direction: row;
- }
- #sidebar-wrapper {
- min-width: 300px;
- background: #000;
- overflow: hidden;
- z-index: 1000;
- transition: all 0.4s ease 0s;
- position:relative;
- resize:horizontal;
- }
- #page-content-wrapper {
- min-width:640px;
- display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex;
- flex: 1; -webkit-box-flex: 1; -moz-box-flex: 1; -webkit-flex: 1; -ms-flex: 1;
- flex-direction: column;
- position:relative;
- }
- .sidebar-nav {
- position: absolute;
- top: 0;
- width: 100%;
- list-style: none;
- margin: 0;
- padding: 0;
- }
- .content-header {
- height: 65px;
- line-height: 65px;
- }
- #menu-toggle {
- display: none;
- }
- .inset {
- padding: 20px;
- }
- @media (max-width:900px) {
- /*767*/
- #wrapper {
- padding-left: 0;
- }
- #sidebar-wrapper {
- display: none;
- }
- #wrapper.active {
- position: relative;
- left: 250px;
- }
- #wrapper.active #sidebar-wrapper {
- left: 250px;
- width: 250px;
- transition: all 0.4s ease 0s;
- }
- #menu-toggle {
- display: inline-block;
- }
- .inset {
- padding: 15px;
- }
- }
- #collapsePodcasts { width:100%; position:relative; margin-bottom:12px; min-height:250px; }
- #youtube_frame { position:absolute; top:0; left:0; width:100%; height:100%; border:0; }
- .navbar {
- background-color: #e5f7c3;
- color: #ffffff;
- font-family: arial,sans-serif;
- margin:0;
- height:50px;
- }
- .navbar li>a:hover, .navbar li>a:focus, .navbar .open, .navbar .open>a, .navbar .open>a:hover, .navbar .open>a:focus {
- background-color: #f15a25;
- color: #fff;
- }
- .navbar li > a, .navbar {
- color: #f15a25;
- }
- .navbar-brand {
- padding: 7px 10px;
- }
- .navbar-brand .logo{
- margin: 0 15px;
- }
- a:hover, a:focus {
- color: #f15a25;
- text-decoration: underline;
- }
- a {
- color: #f15a25;
- text-decoration: none;
- }
- .navbar-toggle {
- border: 1px solid rgba(241,90,37, 0.50);
- }
- .navbar-toggle .icon-bar {
- background-color: #f15a25;
- }
- #rrPlayer { padding: 10px;}
- #subnavbar { background-color: #8bb746; padding: 5px 10px; }
- #subnavbar .snb{ color: #000000; font-weight: bold; }
- #subnavbar a { color: #ffffff; }
- .subnavbar {
- background-color: #8bb746;
- color: #ffffff;
- margin-bottom: 0px;
- width: 100%;
- }
- .subnavbar li>a:hover, .navbar li>a:focus, .navbar .open, .navbar .open>a, .navbar .open>a:hover, .navbar .open>a:focus {
- background-color: #f15a25;
- color: #ffffff;
- }
- .subnavbar li > a, .subnavbar {
- color: #f15a25;
- }
- .subnavbar li>a:hover, .navbar li>a:focus, .navbar .open, .navbar .open>a, .navbar .open>a:hover, .navbar .open>a:focus {
- background-color: #f15a25;
- color: #ffffff;
- }
- .ytvideoList a { margin: 5px; display: inline-block; }
- </style>
- <script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
- <script type='text/javascript' src="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
- <script type="text/javascript">
- /************************ jquery.fitvids.js ************************/
- /*global jQuery */
- /*jshint browser:true */
- /*!
- * FitVids 1.1
- *
- * Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
- * Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
- * Released under the WTFPL license - http://sam.zoy.org/wtfpl/
- *
- */
- (function( $ ){
- "use strict";
- $.fn.fitVids = function( options ) {
- var settings = {
- customSelector: null
- };
- if(!document.getElementById('fit-vids-style')) {
- // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
- var head = document.head || document.getElementsByTagName('head')[0];
- var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
- var div = document.createElement('div');
- div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
- head.appendChild(div.childNodes[1]);
- }
- if ( options ) {
- $.extend( settings, options );
- }
- return this.each(function(){
- var selectors = [
- /*"iframe[src*='player.vimeo.com']",
- "iframe[src*='youtube.com']",
- "iframe[src*='youtube-nocookie.com']",*/
- // Tried to comment the above lines and add a selector for my div, with no success
- "#youtube_frame",
- "iframe[src*='kickstarter.com'][src*='video.html']",
- "object",
- "embed"
- ];
- if (settings.customSelector) {
- selectors.push(settings.customSelector);
- }
- var $allVideos = $(this).find(selectors.join(','));
- $allVideos = $allVideos.not("object object"); // SwfObj conflict patch
- $allVideos.each(function(){
- var $this = $(this);
- if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
- var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
- width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
- aspectRatio = height / width;
- if(!$this.attr('id')){
- var videoID = 'fitvid' + Math.floor(Math.random()*999999);
- $this.attr('id', videoID);
- }
- $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
- $this.removeAttr('height').removeAttr('width');
- });
- });
- };
- // Works with either jQuery or Zepto
- })( window.jQuery || window.Zepto );
- </script>
- </head>
- <body>
- <!-- top nav -->
- <div class="navbar navbar-fixed-top">
- <div class="navbar-header">
- <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- </div>
- <nav class="collapse navbar-collapse" role="navigation">
- <ul class="nav navbar-nav">
- <li><a href="#podcastModal" role="button" data-toggle="modal"><i class="glyphicon glyphicon-facetime-video"></i> Video</a></li>
- </ul>
- </nav>
- </div>
- <!-- /top nav -->
- <div id="wrapper">
- <!-- Sidebar -->
- <div id="sidebar-wrapper">
- <div class="sidebar-nav">
- <div id="collapsePodcasts" class="collapse">
- <iframe id="youtube_frame" name="youtube_frame" src="https://www.youtube.com/embed/Q_tAyUrfKsk?autoplay=1&autohide=2&color=white&version=3&rel=0" width="300px" height="250px" allowfullscreen></iframe>
- </div>
- <p style="color:orange; font-weight:bold; font-size:16px;margin:20px;">Fix.This.Bug</p>
- </div>
- </div>
- <!-- Page content -->
- <div id="page-content-wrapper">
- </div>
- </div>
- <div id="podcastModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
- Last Videos
- </div>
- <div class="modal-body">
- <div id="videos"> <!-- here will be loaded your videos --> </div>
- </div>
- <div class="modal-footer">
- </div>
- </div>
- </div>
- </div>
- <!-- /Page content/ -->
- <script type='text/javascript'>
- // START of youtube rss fetch //
- function youtube_embedder(urlnormale){ // Embedder - Trasforma classici url youtube in embedded links...
- var regEx = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
- var match = urlnormale.match(regEx);
- if (match&&match[1].length==11){
- var nuovo = 'https://www.youtube.com/embed/'+match[1]+'?autoplay=1&autohide=2&color=white&version=3&rel=0';
- return nuovo;
- }else{ console.log("Url Youtube errato");
- }
- }// Fine emb.
- function show_my_videos(data){
- html = ['<div class="ytvideoList">'];
- $(data.feed.entry).each(function(entry){
- url = this.link[0].href;
- url_thumbnail = this.media$group.media$thumbnail[3].url;
- title = this.media$group.media$title.$t;
- description = this.media$group.media$description.$t;
- html.push('<a href="'+youtube_embedder(url)+'" title="'+ title +'" alt="'+ title +'" target="youtube_frame" class="chiudbox_dopoilclick"><img class="ytThumbnail" src="'+url_thumbnail+'" alt="'+description+'" /></a>');
- });
- html.push('</div>');
- $("#videos").html(html.join(''));
- }
- $.ajax({
- type: "GET",
- url: "http://gdata.youtube.com/feeds/users/realcsstricks/uploads?alt=json-in-script&format=5&max-results=16",
- cache: false,
- dataType:'jsonp',
- success: function(data){
- show_my_videos(data);
- }
- });
- // END of youtube rss fetch //
- /************ CLICKS HANDLING ************/
- $('#videos').on('click', '.chiudbox_dopoilclick', function() {
- $('#podcastModal').modal('hide');
- $('#collapsePodcasts').collapse('show');
- /* The following two lines are MY FIX to the bug...
- $('#youtube_frame').attr('src', $(this).attr('href'));
- setTimeout(function() { $('#collapsePodcasts').fitVids(); },50);
- The next line is, instead, what would have been done in a normal situation, where fitVids didn't have this bug */
- $('#collapsePodcasts').fitVids();
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement