Tag Archive: jQuery

My Latest Project

I have been volunteering at ICAF (International Child Art Foundation) since April of this year. When I first started off, I was assigned to be a video editor to edit pre-recorded videos for some international festivals. The reason why I selected this position is probably because I put the video editing skill on my resume :) I used Kdenlive and Openshot interchangeably to edit these videos. Sometimes I also used Audacity to sync between left and right channel of the videos.

After three months of video editing, I was just beginning to love to edit videos. However, I assigned to redesign the gallery page on the ICAF website two weeks ago. This is my second web development challenge. My first challenge was to build the first website for another non-profit organization. Although that project was abandoned long time ago because the interruption of school work, I learned the existence of server-side scripting at that time and wrote the first PHP application, the contact form on my website. This time I need to place thousands of children’s artworks and some other pictures to the gallery page in an organized layout.

I know that I have to use pagination for this project. It’s my first time to create pagination pages using PHP. The original design shown below was using JqPageFlow jQuery plugin to implement the pagination as the user scroll down the page.

ICAF Gallery Original Desgin

ICAF Gallery page original design

After some more research, I thought that the infinite scrolling is not good for bookmarking since the manager specifically pointed out that he wants to have a back button for each page. Therefore I revised the design to use the traditional pagination method similar to Google:

ICAF revised gallery layout

Revised ICAF Gallery page layout

Note: The next three linked pages are no longer available as I’ve lost them. Sorry for the disappointment.

Based on the above design, I wrote a test page to test my pagination code. This page is still under development. I will integrate the code into the original page once I completed the testing stage. You can download the source code for this page here (I didn’t include the image files since these images are over 1.5 GB). Note that I used exec PHP function to execute ‘ls’ Linux command to output the image file names to an array rather than use a loop or a database table to process file names. This page also contains a script to split different parts of the file name since these names followed a specific pattern: “country-firstNam_lastName-age-thumb.png” as well as some knowledge I got from the C for loop tutorial. Also note that this is the test code, meaning that I haven’t added extensive comments to the code yet.


Site Menu Animation Prototype

I have been playing around with MooTools recently and came up with an idea to allow users to change the orientation of the menu for my updated site with animation. MooTools is an Object Oriented JavaScript framework similar to jQuery. The main reason I chose this framework instead of jQuery is that it can easily create customized animations. Although I’m still learning how to use MooTools’ full features, I wrote a HTML page that toggles between vertical and horizontal menu with custom animations just by using MooTools framework. Note that this is a prototype to the upcoming updated site menu. It only contains the background color and doesn’t contain any content. Here is the MooTools code for the page:

