Subscribe Via RSS

3174 Subscribers

Subscribe Via RSS
Subscribe Via Twitter

Followers

Subscribe Via Twitter
jQuery & jFlow

May 27th, 2009 in JQuery Tutorials by Richard Carpenter

jQuery & jFlow

1 Star2 Stars3 Stars4 Stars5 Stars12 Votes, Rating: 4.5
Loading ... Loading ...
About The Author

About The Author: Richard Carpenter

Hi im Richard Carpenter im a freelance web and graphics designer from England. I am also a regular Blogger, Tutorial Writer, and owner of HV-Designs. You can follow me on twitter HERE. You may also view my portfolio HERE.

 

Richard Carpenter has written 322 posts.

Good evening everybody in todays tutorial we’ll be dabbling into some jquery. We’ll be intergrating a jQuery plugin called jFlow into a website.

Before we start this tutorial your going to need a few things:

- Jquery 1.2.6.Pack (download here).
- Jquery jFlow Plugin 1.0 (download here).
- A website ready template to add jflow into.

If you want to read up about the jflow plugin there website is HERE. If your asking yourself “why is he using jquery 1.2.6?” then the answer to your question is because i couldnt get jflow to work with the new libary. (just speaking from experience). Although i do believe there is a jflow 1.2 version which might work.

Once you have all your files open up your template in your code editor. Navigate to your templates main folder, create a new folder called “js” then copy and paste the jflow and jquery 1.2.6 file into the folder. Open up your index.html and link the two files in the head section by your style sheet.

<script src="js/jquery-1.2.6.pack.js" type="text/javascript"></script>
<script src="js/jquery.flow.1.1.min.js" type="text/javascript"></script>

Underneath the two linked js files add this chunk of javascript.

<script type="text/javascript">
$(function() {
$("div#controller").jFlow({
slides: "#slides",
width: "900px",
height: "250px"
});
});
</script>

Without the chunk of code above your slides will not slide. The width and height are required, if you remove the height the slides will work in firefox but will not in internet explorer. The width of my slides on my template are 900px wide and 250px in height, you will have to adjust these 2 values according to your own design. Lets look at the code above in more deatil.

Firstly we have a div of #myController this is the div where all the controllers will be nested. we then have a div of #slides this is the div where all your sliding divs are nested in. we then have width this can be specified in px or % as is a required style. We then have height this can be specified in px and is also required.

Lets take alook at my featured area in which we’ll be placing the slides. Il be using the “Your PROject” template i made in a previous tutorial. The code looks like this.

<div id="featured"><!--FEATURED CONTENT STARTS-->
<div class="featured-text"><!--FEATURED TEXT STARTS-->
<h1 class="featured">featured text here 01</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porttitor est et ante euismod vel euismod tortor ornare. Quisque turpis augue, iaculis vel luctus non, dapibus a ante. Quisque vitae turpis augue. Nulla facilisi.  Continue Reading...</p>
</div><!--FEATURED TEXT ENDS-->

<div id="featured-image01"><!--FEATURED IMAGE STARTS-->
<div class="featured-buttons"><!--NEXT AND PREVIOUS BUTTONS STARTS-->
<div class="featured-btn">
<img src="images/next_btn.png" alt="Next"  />
<div class="featured-btn"><img src="images/prev_btn.png" alt="Previous" />
</div>
</div>
</div><!--NEXT AND PREVIOUS BUTTONS END-->
</div><!--FEATURED IMAGE ENDS-->

</div><!--FEATURED CONTENT ENDS-->

The mockup above looks like this.

Step1

Above the featured area DIV tag we need to add our jflow controllers copy and paste the code below, above your featured area code.

<div id="controller" class="hidden">
<span class="jFlowControl">No 1</span>
<span class="jFlowControl">No 2</span>
<span class="jFlowControl">No 3</span>
</div>

My main featured area has a main container called featured, rename this to slides. Also rename the style in the style sheet to slides. At the very bottom of your style sheet we need to add the style to hide our other two slides. We can do this by adding the style below.

.hidden {
	display: none; /*hides our 2nd and 3rd featured slides*/
}

In our featured area under the slides div we need to add a blank div. At the end of our featured content we need to close the div. The code looks like this.

<div id="slides"><!--FEATURED CONTENT STARTS-->

<div><!--STARTS SLIDE #1-->

<div class="featured-text"><!--FEATURED TEXT STARTS-->
<h1 class="featured">featured text here 01</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porttitor est et ante euismod vel euismod tortor ornare. Quisque turpis augue, iaculis vel luctus non, dapibus a ante. Quisque vitae turpis augue. Nulla facilisi.  Continue Reading...</p>
</div><!--FEATURED TEXT ENDS-->
<div id="featured-image01"><!--FEATURED IMAGE STARTS-->
<div class="featured-buttons"><!--NEXT AND PREVIOUS BUTTONS STARTS-->
<div class="featured-btn">
<img src="images/next_btn.png" alt="Next"  />
<div class="featured-btn"><img src="images/prev_btn.png" alt="Previous" />
</div>
</div>
</div><!--NEXT AND PREVIOUS BUTTONS END-->
</div><!--FEATURED IMAGE ENDS-->

