SEO Search

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 27 October 2013

Turn off the lights with jQuery

Posted on 06:39 by Unknown
For those who enjoy watching videos on the net, this is a very useful script made by Janko with jQuery.

So what this script does? It will "turn off the lights" so that everything you have on the page will be fading to dark less the video, so there will not be other elements that will distract us while watching a video and we will feel like in the cinema.

You can see an example here by clicking on the link that says "Turn off the lights".
Whenever you want, then you can click on the link again and it will turn the lights back on.
Turn off the lights

To put this effect of "lights" on the blog, go to Template > Edit HTML and before the </head> tag (CTRL + F to find it), paste the script:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function(){
$("#darkness").css("height", $(document).height()).hide();
$(".lightSwitcher").click(function(){
$("#darkness").toggle();
if ($("#darkness").is(":hidden"))
$(this).html("Turn off the lights").removeClass("turnedOff");
else
$(this).html("Turn on the lights").addClass("turnedOff");
});
});
//]]>
</script>
Then add before ]]></b:skin> the CSS styles:
/* Turn off the lights
----------------------------------------------- */
#lightsVideo {
position:relative;
z-index:102;
}
#switch {
max-width:640px;
text-align:left;
position:relative;
height:25px;
display:block;
margin: 25px 0 0 60px;
}
.lightSwitcher {
position:absolute;
z-index:101;
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEin6AmG3NS7s_SF7ECSHGU_WiUau1tDAJ7dzc8OkKwMjxufv3BEidSpN5WWNffKOFI0v7xadhEeEoP4Yeg458QGbqO3Wvur6Vew13RPuhuovFhUVmauGSyMBtItTcVEuNX9axVaVMknZRGX/s1600/lights-on.png);
background-repeat:no-repeat;
background-position:left;
padding: 0 0 0 20px;
outline:none;
text-decoration:none;
}
.lightSwitcher:hover {text-decoration:underline;}
.turnedOff {
color:#ffff00 !important;
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKYBlSSJL5hyphenhyphen5GjjBiNaaXPO106HKNLPvv0i_5mfRoKzR8qFK8dnZmBjBU11PGazHT8sufz7LlosPl-X2tN1e2KuIRh212hv4Dw-TZKtZfy36TXKNstqBVAOzSV4B3tqCbfTyjzXSmu3D0/s1600/lights-off.png);
}
#darkness {
background:#000;
opacity:0.8;
filter:alpha(opacity=80);
position:absolute;
left:0;
top:0;
width:100%;
z-index:100;
}
Click on the arrow to expand the styles
 Then, before the </body> tag, add this:
<div id='darkness'/>
And finally, wherever you put your video, either a post or a HTML/Javascript gadget, use this code:
<center>
<div id="switch"><a class="lightSwitcher" href="javascript:void(0);">Turn off the lights</a></div>
<div id="lightsVideo">
...Here goes the code of the video...
</div>
</center>
Add the code of your video to where is indicated and that's it. Now you can enjoy your videos with the lights off!

Remember that this trick uses jQuery, so if you use Scriptaculous or Mootools you should apply a patch, and if you use another version of jQuery, you must use only one.
Email ThisBlogThis!Share to XShare to Facebook
Posted in jQuery | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • CSS Basics. How to Apply Rounded Corners On Images #1
    This tutorial will explain how to change the outside border of any image using some simple CSS rules to make it round, but this is so easy t...
  • How to change Blogger "Post A Comment" Message
    In this tutorial i will show you how to replace the 'Post A Comment' text that appears above the comment form with an image. Also, I...
  • Google Translate Widget with Flags For Blogger
    The Google Translate Widget for Blogger allows the visitors to translate your site or blog in their own language. This widget also auto-dete...
  • How to Write SEO Optimized Blog Posts
    I'm not a SEO Expert, nor what we will read further is a top secret, but this is something about basic positioning that everyone should ...
  • Scriptaculous image slider/carousel for Blogger
    This is a very nice carousel slideshow made by Brian R. Miedlar which shows a gallery of images having a sliding effect that returns to the...
  • A Simple Related Posts Widget For Blogger
    In the last tutorial, i've been talking about the Related Posts widget  that shows related posts along with thumbnails just at the end ...
  • Blogger Auto Video Template by webbilgi
    Rate this template: Demo: Click here for Demo Source And Designer: Author page Click here to Download Features: Automatic thumbnail creati...
  • A Beautiful jQuery Drop-Down Menu For Blogger Blogspot
    Alright, this time, we are going to make a stylish and simple jQuery drop down menu. The main objective is to make it as simple as possible,...
  • Turn off the lights with jQuery
    For those who enjoy watching videos on the net, this is a very useful script made by Janko with jQuery. So what this script does? It will ...
  • How to add go to top and go to bottom buttons Using jQuery in Blogger
    The Up and Down buttons can be used to navigate to the top and bottom of the page content, especially when on the main page there are many ...

Categories

  • adsense
  • adsense optimization
  • adsense tips
  • Auto Video Template
  • avatars
  • blockquotes
  • Blog Design
  • blogger
  • blogger posts
  • color code generator
  • Comments
  • comments tricks
  • css
  • emoticons
  • Emoticons/Smileys
  • Facebook
  • feedburner
  • forum
  • Hacks
  • how to
  • how to make a blog
  • Image Effects
  • internet
  • jQuery
  • labels
  • menus
  • Navigation
  • navigation menu
  • popular posts
  • posts
  • read more
  • recent comments
  • recent posts
  • related posts
  • RSS
  • SEO
  • sitemaps
  • slideshows
  • social media
  • social media plugins
  • static pages
  • Templates
  • threaded comments
  • titles
  • tools
  • translating
  • webbligi
  • Widgets

Blog Archive

  • ▼  2013 (57)
    • ►  November (4)
    • ▼  October (16)
      • How to Add a Tiny jQuery Circleslider to Blogger
      • Turn off the lights with jQuery
      • Before/After Photo Effect with jQuery
      • Spacegallery: image gallery/slideshow made with jQ...
      • Top three qualities of a successful blogger
      • Add Keyboard Keys Effect To Your Text in Blogger w...
      • How to do natural SEO on Blogger
      • How to Add a Recent Forum Topics Widget to Blogger
      • Add a forum on your Blogger blog with Nabble
      • Top Commentators Widget with Avatars for Blogger
      • Redirect Blogger 404 Error (Page Not Found) To Hom...
      • 4 Alternatives to Google AdWords
      • How to Add Google Analytics to Blogger
      • How to Increase Alexa Ranking of your Blog
      • On-Page SEO Tips for Blogger
      • Adding a Meta Description to Blogger
    • ►  September (13)
    • ►  June (3)
    • ►  May (4)
    • ►  April (5)
    • ►  March (12)
  • ►  2012 (73)
    • ►  July (1)
    • ►  June (3)
    • ►  May (9)
    • ►  April (23)
    • ►  March (30)
    • ►  February (7)
Powered by Blogger.

About Me

Unknown
View my complete profile