Tuesday, 26 May 2009

How to implement a news ticker with jQuery and ten lines of code

After my previous posts about how to implement a news ticker with MooTools I received a lot of emails from my readers that asked to me to implement a similar feature with jQuery, including fade in and fade out effects, in the simpler possible way. So in this post I want to illustrate you how to implement a nice news ticker using jQuery and just ten lines of Javascript code. The result is something like this:



I suggest you to take a look at this live preview and download the source code to understand how it works. In the source code I added a file called base.html that contains the basic structure of this ticker you can quickly reuse and customize in your web project.





A little introduction
Step 1: image to have a <ul> list with ID = listticker. This list contains some list elements <li> (in this case: My News 1, My News 2, ...). First step is: get the first element of the list, save its content into a var and remove it using a fade out effect.



You can get the HTML code contained into the first element of the list (#listticker) and assign it to a var (first) using this simple code:

first = $('ul#listticker li:first').html();


To use fade out effect and remove the element you can use this code:

.fadeOut('slow', function() {$(this).remove();});


Step 2: now you have to add the content saved into the var first to the end of the list:


You can use this simple code:

$('ul#listticker').append(first)


...where first is the var you used to save the content of the first element in the step 1.

Step 3: Now you have to move up the content of the list (My News 2 is now the first element of the list) and repeat the entire process from the step 1.




In Javascript code section of this tutorial I used setInterval() to repeat the process every 3 seconds (3.000 milliseconds). Ok, now take a look at HTML and Javascript code.


HTML Code
HTML code is really simple. The only thing you have to do is adding an <ul> list with ID = listticker and some list elements:

<ul id="listticker">
<li>My News 1</li>
<li>My News 2</li>
<li>My News 3</li>
<li>My News 4</li>
<li>My News 5</li>
</ul>

Remeber to add into the tag <head> of the page where you want to implement this ticker a link to jQuery:

<script type="text/javascript" src="jquery.js"></script>


Javascript Code
Take a look at the follow code. I implement 2 functions removeFirst() and addLast(). Each function contains five lines of code. Total lines for "conceptual" code: 10 lines! I promised! :)