</div><!--ENDS SLIDE #1-->

</div><!--FEATURED CONTENT ENDS-->

Your next two slides or how ever many you will have to being with another empty div and end with a div so for example your slides would look like this.

<div><!--STARTS SLIDE #1-->
FIRST SLIDE CONTENT
</div><!--ENDS SLIDE #1-->

<div><!--STARTS SLIDE #2-->
SECOND SLIDE CONTENT
</div><!--ENDS SLIDE #2-->

<div><!--STARTS SLIDE #3-->
THIRD SLIDE CONTENT
</div><!--ENDS SLIDE #3-->

Inside our featured content area we also have two images, the images are a left and right arrow.

<div class="featured-btn"><img src="images/next_btn.png" alt="Next"  /></div>
<div class="featured-btn"><img src="images/prev_btn.png" alt="Previous" /></div>

On each button we need to add a new class associated with jflow. The classes are.

class="jFlowNext"
class="jFlowPrev"

The jFlowNext classes will make the slide go left, the jFlowPrev will slide the content right. We have to add both classes into our featured area. The next class will go on our next button and the prev class will go on our previous button. Like this.

<div class="featured-btn"><img src="images/next_btn.png" alt="Next" class="jFlowNext"  /></div>
<div class="featured-btn"><img src="images/prev_btn.png" alt="Previous" class="jFlowPrev" /></div>

Once you’ve done that upload your template and see how it looks. If you wanted to make it slightly easier to read in your code you could place each slide in a php file then include them into your template. To view the finished product click the button below.

Thats all, hope you’ve enjoyed this tutorial any problems dont hesitate to ask. The template will be free to download soon so keep your eyes peeled.

Be Part Of The Community!

Become part of the hv-designs community.

Subscribe Via RSS or Follow Us On Twitter.

Subscribe Via RSS Follow Us On Twitter

17 Responses to “jQuery & jFlow”

  1. Kev says:

    I have been looking at your progress with this website and I am finding it very interesting, one thing I though, the JFlow does not actually work properly in Google Chrome (it functions correctly but pushed the featured window and post to the right).

    Just a bit of constructive feedback =] but loving the tut.

  2. leertaste says:

    Great work :) Now I know how to use JQuery :) Thank you

  3. Akkis says:

    This is a wonderful tutorial serie! Thank you!

  4. webwizo says:

    This is marvelous tutorial, i was using of MooTools for it! but MooTools wasn’t as smooth as jQuery working..

    Thanks for the tutorial man

    Enjoy!!

  5. Harsha says:

    Hey Richard, I love how you changed the site from its beginning to now, I think I started reading it a little before you changed it for the first time, and now it looks so much cooler. The tutorials are starting to become more interesting, and to me it seems like a HongKiat sort of blog, because now, its much more totalistic, than just doing layouts.

  6. I love what JQuery can do, Thank you for the tutorial. Again, in the home page of http://www.tutorialsroom.com :)

  7. The demo is so cool. I love the slide effect and its design. So beautiful. Can you share (or write a tut) about the design?

  8. Hello guys,

    two errors:
    - this demo is not compatible to Safari browser, I had to watch it over FireFox.
    - I cannot even write this reply in this comment window, I have my mouse pressed right now in this space and with other hand I’m writing this comment, otherwise if i click to write, my cursor goes back to the name field…

    Just sharing, it might help to diagnose future problem…

  9. Thanks for your comments

  10. Adrian Gould says:

    Hi there, nice tutorial.

    One issue with Camino 1.6.7 on OSX 10.5.6 – the layout is a bit stuffed – the featured content box is positioned over on the right, not in the document flow.

    Apart from that minor hiccup the demo works nicely.
    Well done!
    Ady

  11. If i was trying to implent this into the gaming layout 6 design and get the news posts at the top to change how would i go about it because i cant seem to get it to work?

  12. @STEPHEN:

    what seems to be your problem, if were going to help you need to provide some more detail

  13. well, i can get the actuall code onto the website, but it either just comes up at the bottom of the page or it messes up my design and moves everything about. And i dont know how to get the picture to appear in it?

  14. Hi there,

    I have 6 slides containg different sections such as WEB DESIGN, SEO ONLINE MARKETING etc. I need to link to a section from an AdWords link, so for example if someone clicked on the e-commerce link from Google AdWords, they would land on the page, but the div that contained the e-commerce content would be shown on the page, not the default 1st div.

    Any ideas. Thanks

  15. Duskolo says:

    great work!
    Love the tutorial!

Leave a Reply