window.addEvent("domready", function() {
         $("change").addEvent("click", function() {
             var changeMenu = new Fx.Tween($('menu'));
                 .chain(function() {
                 .chain(function() {
                     changeMenu.start("left", "10px");
                 .chain(function() {
                     changeMenu.start("top", "40px");
                 .chain(function() {
             return false;
          $("hori").addEvent("click", function() {
             var changeMenu = new Fx.Tween($('menu'));
             changeMenu.start("top", "50px")
                 .chain(function() {
                     changeMenu.start("left", "100px");
                 .chain(function() {
                 .chain(function() {
                 .chain(function() {
             return false;

Notice that I used CSS property names and MooTools functions to create animations. You can view the whole source code by right-click the prototype page since it is just a plain HTML and JavaScript page.

I created this prototype with the help of MooTools 1.2 Beginner’s Guide and MooTools Docs.

10 jQuery Code Snippets to use instead of using jQuery Plugins

There are lots of jQuery plugins available around the web that can simplify your coding. However, some of the plugins can easily implemented using only jQuery. This article lists the top 10 jQuery code snippets that uses only jQuery to achieve the same effect as using plugin including:

  • Disable right-click
  • Disappearing search field text
  • Opening links in a new window
  • Detect browser
  • Preloading images
  • CSS Styleswitcher
  • Columns of equal height
  • Font resizing
  • Get the mouse cursor x and y axis
  • Verify if an Element is empty

For the code snippets for the above effects, as well as their usage explanation, please read the original article.

9 jQuery Plugins to Enhance Web Design Creativity

Note: Some of the links in this post no longer exists. They have been crossed out.

I just read an article (http://blarnee.com/wp/10-new-jquery-plugins-to-inspire/) about 10 jQuery plugins that can help to increase the creativity of web design (noted that there are actually 9 jQuery Plugins instead of 10 jQuery plugins mentioned on the article title) Some of these plugins have cool animation and some have nice styles. And since these plugins are open source, you can study their source code and create your own animations and effects. Here is the list of these plugins:

  1. Coda Bubble (http://www.myjquery.co.uk/docs/x/plugins/coda_bubble/coda_bubble.php)
  2. DivCorners
  3. Facebook Style Wall Post
  4. Create an Interactive, Filterable Portfolio
  5. How to Make a Slideshow with a Transparent PNG Frame
  6. Simple Toggle with CSS & jQuery (http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial/)
  7. Captify (http://thirdroute.com/projects/captify/)
  8. Flickr Horizontal Menu (http://www.candesprojects.com/download/flickr-horizontal-menu/)
  9. EncyPlayer – jQuery Fancybox and Flowplayer Intergration

Also noted that in the article, each link to the jQuery plugin web page seems to be directed to jqueryplugins.com, which is a jQuery plugins directory . Right now this website is currently in beta. Therefore, it doesn’t have a RSS feed to track of what are the newest jQuery plugins.

For more information about each plugin, visit the corresponding plugin homepage. Please read the original article (http://blarnee.com/wp/10-new-jquery-plugins-to-inspire/) for an overview for all of the above plugins.

6 Cool jQuery Animation Plugins

Here is a list of jQuery plugins that I found over here (each link below links to the demo page of the plugin):

  1. Blend (http://colorpowered.com/blend/)
  2. Sexy Curls (http://elliottkember.com/sexy_curls.html)
  3. Roundabout
  4. Flip
  5. Quicksand
  6. JQZoom

I personally think that Flip jQuery plugin is best to replace Flash with JavaScript. In the near future, there will be many creative animations written in jQuery. I believe that Flash will be replaced by jQuery and HTML 5 video.

For more information about each of the above plugins, please read the original article.

Animate Objects along Paths using jQuery Path Plugin

jQuery Path plugin animates an HTML element along a specified path, much like Flash motion guide layer. The path can be a curve or a line. You can see a demo on this page and checkout its source code. According to the source code, the syntax for this plugin is integrated to the jQuery animate function:

$(“#div”).stop().animate({path: pathType}, time_in_millisecond);

One disadvantage of using this plugin that I’ve found is that there is no pre-set path type. Fortunately, the plugin documentation explains how to create bezier and arc path, as well as custom path types.

jQuery CSS Browsers Compatibility

Different browsers require different CSS property syntax, especially in CSS 3. In CSS 2, the only property that I know of requires different syntax is opacity property. Firefox called opacity, and IE called filter. You need to set values for opacity and filter properties at the same time. Not only this is inefficient, but it also adds up the size of the CSS file.

Fortunately, jQuery has a css function to make the CSS cross-browser compatible. For example:

   opacity: 0.5

It will auto changed to filter CSS property if the user is running IE.

However, since the new CSS 3 is in the draft mode right now, jQuery has not implemented CSS 3 standard yet. It means that border-radius and other properties that are different from each browser needs to write all of the possible style properties into the CSS file.

For more information about jQuery CSS and a jQuery plugin to support CSS 3 syntax, please read original article.

Using jQuery UI with Google AJAX API

jQuery UI is an User Interface library based on jQuery JavaScript framework. It has cool effect such as make the layers on the web pages draggable and resizable, add dialogs to the page, and add auto-complete feature onto the page. Recently, I noticed that some websites use Google to get the jQuery framework and its UI library. After I googled it, I found out that it is included with Google AJAX API along with other JavaScript Framework such as Prototype and SWFObject. To use it, I need to set up an API key for my domain in order to use Google APIs. Then I added two google.load() functions between the script tag before the body tag.


Note that the second parameter is the version number. I placed version 1 since both jQuery and jQuery UI are at version 1 and it automatically gets the latest version of version 1. Unfortunately,when I’m testing out with this new import method using Google, the resizable() function of jQuery UI did not work. I found out that I need to either create my own stylesheet for the jQuery UI by using jQuery UI’s ThemeRoller, or import the CSS file from Google.

<link rel=”stylesheet” type=”text/css” href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css” />

Note that you need to host your own CSS file if you want to customize the page style.

Google provides an easier way to integrate jQuery and jQuery UI to web pages. This allows me to have latest version of both frameworks without downloading needed files.

Text Gradients Trick Using CSS and a PNG image

A few weeks back I found an useful jQuery plugin called Rainbows to make text gradient. This was an useful JavaScript-based plugin. However, some people disable their browsers’ JavaScript support, make this technique useless. Another technique I discovered today that makes text gradient is by using CSS and a little PNG image. This technique has some advantages and disadvantages over the previous JavaScript technique. First, JS technique has the ability to copy text contained in the gradient where as CSS technique cannot copy the text image and image itself. Second, CSS technique uses basic CSS syntax to achieve this effect by repeat a gradient image vertically where as JavaScript technique borrows JS framework to achieve this effect.

This technique is very easy to create purely using CSS. It uses white gradient background as a background image in order to make this effect working. It’s also cross-browser compatible. The following steps shows how to apply this effect:

  1. First by adding an empty nested span tag after the text you want to make gradient, e.x. <h2>Title<span></span></h2>.
  2. Style the text anyway you want using CSS, except set the position to relative, “position:relative”.
  3. Style the background of empty span to transparent gradient png and repeat-x. That is to set the background image to white gradient background png if you use default white background color.
  4. Lastly, in order to make compatible with other browsers, apply the following CSS styles to the empty span element:
    background-image: url(none.gif);
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="gradient_1.png", sizingMethod="scale");

This technique uses an easier but unusual method to achieve the text gradient effect. Once the text is applied with this effect, the produced image cannot be copied nor selected. The best place to use this effect is on the title of an article or as a logo effect.

To learn more about this technique, visit http://cssglobe.com/lab/textgradient/.