<script type="text/javascript">
$(document).ready(function(){

var first = 0;
var speed = 700;
var pause = 3000;

function removeFirst(){
first = $('ul#listticker li:first').html();
$('ul#listticker li:first')
.animate({opacity: 0}, speed)
.fadeOut('slow', function() {$(this).remove();});
addLast(first);
}
function addLast(first){
last = '
  • '+

  • first+'';
    $('ul#listticker').append(last)
    $('ul#listticker li:last')
    .animate({opacity: 1}, speed)
    .fadeIn('slow')
    }

    interval = setInterval(removeFirst, pause);
    });</script>


    In the last line I used:

    interval = setInterval(removeFirst, pause);


    ...it calls the function removeFirst()every 3 seconds (3000 milliseconds) and in this way I create ad infinite loop.




    If you have suggestions to improve the code please leave a comment. Thanks!


     
    News ticker with horizontal scrolling
    Fantastic News Ticker Newsvine-like
    Automatic news ticker with vertical scrolling and Start/Resume optionsJoomla! extension: super news ticker

    Read More

    Saturday, 23 May 2009

    Useful Adobe Flash frameworks and graphical engines for developers

    Are you an Adobe Flash developers? In this post you can find some really interesting Flash frameworks and graphical engines that help you develop quickly complex Rich Internet Application and Flash-based games. This list includes graphic UI elements, Flash and Flex components, a physical engine and an open source component to create isometric games with Flash.


    Gaia Framework
    Gaia is an open-source front-end Flash Framework for AS3 and AS2 designed to dramatically reduce development time. Gaia is targeted at anyone who develops Flash sites. It provides solutions to the challenges and repeated tasks we all face with front-end Flash site development, such as navigation, transitions, preloading, asset management, site structure and deep linking. It provides speed and flexibility in your workflow and a simple API that gives you access to its powerful features. For an example of Gaia-made website take a look at Inglorious Basterds Official Site.

    Progression
    Progression is a real powerful framework for Adobe Flash with focus on your creative work. You can just focus on user experience matter, how to transit, what dramatical effects you want to provide for your UI. Progression supports wide range of developing styles - from traditional timeline-based style to stylish class-based style. Progression packages all necessary functions of Web site development as component. You can develop web site using the component by drag & drop on the stage.

    Yahoo! ASTRA
    Yahoo! ASTRA, is an ActionScript Toolkit for Rich Internet Applications. It provides a collection of Flash and Flex components, code libraries, toolkits and utilities developed by Yahoo! for ActionScript developers.

    ARP
    ARP is an open source pattern-based Rich Internet Application framework for the Adobe Flash Platform. ARP currently supports Adobe Flash and Flex-based RIA development in AS 2 and AS 3 and is designed to be simple to use and lightweight.

    JSwiff
    The aim of the JSwiff project is to create an open source, pure Java framework for Macromedia Flash file creation and manipulation.

    PushButton
    The PushButton Engine is an Open Source, Flash game engine and framework that's designed for a new generation of games. PushButton Engine makes it easy to bring together great existing libraries and components for building Flash games. Spend less time on code, more time on building fun games.

    Fisix Engine
    The Fisix Engine is a 2D verlet physics engine for Flash. It is written completely in AS3 in order to make use of flash player 9’s improved cpu capabilities. Although Flash is still slower than platforms such as c/c++, or java, which means that you most likely won’t be able to make the next Half-Life in flash, it doesn’t mean you can’t do really cool stuff with 2D particles, constraints, rigid bodies, etc. and make great looking games and simulations. Take a look at the demo here. The result is really awesome.
    FFilmation
    FFilmation is a really impressive, open source, Flash Engine to create isometric locations for Flash-based games.


    Related Content
    - 7 Powerful image carousels for web designers
    - Useful scripts and resources Facebook-inspired for web developers
    - Best Image Croppers ready to use for web developers
    - 10 Beautiful Web UI libraries
    - File uploaders collection for web developers
    - Interesting html FORM Validators for web developers

    Read More

    Wednesday, 20 May 2009

    How to manage a small web project: a simple approach

    Some times ago I wrote a post about a structured process you must know to develop a web application and many readers asked to me to write something simpler about how to manage a small web project. I think there are not general rules for that but, without doubt, a correct approach can help you manage your projects more efficently and achieve quickly the final result.

    I prepared this picture that illustrates a simple process with 3 main phases you can use as reference to manage a small web project:



    1. Planning

    Plan what you have to do, how you have to do it and in which time.

    1.1 Define project scope

    First step: Identify 4-5 high-level points which define the scope of your project. Don't underrate the importance of this step because if you are able to describe your project in a nutshell, it means you have a clear idea about what you have to do. So it will be simpler to realize it.

    1.2. Identify main features to implement

    Second step: Identify main features of your web project and add, for each of them, some details such as relationships, general notes, ecc. For example image to have a simple project with only two main features: user login and profile management. You can represent them in this way:



    That's a simplified example only to give you an idea.


    1.3. Define sitemap

    Next step: define a sitemap of your project with files and folder. Be accurate in identifying all files to implement (HTML/PHP page, JavaScript files,...) because they are final deliverables to implement.




    1.4. Plan a daily to-do list

    Set daily milestones using a simple to-do list. So everyday you'll know exactly what you have to do. In this way, you can easy monitor your progress measuring what you did a certain day and what had to do.




    2. Developing and testing

    In this phase: write HTML, CSS, PHP, JavaScript... code and test small portions of code during developing (preliminary test). So it wil be simpler find bugs and errors. When your web application is ready, stress it with a final test to catch errors you didn't find during preliminary test which cause unexpected behaviors .


    3. Publishing

    Now you are ready to publish your project on-line. When your website or web application is on-line do a last test on what you published to assure you that it's all ok. That's all!

    If you have some suggestion please leave a comment, thanks!


    External links
    Take also a look at these links:

    - Software development methodology
    - Agile software development - Wikipedia, the free encyclopedia
    - Manifesto for Agile Software Development


    Related posts
    - Structured process you must know to develop a web application
    - Simple process to estimate times and costs in a web project
    - How to manage a small web project: a simple approach
    - Simple process to estimate times and costs in a web project
    - The Deming Cycle: an application to web design

    Read More

    Tuesday, 19 May 2009

    What do you think about the new layout of Woork?

    Hi everyone, how you can see I made some general improvements (... I hope...) to the layout of Woork considering several suggestions I received from you in the past months about the old design of my blog. What do you think about the result? Please let me know, leaving a comment. Thanks!

    Read More

    Thursday, 14 May 2009

    7 Powerful image carousels for web designers

    This post is a collection of some powerful carousels for images and text content ready to use in your web projects. It includes Agile Carousel, YUI Carousel, JCarousel, iCarousel (jQuery + MooTools) and a tutorial about how to implement a simple Flickr-like carousel using Prototype-UI. If you want to suggest other interesting scripts about this topic, please leave a comment. Thanks!

    1. Agile Carousel
    Agile Carousel is a jQuery plugin that lets you create a super fexible carousel with advanced setting options. It supports text and images in each box and a navigator to display in which box you are. Take a look here to see it in action, it's absolutely my favourite!

    2. Yahoo! UI Carousel Control
    The YUI Carousel Control provides a widget for browsing among a set of like objects arrayed vertically or horizontally in an overloaded page region. The "carousel" metaphor derives from an analogy to slide carousels in the days of film photography; the Carousel Control can maintain fidelity to this metaphor by allowing a continuous, circular navigation through all of the content blocks.

    3. jCarousel
    jCarousel is a jQuery plugin for controlling a list of items in horizontal or vertical order. The items, which can be static HTML content or loaded with (or without) AJAX, can be scrolled back and forth (with or without animation).

    4. jCarousel Lite
    jCarousel Lite is a jQuery plugin that carries you on a carousel ride filled with images and HTML content. Put simply, you can navigate images and/or HTML in a carousel-style widget. It is super light weight, at about 2 KB in size, yet very flexible and customizable to fit most of our needs.

    5. Simple images carousel to create Flickr-like slideshows
    This tutorial illustrates how to implement a simple images carousel to create a Flickr-like slideshow using Prototype-UI framework.

    6. iCarousel
    iCarousel is a powerful carousel built over MooTools v1.1 fully configurable from the user just in some steps. You can change any default option just initializating the class with an object in JSON. It's tested in Internet Explorer, Firefox, Opera and Safari.

    7. Carousel.us
    Carousel.us is an advanced Javascript 3D carousel which uses either MooTools framework and Reflection.js by Christophe Beyls, or Prototype.js and Script.aculo.us frameworks with Reflection.js. Take a look here to see it in action.



    Useful scripts and resources Facebook-inspired for web developersBest Image Croppers ready to use for web developers10 Beautiful Web UI librariesFile uploaders collection for web developersInteresting html FORM Validators for web developers

    Read More

    ColoRotate: browse and create your color palette in 3D

    ColoRotate is a free online service that has some similarities to Adobe Kuler, but is different in that it's in 3D. Users can browse color palettes, create new palettes, and share palettes with others in the ColoRotate community.

    Using ColoRotate 3D interface, you can quickly see the multidimensional nature of your colors and the relationships between colors in a way that matches how your eye and brain perceive color and change your colors one at a time, blend two colors together, or transform a full palette of colors all at once with contrast and color joysticks — adjustments that previously have been beyond your reach. With ColoRotate’s quick drag-and-drop you can adjust hue, brightness, and saturation. Import and export in Adobe Swatch Exchange (ASE). Soon, you’ll be able to save even more time with a Photoshop Plugin.



    You can also post on-line your palettes, and tag palettes to engage with the ColoRotate community, or discussions. In the future, look for features like comments and ratings.
    ColoRotate has an intuitive interface that eliminates the need to memorize or jot down color combinations or numbers. Indeed, you can traverse across an open three-dimensional color space and choose (or design) the color palette that fits your needs. In the process, you can uncover color relationships that give your designs an aesthetic balance that will please the most discriminating eye.


    Related Content
    - Best resources on-line for color schemes generators

    Read More

    Thursday, 7 May 2009

    How to implement a Post-to-Wall Facebook-like using PHP and jQuery

    In the past months I received a lot of request to write a tutorial for beginners in order to explain how to implement a Post-to-Wall Facebook-like. So, I prepared this very simple example which helps everyone understand how to implement this feature in a website using just some lines of PHP and JavaScript code.

    Take a mind, every post in the Facebook Wall contains a lot of information (user, sender, message content, date, number of comments, ...):


    But how I said, this tutorial is for Ajax/jQuery/PHP beginners. So I decided to simplify the original Wall using just a single information: the message content.





    In this tutorial we have these files:
    - confing.php (database connection parameters)
    - index.php
    - insert.php
    - jquery.js
    How the Wall works?



    index.php contains a form with id "submit_form" with an input text with id "message_wall". When an user submits a new message. Then the new message is appends to top of the ul list with id "wall" with a nice fade-in effect (with jQuery). Ok, now take a look at the code.


    1. index.php
    index.php is very simple and contains just simple HTML code:

    <form id="submit_wall"&gt;
    <label for="message_wall">Share your message on the Wall</label>
    <input type="text" id="message_wall" />
    <button type="submit">Post to wall</button>
    </form>

    <ul id="wall">
    </ul>

    The <ul> list with id "wall" is the "container" of messages which are posted into the wall.


    2. JavaScript Code
    Open index.php and include jQuery in the <head> tag of the page:

    <script type="text/javascript" src="jquery/jquery.js"> </script>

    ...then add this simple function to enable Ajax functionalities to insert the message posted from the user into a database table without reload the page:

    <script type="text/javascript">
    $(document).ready(function(){
    $("form#submit_wall").submit(function() {

    var message_wall = $('#message_wall').attr('value');

    $.ajax({
    type: "POST",
    url: "insert.php",
    data:"message_wall="+ message_wall,
    success: function(){
    $("ul#wall").prepend("<li style="display: none;">"+message_wall+"</li>");
    $("ul#wall li:first").fadeIn();
    }
    });
    return false;
    });
    });
    </script>

    .prepend(...) is a jQuery function to insert elements inside, at the beginning, of a specific element (in this case UL list with id wall -->$("ul#wall")). When the new message is added into the list is hidden (display:none). Then it appears with a fade-in effect:

    $("ul#wall li:first").fadeIn();

    ul#wall:first: gets the first li element (the last added) into the ul list with id "#wall".


    3. insert.php
    insert.php contains some lines of PHP code to insert the new message into a database table. In this example I created a table WALL with just one attribute "message". PHP code is very simple:

    <?php
    if(isset($_POST['message_wall'])){
    /* Connection to Database */
    include('config.php');
    /* Remove HTML tag to prevent query injection */
    $message = strip_tags($_POST['message_wall']);

    $sql = 'INSERT INTO WALL (message) VALUES( "'.$message.'")';
    mysql_query($sql);
    echo $message;
    } else { echo '0'; }
    ?>


    That's all! Download the source code ready to use in your web projects.




    Add a comment for questions or suggestions, thanks!

    Read More

    Wednesday, 6 May 2009

    8 Interesting Adobe AIR applications for web lovers

    I like Adobe AIR. With AIR you can develope rich internet applications that run outside the browser on multiple operating systems. In this post I want to share with you some really interesting Adobe AIR applications for web lovers: this list includes some social-network clients, developer tools, and mashup applications.


    1. TIME 100 desktop application
    TIME 100 allows you to access to the complete archive of past and present honorees on the TIME 100 annual list of the “World's Most Influential People”.



    I think it's one of the most interesting applications actually in circulation. Take it a look!


    2. DestroyTwitter
    DestroyTwitter is a robust but compact Twitter application built on the Adobe AIR platform. It consists of a series of canvases that constantly update to keep tweets current and up-to-date using notifications that appear immediately after a new tweet arrives.



    DestroyTwitter also features complete direct messaging functionality. Messages and tweets can be replied to with the original visible for quick and easy reference. A search function is also available to track anything that's being talked about.


    3. Feedalizr
    Feedalizr is a social media desktop client that keeps track of updates from friendfeed, twitter, facebook, Flickr, Twitpic & jaiku. It offers full support for these services so that users can interact, i.e. comment, like, favorite, tweet, reply etc. and their updates are instantly reflected on the services website and added to their stream.




    4. Skimmer
    Skimmer is an Adobe AIR desktop application designed to streamline, beautify, and enhance the experience of participating in your most frequently used social networking activities.



    It improves upon your day-to-day interaction with multiple social networks, removing distractions and providing a rich experience that is particularly suited to multimedia content.


    5. Icon Generator
    Icon Generator is a little application that lets you generate a CS3 or Web 2.0 style icon, only 3 step. Pick color, type characters, and save it. Just create 4 different sizes of the icon.



    6. Kuler Desktop
    Kuler is an online application to create and share color harmonies. With this AIR application you can search and import Kuler themes directly into Creative Suite 3 Illustrator, InDesign, and Photoshop.


    You can also view the highest tated, most popular, newest, and randomly selected themes. Drag and drop themes as transparent "tear offs," to scale and view over any application.


    7. Lita
    Lita is an administration interface for SQLite databases. It lets you edit your databases structure and data in a dedicated environment.



    With Lita you can open, create, compact databases; create, rename, delete, and empty tables; Easily run, import and export your custom SQL statements.


    8. Bookmash
    Bookmash is a mashup application which allows you to find quickly videos, music, photos, people and news on line.



    Any suggestions about other interesting AIR applications? Please leave a comment!

    Read More

    Sunday, 3 May 2009

    5 Free Flash video and audio (mp3) players for the web

    Are you looking for a custom and simple solution to embed your videos or MP3 files into your web pages using a custom Flash player? Take a look at this collection with the most popular, useufl and free Flash video and audio players ready to use in your web site or blog.

    1. Flowplayer
    Flowplayer is an Open Source (GPL 3) video player for the Web. Use it to embed video streams into your web pages. Built for site owners, developers, hobbyists, businesses and serious programmers.


    2. JW FLV Player
    The JW FLV Player is the Internet’s most popular and flexible media player. It supports playback of any format the Adobe Flash Player can handle (FLV, MP4, MP3, AAC, JPG, PNG and GIF). It also supports RTMP, HTTP, live streaming, various playlists formats, a wide range of settings and an extensive javascript API.


    3. Flash Video Player Plugin for WordPress
    This Flash Video Player Plugin for WordPress is ideal to embed quickly your video into your Wordpress Blog. It supports custom skin, watermark logo, poster frames and floating controls.



    In order to use this plugin unpack it and transfer the flash-video-player folder into your wp-contents/plugins folder and activate the Flash Video Plugin in your WordPress admin panel. You can find more info here.


    4. WP Audio Player
    WP Adudio Player is a WordPress Plug-in to play MP3 file directly into your post. It's simple to use and customize. This is the default skin:



    You can also use this plug-in in a non-WordPress website following this tutorial.


    5. XSPF Web Music Player
    XSPF Web Music Player is a flash-based web application that uses xspf playlist format to play mp3 songs. XSPF is the XML Shareable Playlist Format. The software is written in Actionscript 2.

    Read More

    Friday, 1 May 2009

    My Tiny TodoList | A simple open source todolist written in PHP and jQuery

    My Tiny TodoList is a totally free, simple open source todolist written in PHP and jQuery released from Max Pozdeev and based on my original MyToDoList application.

    Using MyTiny TodoList you can add, modify or delete tasks, mark a task as completed and set task priority. Max improved a lot the interface with some nice jQuery effects and other general improvements. The result is very interesting and I suggest you to take it a look.

    Max Pozdeev MyTinyTodoList Website
    MyTinyTodoList Demo




    Some screenshots:







    Install My Tiny TodoList

    1. Download, unpack and upload to your site.
    2. If you want to use Mysql database instead of Sqlite - uncomment the line begining with $config['mysql'] in file 'init.php' and specify your settings as described in file.
    Otherwise sqlite database file 'todolist.db' will be created in directory 'db'. If no - create it manually and make it writeble for webserver/php.
    3. Open in your browser file 'dba.php' from your site and create tables in databse.
    4. Open 'index.php' in your browser to run the application.

    Read More