Add vimeo style menu to video.js? - html

I have a simple demo page working with video.js and haven't changed a thing with it yet. I would like to have it so that I can hover over it and see a menu appear, much like the way vimeo does with their menu for sharing etc.
I am trying to work out if this should be done on the html / css side of things, or if there is funcationality in video.js itself to add menus. A quick example would be great if there is one online somewhere that I can be linked to.
Thanks in advance

One way would be to use the video.js ready event to modify the DOM.
If you inspect the DOM when the ready event fires from your video.js instance, you'll notice that your video tag has been wrapped with a div, and the id you used has been transferred to that div.
If you have enabled controls, you'll notice that the video element also has sibling elements in your new wrapper div. These are the controls video.js adds.
You can create additional controls, and add those as siblings to the video element (alongside the ones video.js creates).
So, a quick example would look like this (using jQuery, although this could be done without it):
var vimeoMenu = '<ul id="vimeo"><li id="like"></li><li id="later"></li><li id="share"></li></ul>';
var videoId = "example_video";
var playerInstance = videojs(videoID).ready(function(){
// Add elements to DOM
var playerWrapper = $("#" + videoId);
playerWrapper.append(videoMenu);
});
Using CSS, you can position the controls in the top right (like Vimeo). Video.js adds a class to the wrapper element that you can use to show / hide your controls. By default, hide your elements (display, visibility, opacity, etc.). When the class of the instance changes to .vjs-user-active, you can show your elements. Video.js uses a 1 second transition (if you want to match it perfectly).

Related

How to create a pop up contact form in Node.js/Jade Template?

How can I go about creating a form which pops up when the user clicks a button on a Jade template? I tried the following in HTML, which works:
http://www.formget.com/how-to-create-pop-up-contact-form-using-javascript/
Now to use this in my Node.js project would I need to create a separate Jade file for the form itself? That is what I tried and then I tried to display the form like this:
function div_show() {
alert("Test");
document.getElementById('abc').style.display = "block";
}
Unfortunately that does not work. What is the recommended approach for creating a pop up form in Jade? I am really confused with Jade and I can't seem to find a good tutorial for this, there are loads for HTML...
Thanks for the help!
Normally for this you would use:document.getElementById('abc').style.visibility="visible";
To hide your table use:document.getElementById('abc').style.visibility="hidden";
When using the 'style' attribute you are using plain css commands. Make sure your default div style settings have it 'hidden', if that is what you want.This display:block;visibility:hidden;' must exist in your default settings for that div style so the DOM has a clear path to what it is controlling. By itself 'display:block;' does not hide or make objects visible, it is mostly about the shape the div creates as a container for objects.
As an option you can use:
document.getElementById('abc').style.display="block";
To hide your table use:document.getElementById('abc').style.display="none";
For this you would set your div style settings to 'display:none;visibility:visible;.
In this case 'display="none"' removes the object from all display layers and could allow other objects to fill in it's space. When it is visible it will push other objects on the same z-index out of the way. If it has a higher z-index, say +100 higher, it will pop-up above the other objects on the page. The 'visibility' attribute only controls the objects visibility, it does not remove it from the display memory. It can still take up space even though it is not visible. The 'opacity' attribute does about the same thing, except it allows you to also make an object as transparent as you like.

Can zoomControl ControlPosition be defined with CSS?

I know there a fixed position for the zoomControl, but they are not enough for where I need to put it.
Can I style it with CSS? Such as top:80px; right:20px;
Yes you can do it with jQuery. If you see the HTML source for the map generated, it can be observed that the various controls the map provides don't have a ID attribute to manipulate them. However we can use the title attribute of each element to modify them as per our need. See this solution where in a click on the map div adds a top:50px to the bar in zoom control -
**DEMO
jQuery-
$("div[title='Click to zoom']").css("top","50px");
});
Similarly you can capture other controls in the map and add css to them as per your need.
One point to note here is that you can't us the $(document).ready() to change the css on page load since the map actually takes time to load and by then the zoom bar isn't in the DOM. So I used a map click event to add the css. You can use other events to manipulate the css of the zoom control or other controls.

How to select multiple areas in containment using jQuery UI draggable

Hi i want to select multipe areas in containment using jQuery UI draggable while usinf drag and drop. I have used containment:["#area1","#area2","#area3"], also made single class with name area and applied to all divs but still not working, even tried containment: '#area1, #area2, #area3' but still not working. Its taking only the first container only. Please suggest
you can use the ui containment options like following:
containment:'selector1, selector2,selector3...'

Setting JQueryMobile Popup's data-position using JavaScript

$('#popupDiv').popup("open");
This programmatically opens a JQueryMobile pop up, but I want to know if it is possible to change or set my popup's settings, such as data-position and data-transition along with my code above. Thanks.
You can do:
$('#popupDiv').popup("open", {positionTo: '#mydiv'});
'origin' is not working for me in version 1.2 though.
see: http://jquerymobile.com/demos/1.2.0/docs/pages/popup/methods.html
Straight from the jQuery Mobile Docs:
Positioning options By default, popups open centered vertically and
horizontally over the thing you clicked (the origin) which is good for
popups used as tooltips or menus. The framework also applies some
basic collision detection rules to ensure that the popup will appear
on-screen so the ultimate position may not always be centered over the
origin.
For situations like a dialog or lightbox where the popup should appear
centered within the window instead of over the origin, add the
data-position-to attribute to the link and specify a value of window.
It's also possible to specify any valid selector as the value of
position-to in addition to origin and window. For example, if you add
data-position-to="#myElement" the popup will be positioned over the
element with the id myElement.
<a href="#positionWindow" data-rel="popup" data-position-to="window" data-transition="slideup">
<div data-role="popup" id="positionWindow">
<p>I am positioned to the window.</p>
</div>
You can add data-transition="slideup" (or the transition of your choice) to the link, as well as other positioning options outlined in the docs link at the top of my answer.
yeah the right way to do this is use event.target like this
$('#popup').off('taphold').on('taphold', function (e) {
$('#popupDiv').popup("open", e.target);
});
incidentally, this code then places a popup if you tap hold the button and a click event is like this would mean a normal click still works
$('#popup').on('tap', function (){
var url = $(this).attr('url');
window.open( url, '_parent');
});
nb: I added "url='google.com'" to the markup and made href='#'

html5 drag and drop drag anything opacity

I am using html5 drag and drop to drag and drop div elements. On the dragstart event I set the the opacity of the div element to 0.4 which reduces makes the div element lighter but it is not transparent ie. when I drag the div element over other div elements I can't see the elements in the background.
var cols = document.querySelectorAll('.draggablediv');
[].forEach.call(cols, function(col) {
col.addEventListener('dragstart', function (e) {this.style.opacity =
'0.4'; return true;}, false); });
I am using chrome 17.0.963.56.
Edit Note: This does not happen in firefox
Any ideas?
Thanks
There is a tutorial that features the same code you are using at:
http://www.html5rocks.com/en/tutorials/dnd/basics/
If you load the link above in Firefox, you'll notice the examples do not work. The tutorial features a specific mention of Firefox and why the examples don't work - you'll need to "wire up" the dataTransfer object.