Aug 27, 2012

JQuery Treeview List

JQuery Treeview List - Creates a nice expanding and collapsing tree view control using jQuery.

JQuery Treeview List

Tree view Displays a hierarchical collection of labeled items, each represented by a TreeNode. This you'll normally see in windows or MAC folder navigation.

Today I am making it in JQuery for ul, li list.



Basic HTML Markup


[html]
<ul>
<li><a>First Level</a>
<ul>
<li><a>Second Level</a></li>
<li><a>Second Level</a></li>
<li><a>Second Level</a></li>
</ul>
</li>
<li><a>First Level</a>
<ul>
<li><a>Second Level</a>
<ul>
<li><a>Third Level</a></li>
<li><a>Third Level</a></li>
<li><a>Third Level</a>
<ul>
<li><a>Fourth Level</a></li>
<li><a>Fourth Level</a></li>
<li><a>Fourth Level</a>
<ul>
<li><a>Fifth Level</a></li>
<li><a>Fifth Level</a></li>
<li><a>Fifth Level</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a>Second Level</a></li>
</ul>
</li>
<li><a>First Level</a>
<ul>
<li><a>Second Level</a></li>
<li><a>Second Level</a></li>
</ul>
</li>
</ul>
[/html]

We just created a normal list formation in hierarchical way.



Now lets add some styling - CSS


[css]
.tree {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: -moz-linear-gradient(center top , #E3E3E3, #FFFFFF 85px) repeat scroll 0 0 transparent;
border-color: #BFC0C2 #BFC0C2 #B6B7BA;
border-radius: 3px 3px 3px 3px;
border-style: solid;
border-width: 1px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.17), 0 -2px 0 rgba(0, 0, 0, 0.08) inset;
display: inline-block;
margin: 0 0 50px;
min-width: 300px;
padding: 10px 15px 15px;
}
.tree ul {
list-style: none outside none;
}
.tree li a {
line-height: 25px;
}
.tree > ul > li > a {
color: #3B4C56;
display: block;
font-weight: normal;
position: relative;
text-decoration: none;
}
.tree li.parent > a {
padding: 0 0 0 28px;
}
.tree li.parent > a:before {
background-image: url("../images/plus_minus_icons.png");
background-position: 25px center;
content: "";
display: block;
height: 21px;
left: 0;
position: absolute;
top: 2px;
vertical-align: middle;
width: 23px;
}
.tree ul li.active > a:before {
background-position: 0 center;
}
.tree ul li ul {
border-left: 1px solid #D9DADB;
display: none;
margin: 0 0 0 12px;
overflow: hidden;
padding: 0 0 0 25px;
}
.tree ul li ul li {
position: relative;
}
.tree ul li ul li:before {
border-bottom: 1px dashed #E2E2E3;
content: "";
left: -20px;
position: absolute;
top: 12px;
width: 15px;
}
[/css]


In css we are making tree nodes usinf :before

Last we will add jquery functionality to toggle the list on click events.



JQuery


[js]
$('.tree li').each(function(){
if($(this).children('ul').length > 0){
$(this).addClass('parent');
}
});

$('.tree li.parent > a').click(function(){
$(this).parent().toggleClass('active');
$(this).parent().children('ul').slideToggle('fast');
});
[/js]

Here first we search for all parent nodes and if found then we are adding a class named as .parent

Then on click of any parent elements, we just add a class .active and slide the li's in it.

This can be used to show the navigation of the website.

Aug 23, 2012

Collection of Special iPhone Meta Tags

I am not an iPhone developer nor a user but just found some special meta tags for developing iPhone webapps and iPhone prove websites. Hope this helps you.
 
Disable horizontal scrolling


[html]
<meta name="viewport" content="width=device-width, user-scalable=no" />
[/html]


  
When bookmarked the website runs in fullscreen, like a normal App.


[html]
<meta name="apple-mobile-web-app-capable" content="yes" />
[/html]


  
When bookmarked as fullscreen, set the color of the status bar


[html]
<meta name="apple-mobile-web-app-status-bar-style" content="black">
[/html]


  
When bookmarked, add an 57x57 Icon and the iPhone will add the shiny effect itself.


[html]
<link rel="apple-touch-icon" href="icon.png" />
[/html]


  
Prefer non glossy Icon or made the gloss yourself? Precomposed stops from adding the gloss on bookmarks


[html]
<link rel="apple-touch-icon-precomposed" href="icon" />
[/html]


  
Remove auto-recognition of Phone numbers


[html]
<meta name="format-detection" content="telephone=no">
[/html]


  
Forces the iPhone to use a number pad


[html]
<input type="number">
[/html]


  
Guess what? A phone number keypad


[html]
<input type="tel">
[/html]


  
Keyboard optimized for typing urls.


[html]
<input type="url">
[/html]


 

Credits : Robert

Aug 16, 2012

Forrst Invites Giveaway | CLOSED

Forrst.com A website for designers and also for developers. Here you will find a great resource of Web Development. Its a community where a developer and designers improve thier craft. Its just a invite based website so that only real people enter it.

Forrst

So you want it???? Then

  • Comment your latest or best work below with your actual EMAIL ID(Design or Development or both - Mandatory)

  • Share this post on twitter and other social sites(Advantage)


And just wait for results. I have total 2 invites so hurry up!!!

Results will be announced on 22 Aug 2012

 




