Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript/ jQuery plugin

It is not a real jQuery plugin, but for my problem i didn't know what title was appropriate.

This is the "Plugin" --> http://jsfiddle.net/djrikyx/GuumY/9/

There are 3 Youtube player, with the possibility of Pop out them into draggable DIVs and also minimize them to the right.

I can't explain my problem only with words, you have to see it to better understand.

First, popout all 3 players, then minimize them, they will go on the right, each one below the previous.

Then if you try to Close, or Maximize the one in the middle or the last, you will see that all will go up for 30px.

I know that now is doing that, because i wrote to do that in the function maximizePlayer() and popinPlayer() using

var countMP = $('.uiVideoHandleMin').length;
uVC.removeClass('uiVideoContainerMin');
if(countMP > 0){
    $('.uiVideoHandleMin').each(function(){
        var top = parseInt($(this).css('top'), 10);
        top = top-30;
        $(this).css({top:top});
    });
}

I don't want that. I want so the first one must be always at 50px from top, and the other just below. So if i close the middle one, the first will stay in position, and the last will go up, and if i close the last, nothing happen.

But i really don't know how i can do what i want, so i'm here asking for a tip/solution.

like image 623
Fr0z3n Avatar asked May 17 '13 17:05

Fr0z3n


People also ask

What is jQuery plugin JS?

A jQuery plugin is simply a new method that we use to extend jQuery's prototype object. By extending the prototype object you enable all jQuery objects to inherit any methods that you add. As established, whenever you call jQuery() you're creating a new jQuery object, with all of jQuery's methods inherited.

How do I get jQuery plugins?

There are plenty of jQuery plug-in available which you can download from repository link at https://jquery.com/plugins.

What are JavaScript plugins?

A browser plugin is a software component that users can install to handle content that the browser can't support natively.

Is jQuery still used in WordPress?

If you're a WordPress user, it's important to know that jQuery is a required library for the platform. As such, a developer will use the codebase to 'standardize' some of the interactions between the HTML and JavaScript elements.


1 Answers

I changed it to this http://jsfiddle.net/Klors/GuumY/11/ which seems to work?

There is a line in your function popinPlayer(elem) { that reduces the css top by 30, but doesn't check to see if it's 0 (or below the removed handle) first.

So I changed top = top-30; to top = top > thisTop ? top-30: top; and added in var thisTop = parseInt($uVH.css("top"), 10); before you reset top on $uVH, which seems to work.

like image 151
Klors Avatar answered Nov 14 '22 22:11

Klors