<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dan Wellman &#187; jQuery</title>
	<atom:link href="http://www.danwellman.co.uk/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danwellman.co.uk</link>
	<description>JavaScript and JavaScript Libraries</description>
	<lastBuildDate>Tue, 07 Sep 2010 20:40:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Plugin &#8211; hoverFade</title>
		<link>http://www.danwellman.co.uk/jquery-plugin-hoverfade/</link>
		<comments>http://www.danwellman.co.uk/jquery-plugin-hoverfade/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 19:12:06 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/?p=152</guid>
		<description><![CDATA[I just wrote a new jQuery plugin that adds a fading-in effect when you hover over certain elements. I&#8217;m using it to add the fading rollover states on the top nav and on the social boxes in the footer.
Download

hoverFade The original plugin, unminified, with comments. 1.4 Kb
minified hoverFade A minified version (it also contains the [...]]]></description>
			<content:encoded><![CDATA[<p>I just wrote a new jQuery plugin that adds a fading-in effect when you hover over certain elements. I&#8217;m using it to add the fading rollover states on the top nav and on the social boxes in the footer.</p>
<h3>Download</h3>
<ul>
<li><a href="/scripts/plugins/jquery.hoverfade.js" title="Jquery HoverFade Plugin">hoverFade</a> The original plugin, unminified, with comments. 1.4 Kb</li>
<li><a href="/scripts/plugins/jquery.hoverfade.min.js" title="minified jQuery hoverFade Plugin">minified hoverFade</a> A minified version (it also contains the license, to shrink filesize even more move this into a separate text file) 908 bytes</li>
</ul>
<h3>Usage</h3>
<p>Using the plugin is simple, but there are several steps you should follow:</p>
<ol>
<li>First you should set up standard CSS hover states from the elements you want to add the effect to. This should be done using a class name on the container of the fading elements. This is so that basic CSS hovers are still used if JS is disabled on the client.</li>
<li>Add selectors that show the same background image as the CSS hovers using a different class name. This different class name will be applied to the container and the CSS class name will be removed.</li>
<li>Link to the plugin file from (ideally) the bottom of the page, after linking first to jQuery</li>
<li>Call the plugin method on the same element that the CSS class was added to. if you use the default class names used by the plugin, and call the plugin on a standard list of links the plugin should just work.</li>
</ol>
<p>The plugin contains 5 user-configurable options, all with sensible defaults:</p>
<pre>newClass: "hover-anims", //class added by the plugin
classToRemove: "hover-css", //CSS-fallback class removed by the plugin
onClass: "on", //element with this class is not affected by hovering
trigger: "a", //element that triggers hover animations
faderTemplate: "&lt;span />" //element which animates</pre>
<p>Replace these with the classes you are using, or for minimal config use the same classes in your CSS. The trigger can be another element if you wish. The fader template should be an HTML tag and if inline, such as the default span element, it should feature a closing slash or it will not work correctly in IE. The fader template element is automatcially created and added by the plugin.</p>
<p>Take a look at the CSS I used for either the top nav menu or the social boxes to see how the CSS-fallback and JS classes can be used</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/jquery-plugin-hoverfade/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Adobe-style checkboxes</title>
		<link>http://www.danwellman.co.uk/adobe-style-checkboxes/</link>
		<comments>http://www.danwellman.co.uk/adobe-style-checkboxes/#comments</comments>
		<pubDate>Fri, 28 May 2010 22:57:52 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/?p=146</guid>
		<description><![CDATA[I really like the how layers can be selected in Photoshop and Fireworks by holding the mouse button down and dragging the cursor over the check boxes. I always miss this feature on web forms with more than a few check boxes on them, so I thought it would be a great idea if it [...]]]></description>
			<content:encoded><![CDATA[<p>I really like the how layers can be selected in Photoshop and Fireworks by holding the mouse button down and dragging the cursor over the check boxes. I always miss this feature on web forms with more than a few check boxes on them, so I thought it would be a great idea if it could be replicated.<br />
Adding this functionality is extremely easy, all we need is the following script:</p>
<pre>
&lt;script>
  (function($){

    //listen for mousedowns over target area
    $("fieldset").mousedown(function(e) {

      //stop text selection
      e.preventDefault();

      //stop text selection in IE
      if (window.ActiveXObject) {

        var fset = document.getElementById("checkers");
        fset.onselectstart = function () { return false; }
      }

      //add mouseovers to checkboxes
      $("input[type=checkbox]").mouseover(function() {		

        //toggle checked state
        ($(this).attr("checked") === false) ? $(this).attr("checked", "checked") : $(this).attr("checked", "");
      });
    });

    //stop listening to mouseovers when mouse button released
    $("fieldset").mouseup(function() {
      $("input[type=checkbox]").unbind("mouseover");	

      //stop unselecting text
      $("fieldset").unbind("select");
    });
  })(jQuery);
&lt;/script>
</pre>
<p>Easy right? Let’s look at what we do; first we set a mousedown event on the<br />
<fieldset> because it’s the container of the check boxes and it gives the visitor plenty of target area to click and hold over. To stop any text in the parent container, such as the labels or the legend, from being selected we can use the preventDefault() method for most browsers.</p>
<p>IE will still allow text selection however, so we also need some additional code just for IE. The code is wrapped in a conditional that looks for the ActiveXObject, which I find a quick and easy solution in those rare times that browser detection instead of feature detection is required. To prevent the text being selected in IE we can return false from the onselectstart event which is fired by the browser as soon as any text is selected.</p>
<p>Next we attach a mouseover event to each of the check boxes; whenever this occurs we just test whether the check box is checked and if not we check it. If it’s already checked we uncheck it. Simple.</p>
<p>We also add a mouseup listener to the<br />
<fieldset> so that the check boxes aren’t interacted with after the mouse button is released.</p>
<p>Try it out below.</p>
<form>
<fieldset id="checkers">
<legend>Select or deselect options by clicking and dragging the mouse pointer over the checkboxes.</legend>
<p>       	<label for="option1"><br />
<input type="checkbox" name="options" value="Option 1" id="option1">Option 1</label><br />
        <label for="option2"><br />
<input type="checkbox" name="options" value="Option 2" id="option2">Option 2</label><br />
        <label for="option3"><br />
<input type="checkbox" name="options" value="Option 3" id="option3">Option 3</label><br />
        <label for="option4"><br />
<input type="checkbox" name="options" value="Option 4" id="option4">Option 4</label><br />
        <label for="option5"><br />
<input type="checkbox" name="options" value="Option 5" id="option5">Option 5</label><br />
    </fieldset>
</form>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/adobe-style-checkboxes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Review of jQuery 1.4 by Karl Swedberg and Jonathon Chaffer</title>
		<link>http://www.danwellman.co.uk/review-of-jquery-1-4-by-karl-swedberg-and-jonathon-chaffer/</link>
		<comments>http://www.danwellman.co.uk/review-of-jquery-1-4-by-karl-swedberg-and-jonathon-chaffer/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 21:20:55 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/?p=130</guid>
		<description><![CDATA[I recently read through the newest revision of Karl and Jonathon’s amazing jQuery reference manual, which has just been updated for the latest release of the jQuery library itself. Even though it’s a reference manual used to refer to specific methods or properties of the library rather than a teaching book that takes the reader [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read through the newest revision of Karl and Jonathon’s amazing jQuery reference manual, which has just been updated for the latest release of the jQuery library itself. Even though it’s a reference manual used to refer to specific methods or properties of the library rather than a teaching book that takes the reader on a journey through the API I still wanted to read through it in its entirety in order to give it a balanced review and to see how much additional information it provided. I’m already fairly competent in using jQuery so I wanted to see if there was anything new it could show me. It did – there were subtle aspects to a number of methods that I had never used before, and with the new additions to the guide added for jQuery 1.4, there was actually a lot I took away from this book.</p>
<p><a href="http://www.packtpub.com/jquery-1-4-reference-guide/book/mid/170310y5ia2d?utm_source=danwellman.co.uk&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002738" title="Buy the book!"><img src="http://www.danwellman.co.uk/wp-content/uploads/2010/03/jquery-image.jpg" alt="jQuery 1.4 Reference Guide" title="jQuery 1.4 Reference Guide" width="500" height="610" class="alignnone size-full wp-image-132" /></a></p>
<p>The first chapter served as a very good general introduction to jQuery and what the library is capable of. The whole chapter is dedicated to an interactive example that uses a wide variety of different jQuery methods and functionality, and the accompanying text gradually picks apart all of the code to show what it does. The example is excellent for those new to jQuery and was a very good way to start the book.
<p>After the initial example-based chapter the book switches tone to more of a reference style guide; chapter 2 is a very detailed, quite lengthy chapter that covers all of the different types of selectors that can be used to select elements from the DOM. Many different selectors, including advanced ones like the different types of attribute selectors are covered.
<p>Remaining chapters look at the different types of methods that are exposed by the library; there is a chapter dedicated to DOM traversal methods, another that looks at AJAX-related methods, etc. Helpfully, the book is structured similarly to the online documentation so readers should be able to easily find the method they require information about without too much difficulty.</p>
<p>Towards the end of the book there are chapters that look at the miscellaneous methods such as .grep(), .unique(), etc which don’t fit neatly into any of the other categories, and the different properties of the jQuery object that can give us extra information about the environment that the library is executing in such as the .browser properties. These last chapters will be of huge importance to many developers that are familiar with some of the more common methods, but less familiar with some of these lesser-used methods and properties.
<p>There is also a chapter dedicated to the construction of jQuery plugins; the authors didn’t have to include an entire chapter on this topic as it is sometimes seen as beyond the scope of general jQuery usage. They could have just included some basic information under the miscellaneous chapter perhaps, but they didn’t, they provided a whole chapter to it because the topic deserves a whole chapter. It’s a relatively short chapter, and the example plugins are very light, but it covers all of the essentials for plugin development such as the standard conventions, the object method and global functions, so this chapter adds a lot of value.
<p>The book also features some potentially very useful appendices including lists of useful tools for JS developers such as code minifiers and browser development tools, information about where to find useful JavaScript, (X)HTML and CSS references as well as a complete alphabetical listing of every jQuery method and property.</p>
<p>Overall, I found this an excellent reference book for developers of all levels and would recommend it to anyone that was serious about jQuery development. Bear in mind that it is a reference manual opposed to a recipe-style example-based book, so the style is very concise and sometimes dry. Personally I think this was a good thing as it allowed the book to remain focused on the core topics without going off on a tangent about implementational specifics that the reader may never encounter. It’s highly accessible, very information-heavy and literally covers every single method and property found in the library. This book will stay on my desktop (my real, actual desk) for some time to come and will remain my first point of contact from now on when looking up any method of the library.</p>
<p>My one complaint is that some of the appendix items from previous versions of the book seem to have been removed; for example, there is an information box in one chapter which states ‘An in-depth discussion of closures can be found in Appendix C of the book Learning jQuery 1.3.’ I’m sure many people buying the 1.4 version of the book won’t already have the previous edition so this is not helpful in any way. Leaving this non-essential but related information in the book would have been far better. Sometimes however, due to the limits that are placed on page count by publishers, old, less-related information has to be removed. It’s not a massive complaint, and I can understand why the authors may have had to remove these extras to make room for information relating to all the cool new functionality of jQuery, but I think the book would have benefited from retaining this information if at all possible. </p>
<p><a href="http://www.packtpub.com/jquery-1-4-reference-guide/book/mid/170310y5ia2d?utm_source=danwellman.co.uk&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002738" title="Buy jQuery 1.4 Reference Guide">Buy the book!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/review-of-jquery-1-4-by-karl-swedberg-and-jonathon-chaffer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better Password Fields with jQuery</title>
		<link>http://www.danwellman.co.uk/better-password-fields-with-jquery/</link>
		<comments>http://www.danwellman.co.uk/better-password-fields-with-jquery/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 14:46:19 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/?p=108</guid>
		<description><![CDATA[The &#8216;whether or not to show plain text in password fields for usability&#8217; situation has never really been resolved to my satisfaction; plain-text fields are clearly much more usable and less confusing than obscured passwords, but what if the person using the plain-text field is sat in a public place? Showing their password for just [...]]]></description>
			<content:encoded><![CDATA[<p>The &#8216;whether or not to show plain text in password fields for usability&#8217; situation has never really been resolved to my satisfaction; plain-text fields are clearly much more usable and less confusing than obscured passwords, but what if the person using the plain-text field is sat in a public place? Showing their password for just anyone to see would be ludicrous.</p>
<p>The iPhone style of obscuring everything except the last letter is a good compromise that offers a combination of security and usability, and there are plenty of great guides out there on how to implement this in your web pages.</p>
<p>But it&#8217;s still based on the flawed assumption that the user is always going to be somewhere public. And it&#8217;s not 100% secure anyway because if someone watches each letter as it&#8217;s typed over your shoulder, depending on what the password is, it could be very easy to remember. The point is that we don&#8217;t have to rely on a compromise when a solution is easy to implement.</p>
<p>The solution is to hand the initiative over to the visitor and let them decide for themselves whether to show the password in plain text or not. Then we don&#8217;t have to either use a semi-hidden, semi-secure way of presenting the field, and we don&#8217;t have to make the choice of whether to show plain or obscured text. All we need to do is add a simple link after the password field which will convert the obscured password field to a standard text field, thus revealing the password.</p>
<h3>The code</h3>
<p>Start off with the standard HTML that you would normally use when requiring a visitor to enter their password, probably something like the following:</p>
<pre>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
    &lt;title&gt;Better Password Fields&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form action="#" method="post"&gt;
      &lt;label for="pass"&gt;Password:&lt;/label>&lt;input id="pass" name="pass" type="password"&gt;
    &lt;/form&gt;
    &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;

    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The password field is specified as a password field so that if the visitor has JavaScript disabled the field will be obscured by default &#8211; better to err on the side of caution right?</p>
<p>We haven&#8217;t hardcoded a link to the page that will convert the password field into a plain text field; if JS is disabled the link will be completely useless. The best way to have an element on the page that requires JavaScript be enabled for it to work is to add the element with JavaScript in the first place &#8211; that way if JavaScript is disabled, the useless link won&#8217;t be added.</p>
<p>That&#8217;s all of the underlying HTML that we need &#8211; nothing more and nothing less, the very definition of semantic. Everything else we need we can add using the script, which we&#8217;ll look at next.</p>
<h3>Preparing the form for revealed password fields</h3>
<p>Let&#8217;s setup the initial part of the script which would run on page load; we left an empty script element at the bottom of the HTML, add the following code to it:</p>
<pre>(function($) {
  $("form").find("input[type='password']").each(function(val) {
    var input = $(this);

    //insert link to show plain-text
    $("&lt;a&gt;").text("Show password").addClass("show-plain").attr({
      title: "Show the password in plain text",
      href: "#"
    }).insertAfter(input);
  });
})(jQuery);
</pre>
<p>All of our code will reside within a self-executing anonymous function which we pass the jQuery object into. Our function accepts the jQuery object using the $ parameter so it is safely aliased within the local scope of our function, which should offer protection from any other libraries that may be in use on whatever pages the code ends up on.</p>
<p>All we need to do at this stage is prep our password fields by adding the &#8217;show plain text&#8217; links after each password field. We first select all of the input fields that have a type of password (that&#8217;s just one in this example, but there could be more on pages out in the wild), then for each of the selected elements we create a new anchor and insert it directly after the current input field.</p>
<p>The new anchor has its <strong>title</strong> and <strong>href</strong> attributes set (some browsers won&#8217;t treat it as a link if it doesn&#8217;t have a href), and we give it a class name of <strong>show-plain</strong> (mostly so that we can select it in just a moment but potentially also for styling purposes).</p>
<p>Our page should now look like this, with the new link directly after the password field:</p>
<p><img class="size-medium wp-image-120 alignnone" title="Better Password Fields 1" src="http://www.danwellman.co.uk/wp-content/uploads/2010/02/bp1-300x128.jpg" alt="Better Password Fields 1" width="300" height="128" style="float:none !important"></p>
<p>A simple, unassuming link. Next we need to make our new link(s) work; directly before the last line of code (})(jQuery);) add the following:</p>
<pre>//add click handler for show-plain link(s)
$(".show-plain").live("click", function() {

  //cache selector
  var input = $(this).prev();

  //create new text input
  $("&lt;input&gt;").attr({
    id: input.attr("id"),
    type: "text",
    name: input.attr("name")
  }).val(input.val()).addClass(input.attr("class")).insertAfter(input.prev());
  input.remove();

  //change link text and attributes
  $(this).text("Hide password").removeClass("show-plain").addClass("show-hidden").attr({
    title: "Obscure the text"
  });

  //stop link being followed
  return false;
});
</pre>
<p>We use the <strong>live()</strong> method to add a click handler for the &#8217;show plain text&#8217; link because, as you can probably tell from the code above, the class name of the link changes. Using <strong>live()</strong> means that we don&#8217;t have to re-bind the click event every time we create a new link; the <strong>live()</strong> method uses event delegation which attaches a listener for this event to the specified element&#8217;s parent instead of binding directly to the element itself.</p>
<p>Within the anonymous function added as a parameter to the <strong>live()</strong> method we first cache a reference to the input element directly before the link that was clicked, so the variable will always refer to the correct input element regardless of which link is clicked. We cache it because we&#8217;ll be referring to it several times and we don&#8217;t want to have to select it from the document each time we want to do something with it.</p>
<p>Next we create our replacement text input, which we set to a standard text type so that its contents will be clearly visible. We copy any text that has already been entered into the password field, and any class names that may have been given to it. We then insert the new text field and remove the password field. It&#8217;s the old switcheroo, plain and simple, but it will look as if any text already entered into the password field is magically revealed. The following image shows the two states:</p>
<p><img class="alignnone size-medium wp-image-121" title="Better Password Fields 2" src="http://www.danwellman.co.uk/wp-content/uploads/2010/02/bp2-284x300.jpg" alt="Better Password Fields 2" width="284" height="300"  style="float:none !important"></p>
<h3>Reapplying the obscured text</h3>
<p>Now we just need to add the code that will turn the revealed text back into obscured text, just in case the visitor needs to hide the password again. We&#8217;ve given the choice back to the visitor of whether the password should be visible or not, but we&#8217;d better give them the choice to hide it again too. After the click handler for the show-plain link add the following code:</p>
<pre>//add click handler for show-plain link(s)
$(".show-hidden").live("click", function() {

  //cache selector
  var input = $(this).prev();

  //create new password input
  $("&lt;input&gt;").attr({
    id: input.attr("id"),
    type: "password",
    name: input.attr("name")
  }).val(input.val()).addClass(input.attr("class")).insertAfter(input.prev());
  input.remove();

  //change link text and attributes
  $(this).text("Show password").removeClass("show-hidden").addClass("show-plain").attr({
    title: "Show the password in plain text"
  });

  //stop link being followed
  return false;
});
</pre>
<p>This is pretty much the reverse of what we did in order to show the text; we just remove the plain text field, copying its value, id and any class names, and then replace it with a new input of type password. We also adjust the link again to reflect the new state. We should find that when we load the page we can enter text into the field and switch between plain and obscured text as in the previous screenshot in any common mainstream browser.</p>
<h3>Summary</h3>
<p>In terms of usability nothing can be better than giving your visitors a clear and simple choice; in this case whether or not to show a password in plain text or obscured text. We saw how easy it was to add this simple solution to a page &#8211; just a couple of lines of code. So instead of offering a compromise we can offer a solution, and improve the usability and effectiveness of password fields on our sites at the same time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/better-password-fields-with-jquery/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Review of jQuery 1.3 with PHP by Kae Verens</title>
		<link>http://www.danwellman.co.uk/review-of-jquery-1-3-with-php-by-kae-verens/</link>
		<comments>http://www.danwellman.co.uk/review-of-jquery-1-3-with-php-by-kae-verens/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 19:54:57 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/?p=100</guid>
		<description><![CDATA[
jQuery 1.3 with PHP by Kae Varens is a great book that shows you how to interface jQuery with PHP. It&#8217;s different from any other web development book I&#8217;ve read because it approaches things from the opposite perspective that I personally am used to – from the server to the client. It&#8217;s aimed at competent [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/jquery-1-3-with-php/book" title="jQuery 1.3 with PHP by Kae Verens"><img src="http://danwellman.co.uk/img/jqueryphp.jpg" alt="Jquery 1.3 with PHP by Kae Verens"></a></p>
<p>jQuery 1.3 with PHP by Kae Varens is a great book that shows you how to interface jQuery with PHP. It&#8217;s different from any other web development book I&#8217;ve read because it approaches things from the opposite perspective that I personally am used to – from the server to the client. It&#8217;s aimed at competent PHP developers that want to learn how to use jQuery. Strictly speaking I&#8217;m outside of the scope of who the book is aimed at, but fortunately I just enough PHP to follow along with the examples and know roughly what is happening in the server-side code. It is made clear very early on who the book is aimed at.</p>
<p>One thing that I really liked about this book was that as well as the strong focus on jQuery throughout (as you&#8217;d expect) the author also included not just one, but several different examples of using jQuery UI in conjunction with PHP. jQuery UI is the official UI library for jQuery so I think it&#8217;s important that it should be covered in this kind of book, even if only briefly.</p>
<p>The book is broken down into the following chapters:</p>
<p><strong>Chapter 1</strong> eases you into the book with sections on what jQuery is, why you should be using it and how it integrates with PHP. Some popular web applications that use jQuery are looked at and the author shows how to set up a directory structure so that the examples in the book can be replicated.</p>
<p><strong>Chapter 2</strong> covers some quick tips that server-side developers can use in order to help bridge the gap between the client and the server. Examples include how to make select boxes dynamically load options when required, contextual help tips, and inline editing of a page&#8217;s content.</p>
<p><strong>Chapter 3</strong> looks at the tabs and accordion widgets from jQuery UI and shows not only how to load their contents dynamically, but also how to create them on the fly with the server. This is a very thorough and detailed chapter and I really liked the code examples here.</p>
<p><strong>Chapter 4</strong> focuses on forms and form validation; it shows how to use the jQuery validation plugin in order to perform some validation on the client before involving the server (such as checking for empty fields which are required), and how to complete the validation on the server. Another code examples shows how to easily create an awesome auto-complete text-field.</p>
<p><strong>Chapter 5</strong> is another very thorough and in-depth chapter dominated by code examples; it shows how to create a file management system that allows for creating, moving and deleting directories on the server and uploading, moving and deleting files. This was probably my favourite chapter of the book.</p>
<p><strong>Chapter 6</strong> shows you how to create an entire calendar application that allows you to add, delete and move events and how recurring events can be handled.  This is a great practical chapter that uses some interesting plugins including the jquery-week-calendar and the jQuery UI dialog. The example really highlights how to make these plugins work with server efficiently.</p>
<p><strong>Chapter 7</strong> covers image manipulation such as cropping, resizing and rotating. Jorn Zaefferer&#8217;s treeview plugin is used in conjunction with some of the file management app created in chapter 5 to  show the images available, while the actual manipulations are performed with the ImageMagick PECL extension.</p>
<p><strong>Chapter 8</strong> looks at the client-side heavy jQuery UI interaction helper sortable; so far the jQuery UI components the book has looked at have all been UI widgets so it&#8217;s great that this is included as well. Drag and drop, a very client-side oriented task, is looked at in detail and there is probably less server-side code in this chapter than in any other, which must be incredibly useful for those more used to working with the server.</p>
<p><strong>Chapter 9</strong> looks at displaying large sets of tabular data efficiently and uses the dataTables jQuery plugin to allow pagination, sorting, filtering and column re-ordering. There are some interesting (for me) server-side concepts in this example such as caching and how to load data is small chunks, but a server-side developer would probably know this already. The client-side code examples were quite extensive as well though and would help server-side developers use the dataTable plugin effectively.</p>
<p>The final chapter, <strong>chapter 10</strong> looks at a series of examples that show how client-side code can be optimised to improve the user experience; it&#8217;s a fast paced chapter with a lot of small examples and contains some real gems of information.</p>
<p>Overall this is a great book with very thorough and well-explained examples and plenty of code that the average server-side developer could take away and reuse. As a front-end developer I&#8217;m completely the opposite of who the book is aimed at but it was clear that the descriptions of using jQuery would be of value to PHP developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/review-of-jquery-1-3-with-php-by-kae-verens/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Plugin &#8211; jMailer</title>
		<link>http://www.danwellman.co.uk/jquery-plugin-jmailer/</link>
		<comments>http://www.danwellman.co.uk/jquery-plugin-jmailer/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 12:32:23 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/wpstaging/wordpress-2.8.4/wordpress/?p=64</guid>
		<description><![CDATA[jMailer is a plugin for jQuery I wrote that provides the visitor with a popup email form. It should be attached to a link element and when that link is clicked, the popup appears centered in the viewport.
Within the popup is a form which let&#8217;s the visitor enter an email address they want to send [...]]]></description>
			<content:encoded><![CDATA[<p>jMailer is a plugin for jQuery I wrote that provides the visitor with a popup email form. It should be attached to a link element and when that link is clicked, the popup appears centered in the viewport.</p>
<p>Within the popup is a form which let&#8217;s the visitor enter an email address they want to send the email to, their email adress so that the recipient can reply directly to them, a subject box and a message box.</p>
<h3>jMailer Example</h3>
<p>The &#8216;Contact Me&#8217; tab at the top of this site has the plugin attached; click it to see the popup form and send me a message <img src='http://www.danwellman.co.uk/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> <br />
The To field has been mapped to my own mail address in the back-end so messages will only come to me.</p>
<p>You should also note that the plugin constitues just the front-end. A back-end of your choice (PHP, .NET, etc) can be attached to do the physical sending of mail.</p>
<h3>jMailer Features</h3>
<p>The current release (1.1) of jMailer has the following features:</p>
<ul>
<li>Automatic modality</li>
<li>Automatic iFrame shim when IE6 is used</li>
<li>Configurable opening and closing animations</li>
<li>AJAX sending of form data to the back-end and confirmation message</li>
<li>Basic error checking for non-completed fields</li>
</ul>
<h3>jMailer Usage</h3>
<p>Using the plugin is simple: <a href="../scripts/jquery.jmailer.js" title="Source Files">Download</a> the source file and ensure you have a copy of the jQuery library to hand (min version 1.2.6).</p>
<p>Then just attach the plugin to the link using standard jQuery syntax:</p>
<pre>$("#mailerLink").jMailer();</pre>
<h3>jMailer Configuration</h3>
<p>A configuration object can be supplied in the constructor to configure various options:</p>
<pre>var config = {
  modal: true || false //defaults to true
  id: "a string" //defaults to "mailer"
  shim: true || false //defaults to false unless IE6 in use
  forceShim: true || false //defaults to false
  defaultClass: "a string" //defaults to "mailer-container"
  additionalClass: "a string" // defaults to null
  suppressTo: true || false //defaults to false
  animation: hide || slideUp || fade //defaults to hide
}

$("#mailerLink").jMailer(config); </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/jquery-plugin-jmailer/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>jQuery Plugin &#8211; jPoll</title>
		<link>http://www.danwellman.co.uk/jquery-plugin-jpoll/</link>
		<comments>http://www.danwellman.co.uk/jquery-plugin-jpoll/#comments</comments>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<dc:creator>Dan Wellman</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.danwellman.co.uk/wpstaging/wordpress-2.8.4/wordpress/?p=75</guid>
		<description><![CDATA[jPoll, with an accompanying nettuts+ screencast, provides a &#8216;poll&#8217; widget which can be used to ask your visitors a brief question. The widget will create and render a form inside a designated container and then monitor the form for submission.
When the form is submitted,the results are passed to a backend file which processes the response [...]]]></description>
			<content:encoded><![CDATA[<p>jPoll, with an accompanying nettuts+ screencast, provides a &#8216;poll&#8217; widget which can be used to ask your visitors a brief question. The widget will create and render a form inside a designated container and then monitor the form for submission.</p>
<p>When the form is submitted,the results are passed to a backend file which processes the response (I used PHP and MySQL, although other languages and database servers are available). The widget is just the frontend of the application, you must supply the backend.</p>
<p>Once the visitor&#8217;s choice has been saved, the results of the poll are then passed back to the widget as a JSON object and the widget displays the results using nice animations.</p>
<h3>Example</h3>
<div id="pollContainer"></div>
<h3>Features</h3>
<p>The first release of jPoll comes with the following features:</p>
<ul>
<li>Automatic error message for submission before choice is made</li>
<li>AJAX sending and receiving of selection and results</li>
<li>Built-in result animations</li>
</ul>
<h3>Usage</h3>
<p>All you need to do on the webpage is supply a container element with an id:</p>
<pre>&lt;div id="container"&gt;&lt;/div&gt;</pre>
<p>Then in your script, just call the jPoll constructor supplying a literal configuration object containing the customised properties:</p>
<pre>$("#container").jPoll({ ajaxOpts.url: "myBackend.php", groupIDs: ["A Question", "Another Question", "Etc..."] });</pre>
<p>All of the properties have defaults, but some are fairly generic. The config section below shows all of the properties and their default values.</p>
<p>Note that this is just the front-end &#8211; you must have a database setup to store the results in and you need an accompanying PHP script that gets and set the results in the database.</p>
<h3>Config</h3>
<pre>var config = {
  ajaxOpts.url: "a string" //defaults to "poll.php"
  groupName: "a string" //defaults to "choices"
  groupIDs: ["an array"] //defaults to ["choice0", "choice1", "choice2", "choice3", "choice4"]
  pollHeading: "a string" //defaults to "Please choose your favourite:"
  rowClass: "a string" //defaults to "row"
  errors: true || false //defaults to true
}

$("#container").jPoll(config);</pre>
<h3>Example PHP</h3>
<p>The PHP used in conjunction with this example stores the results of the poll in a MySql database, but if you wanted you could do anything you wanted with the data. Here is the PHP used in this example:</p>
<pre>&lt;?php

	//db connection details
	$host = "localhost";
	$user = "username";
	$password = "password";
	$database = "database_name";

	//make connection
	$server = mysql_connect($host, $user, $password);
	$connection = mysql_select_db($database, $server);

	//get post data
	$selected = mysql_real_escape_string($_POST['choice']);

	//update table
	mysql_query("UPDATE results SET votes = votes + 1 WHERE choices = '$selected'");

	//query the database
	$query = mysql_query("SELECT * FROM results");

	//loop through and return results
	for ($x = 0, $numrows = mysql_num_rows($query); $x < $numrows; $x++) {
    	$row = mysql_fetch_assoc($query);

		//make array
		$json[$x] = array("choice" => $row["choices"], "votes" => $row["votes"]);
	}

	//echo results
	echo json_encode($json);

	//close connection
	mysql_close($server);

?></pre>
<p>At the top of the code we&#8217;ve got a bunch of variables needed to make the database connection. Following this we make the connection to the database and get the choice that was sent to the server, using mysql_real_escape_string() to ensure no sql commands have been added to the string. Next we update the database with the new result, before querying the database to get the updated result.</p>
<p>Following this we build an array of each of the poll rows and their values, before encoding the array as JSON and sending it back to the page to be displayed.</p>
<p>It&#8217;s quite simple, and probably the most simple code that could be used and still have it work <img src='http://www.danwellman.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danwellman.co.uk/jquery-plugin-jpoll/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
