Only 1 jPlayer plays, but it plays all - jplayer

I am creating a testimonials page and have numerous instances of jPlayer loading.
I initialize the players with this function:
initializePlayer: function (playerId,audio) {
$("#" + playerId).jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: audio
});
},
play: function() {
$(this).jPlayer("pauseOthers");
},
swfPath: "/assets/scripts",
supplied: "mp3"
});
},
The html for rendered players look like this:
<div id="jquery_jplayer_1" class="jp-jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_1" style="width: 0px; height: 0px; display: none;">
<audio id="jp_audio_1" preload="metadata" src="/assets/images/testimonials/Melva"></audio>
</div>
<div id="jp_container_1" class="jp-audio span3">...</div>
NOTE: I am not showing the contents of jp_container_1 because it is the standard jplayer. I have not adjusted it at all.
The only difference between each player is the int in the ids and the src:
<div id="jquery_jplayer_2" class="jp-jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_2" style="width: 0px; height: 0px; display: none;">
<audio id="jp_audio_2" preload="metadata" src="/assets/images/testimonials/Mark.mp3"></audio>
</div>
<div id="jp_container_2" class="jp-audio span3">...</div>
If I include the play portion of the initializer, none of the them play. If I exclude it, all of them play on the second player jquery_jplayer_1 and not on any of the rest.
What am I missing? Why are the all linked to the 1 player?

it appears that you have not set the cssSelectorAncestor value. If you read the documentation here:
http://jplayer.org/latest/developer-guide/#jPlayer-option-cssSelectorAncestor
You will see that the default is jp_container_1, which would explain why they are all playing on the same player. I believe that setting that value for each player will make it work as you expect.

first set the
cssSelectorAncestor: "#jp_container_1"
for all player as 1,2,3 then at the bottom of the jplayer functionality
$("#jplayer_inspector_1").jPlayerInspector({jPlayer:$("#jquery_jplayer_1")});
$("#jplayer_inspector_2").jPlayerInspector({jPlayer:$("#jquery_jplayer_2")});
give like this for all players

Related

How to get text in a CSS grid nested in a flexbox to wrap first?

TL;DR: Here's a CodePen.
I have a UI with an image and a grid of text with long lines which looks like this:
I'm using CSS Flexbox with two elements: the image and the text. And then to lay out the text, I'm using CSS Grid. Now, when I view this on a narrow screen for mobile, it correctly wraps everything and stacks the two elements:
But on desktop, with a slightly narrower div, the flex box wraps before the grid text like this:
How can I get the text to wrap while leaving the flex box alone in this case? I fear I may need to use some media queries, but I'm not even sure if I'm using the right CSS components for this.
Here's the code:
index.html:
<div class="media-callout">
<div class="media-thumb">
<img height="170" width="120">
</div>
<div class="media-callout-grid">
<div class="media-callout-key">Authors</div>
<div>Babalola, J & Ogunkola, Babalola</div>
<div class="media-callout-key">Year</div>
<div>2013</div>
<div class="media-callout-key">Title</div>
<div class="media-callout-value">Scientific Literacy: Conceptual Overview, Importance and Strategies for Improvement</div>
<div class="media-callout-key">Journal</div>
<div><em>Journal of Educational and Social Research</em></div>
<div class="media-callout-key">Location</div>
<div>vol. 3, no. 1, pp. 265–274</div>
<div class="media-callout-key">DOI</div>
<div>10.5901/jesr.2013.v3n1p265</div>
</div>
</div>
style.css:
.media-callout {
display: flex;
flex-wrap: wrap;
justify-content: center;
row-gap: 20px;
column-gap: 10px;
padding: 1em;
max-width: max-content;
}
.media-thumb img {
float: left;
height: 175px;
width: auto;
}
.media-callout-grid {
display: grid;
font-size: 12pt;
grid-template-columns: 6em 1fr;
align-content: center;
gap: 0 15px;
}
.media-callout-key {
text-align: right;
font-weight: bold;
}
.media-callout-value {
word-break: break-word;
word-wrap: break-all;
}
A media query does indeed resolve this:
#media screen and (min-width: 600px) {
.media-callout {
flex-wrap: nowrap;
}
}
The query must come AFTER the .media-callout block. I also had to use this approach to prevent the image from being squashed.

