AJAXed WordPress 1.21 released…finally.
After much delaying and dragging of feet and delaying of the third kind, AJAXed WordPress version 1.21 has been released with much fanfare and reader appreciation. This version introduces full AJAX navigation, better support for embedded JS in AJAX-loaded pages, and Italian language support.
The new version of the navigation module was commissioned and paid for by DJ Nightlife (may he be blessed with many children who don’t go through the “terrible-twos”.) AJAX Navigation has been available in AWP for several years now, but it was primitive and unfinished. Its use was limited to very specific websites that were capable of embracing its flaws. I’d like to thank him for his support of the project, and I would encourage any other users to consider commissioning features both for yourself and the AWP community at large.
I wanted to see how small you could make a fully functional AJAX script that worked cross-browser and degraded gracefully, so I went through an old custom AJAX script and made it as small as I possibly could. In the resulting AJAX scripts, the post version is 410 characters and the GET version is only 359 characters long. The scripts are fully functional and accept the following parameters: URL, DATA (in string form), and ELEMENT (to update).
The scripts could be a little smaller, but it would really kill readability.
“Get” AJAX Script
function a(l,d,u){try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}if(r){r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}r.open('GET', l+'?'+d, true);r.send(d);}}
“Post” AJAX Script
function b(l,d,u){try{r = new XMLHttpRequest();} catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');} catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}if(r){r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){document.getElementById(u).innerHTML=r.responseText;}}r.open('POST', l, true);r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');r.send(d);}}
Combined AJAX Script
This combined script also accepts a fourth parameter ‘p’ that should evaluate true if the data is to be sent by post.
function a(l,d,u,p){try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}if(r){r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}if(p){r.open('POST', l, true);r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');}else{r.open('GET', l+'?'+d, true);}}}
Demo: (Sorry but you will have to go to the full page so the JavaScript is loaded.)
One of my readers recently asked how I created my horizontal menu bar: the short answer is by mixing CSS and Javascript.
The first step is to get WordPress to display the menu as a hierarchical list without a title. <?php wp_list_categories('sort_column=name&sort_order=asc&style=list&children=true&hierarchical=true&title_li=0'); ?>
We then wrap this WordPress code in the following so we can style it.
<div style="text-align:center;"><ul id="menu" style="padding:0; margin:0;"><?php wp_list_categories('sort_column=name&sort_order=asc&style=list&children=true&hierarchical=true&title_li=0'); ?></ul></div>
I added this to my header.php, but you can add it anywhere you want it to appear.
The CSS is fairly simple and you just need to add it to your theme’s style.css file.
ul#menu {margin: 0;padding: 0;list-style: none;width: 100%;font-size:1.2em;}ul#menu li {float: left;padding: 0;margin: 0;border-right:solid 1px #fff;}ul#menu ul li {float: none;position: relative;border-bottom: 1px solid #7EAED7; /* fixes gap problem in IE */border-left: 1px solid #FFF;z-index:1000;}ul#menu li ul {margin: 0;padding: 0;display:none;list-style: none;position: absolute;background: #9CC;}ul#menu ul ul{margin-left: .2em;position: absolute;top: 0; /* if using borders, -1px to align top borders */left: 100%;}ul#menu * a:hover, ul#menu li a:active{background:#7EAED7 !important;color: #FFFFFF;}ul#menu li a:link,ul#menu li a:visited,ul#menu li a:hover,ul#menu li a:active{display: block;padding: .2em .3em;text-decoration: none;background: #5587B3;color: #FFFFFF;}ul#menu ul li a:link,ul#menu ul li a:visited,ul#menu ul li a:hover,ul#menu ul li a:active {width: 8em;}- Use the following to copy and paste the code.
Of course you will need to change the colors and text sizes to ensure it blends with the rest of the theme.
AJAXed WordPress version 1.23 has been released. This version introduces French and Spanish support as well as compatibility with WordPress 2.6.
Changes in aWP Version 1.23
Lots of little stuff.
AJAXed Wordpress (AWP) harnesses the power of both AJAX and Wordpress to improve the user experience, the administration capabilities and the design potential of any Wordpress based blog. It works on all WordPress versions from 2.1 - 2.6.
Some of AWP’s features include loading posts inline, inline comments, threaded comments, AJAX comment submission, AJAX Navigation, live comment preview and much more. AWP is endlessly customizable and extensible. Even though AWP provides many features, you are never forced to use features that you don’t want. All aspects of the plugin are easily customized through a single Administration panel.
What are some of the other benefits to using AWP?
AWP is completely free. Free to use, free to play with, and free support. The continued development of this project is supported by voluntary user donations.
AWP is easy to use. The basic setup of AWP is very simple to use.
DIY Javascript Effects Library
As part of a project I needed an extremely light-weight special effects library that would allow queuing of effects (required), multiple effects, the ability to set a per-effect “framerate”, and enough extensibility to fill any need, but it had to be independent of any Javascript library or OS.
For the “core”: I needed it to be able to queue effects to run one after another, but still be able to run effects synchronously with their own queues. Setting up the effects should take no more than a few lines, and the library should be easy adapted to the website or app it is currently running on. The library must also be cross browser, run well on lower end computers, and very very small (the main reason for creating it was as a replacement in a project for people who didn’t want to use jQuery or Scriptaculous just for the effects.) The core should be able to do everything with only being told the element’s ID, whether we are showing or hiding it (if applicable), and the effect to use.

