45 posts
  • Has collected 10+ items on Envato Market
  • Pulled off some great moustache to raise money or awareness for Movember Australia
  • Has been part of the Envato Community for over 2 years
  • Located in United States
premiumwd says

I have seen a lot of threads on theme-forest with a lot of different ways to approach this for their demos. I had a big challenge to try and make this happen and it is quite out of my level of knowledge to put it all together and function properly.

I have already created the js, css, and html to make it slide out and users to be able to change options. However connecting the styles to make it change is where I am at.

Here is the code for the js, css, and html to make a show/hide horizontal demo menu with style switcher.

HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js?ver=1.4.4"></script>
<script type="text/javascript">
google.setOnLoadCallback(function()
{
   // Color changer
   $(".blue").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/blue.css");
      return false;
   });

   $(".green").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/green.css");
      return false;
   });

   $(".orange").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/orange.css");
      return false;
   });

    $(".black").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/black.css");
      return false;
   });

   $(".white").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/white.css");
      return false;
   });

   $(".grey").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/grey.css");
      return false;
   });

  $(".purple").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/purple.css");
      return false;
   });

   $(".yellow").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/yellow.css");
      return false;
   });

   $(".red").click(function(){
      $("link").attr("href", "<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/red.css");
      return false;
   });

});
</script>
<ul id="navigation">
            <li><span>Click Me!</span>

             <div id="panel">

    <div style="padding:10px 10px 0 10px;">
     <a class="grey" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/grey.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/grey.png" width="25" height="25" /></a>
     <a class="white" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/white.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/white.png" width="25" height="25" /></a>
     <a class="blue" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/blue.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/blue.png" width="25" height="25" /></a>
     <a class="red" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/red.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/red.png" width="25" height="25" /></a>
     <a class="green" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/green.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/green.png" width="25" height="25" /></a>
     <a class="orange" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/orange.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/orange.png" width="25" height="25" /></a>
     <a class="yellow" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/yellow.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/yellow.png" width="25" height="25" /></a>
     <a class="purple" href="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/purple.css"><img src="<?php bloginfo('template_directory'); ?>/premiumwd-options/skins/images/purple.png" width="25" height="25" /></a>
    </div>

</div>

</li>
</ul>
CSS
ul#navigation {
    position: fixed;
    margin: 0px;
    padding: 0px;
    top: 140px;
    left: 0px;
    list-style: none;
    z-index:999999;
}
ul#navigation li {
    width: 30px;
    height:27px;
}
ul#navigation li span {
    display: block;
    width: 10px;
    height:10px;
    padding: 7px 10px 10px 10px;
    border-top-right-radius:5px;
    border-bottom-right-radius:5px;  
    background-color:#fff;
    margin-left:-3px;
    border:1px solid #ccc;
    border-left:none !important;
    cursor:pointer;
}

  #panel {
    background: #fff;
    border:1px solid #ccc;
    height: 450px;
    width:145px;
    position:relative;
    top:-29px;left:-147px;
    border-bottom-right-radius:5px;
}  
JS
<script type="text/javascript">
        $(document).ready(function() {
 $('#navigation > li ').toggle(function() {
   $('span,#panel',$(this)).stop().animate({'marginLeft':'145px'},200);
  },function(){
   $('span,#panel',$(this)).stop().animate({'marginLeft':'0px'},200);
  });
});
</script>

This is a great way for users to test out your demos. Have fun :P

by
by
by
by
by
by