CSS How do I make my div elements lineup perfectly so that collectively they make up a perfect rectangle?

While I am open to any solution, counting tables, Bootstrap and Flexbox, a purely CSS solution using just div elements is greatly appreciated.
HTML
<div class="sentence-summary">
<div class="stat bookmarked">
<i class="fas fa-bookmark"></i>
<span class="count">999</span>
</div>
<div class="stat upvotes">
<i class="fas fa-thumbs-up"></i>
<span class="count">999</span>
</div>
<div class="stat downvotes">
<i class="fas fa-thumbs-down"></i>
<span class="count">999</span>
</div>
<div class="main">
<p>{{ $sentence->body }}</p>
</div>
</div>
SCSS
.sentence-summary {
div {
display: inline-block;
}
.stat {
width: 40px;
text-align: center;
span {
display: block;
font-size: 10px;
}
&.bookmarked {
background-color: red;
}
&.upvotes {
background-color: blue;
}
&.stat.downvotes {
background-color: pink;
}
}
.main {
background-color: green;
}
}
Current Result
Desired Result
I would recommend using a grid layout for this. You can specify that the first three columns (stats) should be 40px wide. And then use '1fr' to say that the 'main' sections should take up the remaining space. Using a grid means that the heights will stay the same.
You can use 'grid-column-gap' to specify the amount of space you would like between each column. Something like this:
.sentence-summary {
display: grid;
grid-template-columns: 40px 40px 40px 1fr;
column-gap: 5px;
grid-auto-rows: 40px;
}
Make sure you use the appropriate browser prefixes as this syntax isn't supported by all browsers. I usually use this auto-prefixer.
Update: Adding grid-auto-rows: 40px; makes sure your 'stats' stay square!

isotope packery layout ideal item sizes

I am trying to make a nice layout of items in a grid using a bin packing algorithm like packery or masonry. I Already have isotope installed so will use the packery plugin for that.
If you look at the example here http://codepen.io/desandro/pen/vdwmb this is exactly the kind of thing I need, but the problem I think I'm going to face is the content of the items are via a CMS.
<h1>Isotope - packery layout mode</h1>
<div class="grid">
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--width2 grid-item--height2"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
</div>
* { box-sizing: border-box; }
body { font-family: sans-serif; }
/* ---- grid ---- */
.grid {
background: #DDD;
max-width: 1200px;
}
/* clear fix */
.grid:after {
content: '';
display: block;
clear: both;
}
/* ---- .grid-item ---- */
.grid-item {
float: left;
width: 100px;
height: 100px;
background: #0D8;
border: 2px solid #333;
border-color: hsla(0, 0%, 0%, 0.7);
}
.grid-item--width2 { width: 200px; }
.grid-item--height2 { height: 200px; }
$('.grid').isotope({
layoutMode: 'packery',
itemSelector: '.grid-item'
});
Possibly more of a maths question, but Im assuming for packery to work the items all have to be of a size in relation to each other, ie in the example above all the items are multiples of the smallest item.
Is this assumption correct, and is there anything else i need to consider?

1px gap using Isotope Masonry (or Packery) expecialy on Safari