We have selected two winners. TRAVIS and SUMON SELEEM Congratulations and welcome to forrst

Aug 8, 2012

Wordpress Bloginfo Shortcode

A small snippet for Wordpress Bloginfo. This will help you to add images directly without giving the entire path. Its a shortcode snippet

[php]
function get_bloginfo_shortcode( $atts ) {
extract(shortcode_atts(array(
'info' => '',
), $atts));
return get_bloginfo($info);
}
add_shortcode('bloginfo', 'get_bloginfo_shortcode');
[/php]

Usage :

[html]
<img src="[bloginfo info='template_url']/images/logo.jpg" alt="[bloginfo info='name'] logo" />
[/html]

Now you can easily call your images without giving actual path.

Credits Forrst

Aug 2, 2012

CSS3 Visiting Card 3D Transform

My friend Asif made a nice design on visiting card, so I decided to convert that into a 3D flipping Visiting Card

CSS3 Visiting Card

To rotate a div with 3D transform :-

  • transform-style: preserve-3d;

  • perspective: 800px;

  • transform: rotateY(180deg);

  • backface-visibility: hidden;


After setting the above CSS a div will transform.




Final Product

Visiting Card Front-Back

Visiting Card Back-Front




So lets start




[html]
<div id="card">
<div class="front">
<div class="strips">
<p class="strip red"></p>
<p class="strip orange"></p>
<p class="strip green"></p>
<p class="strip blue"></p>
<p class="strip lOrange"></p>
</div>
<div class="businessName">
Webs Tutorial
</div>
</div>
<div class="back">
<div class="strips">
<p class="strip red"><span>www.webstutorial.com</span></p>
<p class="strip orange"><span>Mumbai, India</span></p>
<p class="strip green"></p>
<p class="strip blue"><span>PHP, HTML5, CSS3</span></p>
<p class="strip lOrange"><span>niraj@webstutorial.com</span></p>
</div>
<div class="myName">
<p>Niraj Chauhan</p>
Developer
</div>
</div>
</div>
[/html]




Above we made a parent div and inside that two divs, one will be the front side and another will be the backside. When we :hover on the front facing div, it rotates in Y axis. As we have set the transform style to preserve-3d it will maintain its view and the transform will be displayed in 3D.




[css]
@font-face {
font-family: roboto;
src: url('../Roboto-Regular.ttf');
}

* {
font-family: roboto !important;
}

.container {
position: relative;
}

#card {
position: absolute;
z-index: 11;
-webkit-perspective: 800px;

-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
left: 30%;
}

#card .front,#card .back {
background: #000;
width: 480px;
height: 205px;
display: block;
position: absolute;
color: #fff;
border-radius: 8px;

-webkit-transition: -webkit-transform 1s ease-in-out;
-moz-transition: -moz-transform 1s ease-in-out;
-o-transition: -o-transform 1s ease-in-out;
-ms-transition: -ms-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
}

#card .front {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
z-index: 13;
}

#card:hover .front {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
}

#card .back {
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
z-index: 12;
background: #000;
}

#card:hover .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
z-index: 14;
}

/* Front Strips */
.strips {
clear: both;
margin: 0 auto;
position: relative;
width: 125px;
}

.strip {
float: left;
height: 140px;
margin-right: 12px;
position: relative;
width: 12px;
font-family: roboto;
}

.red {
background: #b70000;
color: #b70000;
border: 1px solid #890000;
border-top: 0px;
}

.orange {
background: #f25d07;
color: #f25d07;
border: 1px solid #b64605;
border-top: 0px;
}

.green {
background: #a69e33;
color: #a69e33;
border: 1px solid #837726;
border-top: 0px;
}

.blue {
background: #0092b2;
color: #0092b2;
border: 1px solid #006e86;
border-top: 0px;
}

.lOrange {
background: #ee913f;
color: #ee913f;
margin: 0 !important;
border: 1px solid #b36d2f;
border-top: 0px;
}

.businessName {
clear: both;
font-family: roboto;
font-size: 22px;
padding: 5px 0 0;
text-align: center;
}

/* Back strips */
.back .red {
height: 70px;
}

.back .orange {
height: 100px;
}

.back .green {
height: 140px;
}

.back .blue {
height: 100px;
}

.back .lOrange {
height: 70px;
}

.strip span {
position: absolute;
font-size: 15px;
}

.red span {
left: -162px;
top: 50px;
}

.orange span {
left: -102px;
top: 80px;
width: 100px;
}

.green span {
left: 0;
}

.blue span {
left: 20px;
top: 80px;
width: 140px;
}

.lOrange span {
left: 18px;
top: 50px;
}

.myName {
clear: both;
color: #999999;
font-family: roboto;
font-size: 20px;
padding: 0;
text-align: center;
}

.myName p {
color: #a69e33;
}

#designedBy {
border-radius: 5px 0 0 0;
bottom: 0;
color: #FFFFFF;
min-height: 10px !important;
padding: 10px;
position: fixed;
right: 0;
}
[/css]




Now in CSS we set the backface-visibility: hidden;. With this property the backside of the card will be hidden. When we hover on the front face of the card with the help of css transition we flip the card and now the backside of the card will be visible.

When we move away over mouse from the card it turns back to its original position.This way a 3D flip can be done using CSS3.

Now the latest Firefox also supports the 3D Transform. Previously it was only working on webkit browsers