i'm sorry for my english.
It's many days that i try to figure out an issue that i see trying to create a responsive fullwidth grid of images. To create this grid I'm using Isotope with Masonry Layout (http://isotope.metafizzy.co/) or Packery (http://packery.metafizzy.co/layout.html). I have tried both and in both i have the same issue. For some resolution of my browser i see a 1px gap between images (as you can see in the images below).
I have read about this problem in many post (for example https://github.com/metafizzy/packery/issues/42) but no solution works for me. Anyone can help me?
At the moment my code is:
jQuery(window).load(function() {
var container = document.querySelector('.grid');
var pckry;
// using imagesLoaded http://desandro.github.io/imagesloaded
imagesLoaded( container, function() {
pckry = new Packery( container, {
itemSelector: '.grid-item',
rowHeight: '.grid-sizer',
percentPosition: true
});
});
});
I attach the final grid that i would like to have:
After many days of work i have been able to solve my issue thanks to DeSando, the plugins's author.
As he explain in this post http://metafizzy.co/blog/beyonce-seamless-fluid-image-masonry/ the gaps occur due to pixel rounding differences between JavaScript and CSS.
In my case i have a grid based on four columns and when the width of the browser wasn't divisible per 4 the gaps were born. So, as DeSandro suggests here, a workaround is to set container of images a little bit more smaller and cover the gaps with images a little bit more bigger. So, in my website:
HTML
<div class="grid">
<div class="grid-item" ><img src="..." title="" class="lazy"></div>
<div class="grid-item grid-item--width2 " ><img src="..." title="" class="lazy"></div>
<div class="grid-item grid-item--width2 "><img src="..." title="" class="lazy"></div>
<div class="grid-item" ><img src="..." title="" class="lazy"></div>
<div class="grid-item" ><img src="..." title="" class="lazy"></div>
...
</div>
CSS
.grid {
margin: 0 auto;
width: 100.4%;
margin-bottom: 0px !important;
}
.grid-sizer,.grid-item {
width: 24.9%;
display: block;
float: left;
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
list-style: none!important;
}
/* 2 columns wide */
.grid-item--width2 {
width: 49.8%;
display: block;
float: left;
}
.grid-item img{
display:block;
width: 100.4%;
max-width: 100.4% !important;
}
JS
// init Packery
var grid = jQuery('.grid').packery({
itemSelector: '.grid-item',
percentPosition: true
});
// layout Packery after each image loads
grid.imagesLoaded().progress( function() {
grid.packery();
});
I'm sorry for my english. I hope this could be useful for many of us.

Browser, safari/IE negative margin not working

I have a problem with safari. I have searched for 6 hours straight for a fix, so exscuse me if my explanation is bad. So the thing is: I have added a hover effect on my thumbnails, it works in all browsers, but the thumbs are not placed correctly in safari and IE.
I have tried to use:
#media screen and (-webkit-min-device-pixel-ratio:0){
img.a {
position: absolute;
top: -500;
z-index: 10;
}
img.b {
position: absolute;
top: -500;
}
}
But this works for webkit browser, meaning chrome as well.
The css I am currently using which works in chrome and firefox:
img.a {
position: absolute;
top: -500;
margin-left: -115px;
z-index: 10;
width: 230px;
height: 120px;
border: none;
}
img.b {
position: absolute;
top: -500;
margin-left: -115px;
width: 230px;
height: 120px;
border: none;
}
If anyone has a solution it would really save my day :)
Here is the site if you need to inspect: www.janthorb.com
Get rid of the CSS
div#thumbnails {
text-align:center;
}
and also get rid of your margin-left: -115px for your images and you will have something that works in both browswers.
You page code is a mess, no alignment. HTML structure is not reasonable, and cause CSS also is very not science. I rewrote your structure, you can reference.
.demo{ width:820px;margin:0 auto;}
.list{ margin-right:-20px; zoom:1;}
.list li{ float:left; width:230px; height:135px; margin:0 36px 25px 0; overflow:hidden; zoom:1;}
.link{ position:relative;width:228px; height:120px; display:block;border:thin dashed #1b1b1b; overflow:hidden;}
.link img{ position:absolute;top:0;left:0; }
.link .gray{ z-index:11;}
.link .hover{ z-index:10;}
<ul class="list">
<li>
<a class="link" href="#">
<img class="gray" src="http://www.janthorb.com/thumb1_bw.jpg" alt="">
<img class="hover" src="http://www.janthorb.com/thumb1.jpg" alt="">
</a>
</li>
<li>
<a class="link" href="#">
<img class="gray" src="http://www.janthorb.com/thumb1_bw.jpg" alt="">
<img class="hover" src="http://www.janthorb.com/thumb1.jpg" alt="">
</a>
</li>
</ul>
and demo is here

Resources