<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
 /*
- * jQuery Example Plugin 1.0.1
+ * jQuery Example Plugin 1.1
  * Populate form inputs with example text that disappears on focus.
  *
  * e.g.
@@ -15,25 +15,45 @@
 (function($) {
 	
 	$.fn.example = function(text, args) {
-		
+
 		/* Load the default options. */
-		var main_options = $.extend({}, $.fn.example.defaults, args);
+		var options = $.extend({}, $.fn.example.defaults, args);
 		
-		return this.each(function() {
-			var $this = $(this);
-
-			/* Support the Metadata plugin. */
-			var options = $.meta ? $.extend({}, main_options, $this.data()) : main_options;
+		/* The following event handlers only need to be bound once
+		 * per class name. In order to do this, an array of used
+		 * class names is stored in the document body and is checked
+		 * on each use of the plugin. If the class name is in the
+		 * array then this whole section is skipped. If not, the
+		 * events are bound and the class name added to the array.
+		 */
+		var bound_class_names = $.data(document.body, 'example') || [];
+		
+		if ($.inArray(options.class_name, bound_class_names) == -1) {
+			
+			/* Because Gecko-based browsers &quot;helpfully&quot; cache form values
+			 * but ignore all other attributes such as class, all example
+			 * values must be cleared on page unload to prevent them from
+			 * being saved.
+			 */
+			$(window).unload(function() {
+				$('.' + options.class_name).val('');
+			});
 			
 			/* Clear fields that are still examples before the form is submitted
 			 * otherwise those examples will be sent along as well.
 			 */
-			$this.parents('form').submit(function() {
-				if ($this.hasClass(options.class_name)) {
-					$this.val('');
-				}
+			$(this).parents('form:first').submit(function() {
+				$('.' + options.class_name).val('');
 			});
 			
+			/* Add the class name to the array. */
+			bound_class_names.push(options.class_name);
+			$.data(document.body, 'example', bound_class_names);
+		}
+		
+		return this.each(function() {
+			var $this = $(this);
+
 			/* Initially place the example text in the field if it is empty. */
 			if ($this.val() == '') {
 				$this.addClass(options.class_name);</diff>
      <filename>jquery.example.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 /*
- * jQuery Example Plugin 1.0.1
+ * jQuery Example Plugin 1.1
  * Populate form inputs with example text that disappears on focus.
  *
  * e.g.
@@ -12,4 +12,4 @@
  * Copyright (c) Paul Mucur (http://mucur.name), 2007-2008.
  * Licensed under the BSD License (LICENSE.txt).
  */
-(function(A){A.fn.example=function(D,C){var B=A.extend({},A.fn.example.defaults,C);return this.each(function(){var F=A(this);var E=A.meta?A.extend({},B,F.data()):B;F.parents(&quot;form&quot;).submit(function(){if(F.hasClass(E.class_name)){F.val(&quot;&quot;);}});if(F.val()==&quot;&quot;){F.addClass(E.class_name);F.val(D);}if(E.hide_label){A(&quot;label[@for=&quot;+F.attr(&quot;id&quot;)+&quot;]&quot;).next(&quot;br&quot;).andSelf().hide();}F.focus(function(){if(A(this).hasClass(E.class_name)){A(this).val(&quot;&quot;);A(this).removeClass(E.class_name);}});F.blur(function(){if(A(this).val()==&quot;&quot;){A(this).addClass(E.class_name);A(this).val(D);}});});};A.fn.example.defaults={class_name:&quot;example&quot;,hide_label:false};})(jQuery);
\ No newline at end of file
+(function(A){A.fn.example=function(E,D){var C=A.extend({},A.fn.example.defaults,D);var B=A.data(document.body,&quot;example&quot;)||[];if(A.inArray(C.class_name,B)==-1){A(window).unload(function(){A(&quot;.&quot;+C.class_name).val(&quot;&quot;);});A(this).parents(&quot;form:first&quot;).submit(function(){A(&quot;.&quot;+C.class_name).val(&quot;&quot;);});B.push(C.class_name);A.data(document.body,&quot;example&quot;,B);}return this.each(function(){var F=A(this);if(F.val()==&quot;&quot;){F.addClass(C.class_name);F.val(E);}if(C.hide_label){A(&quot;label[@for=&quot;+F.attr(&quot;id&quot;)+&quot;]&quot;).next(&quot;br&quot;).andSelf().hide();}F.focus(function(){if(A(this).hasClass(C.class_name)){A(this).val(&quot;&quot;);A(this).removeClass(C.class_name);}});F.blur(function(){if(A(this).val()==&quot;&quot;){A(this).addClass(C.class_name);A(this).val(E);}});});};A.fn.example.defaults={class_name:&quot;example&quot;,hide_label:false};})(jQuery);
\ No newline at end of file</diff>
      <filename>jquery.example.min.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>925900b4fc4305be95f359cb4dc89fe46ba53c60</id>
    </parent>
  </parents>
  <author>
    <name>Paul Mucur</name>
    <email>mudge@mudge.name</email>
  </author>
  <url>http://github.com/mudge/jquery_example/commit/a21a96dfb923d867441203cf516bd055de1a21a3</url>
  <id>a21a96dfb923d867441203cf516bd055de1a21a3</id>
  <committed-date>2008-01-08T03:36:12-08:00</committed-date>
  <authored-date>2008-01-08T03:36:12-08:00</authored-date>
  <message>Fixed the caching bug on Gecko-based browsers by clearing values on unload.

While everything previously worked fine on Safari, there were problems with
Gecko-based browsers such as Firefox and Camino whereby the browser would
cache the example values. This meant that a simple refresh of the page would
convert example values into *real* values thereby breaking the plugin entirely.

To overcome this, I now bind an event on page unload to clear all the example
values so by the time that a Gecko browser comes to cache the page, those
fields are all blank.

I also removed support for the Metadata plugin (as I didn't use it and only
added it based on an article about jQuery plugins) and reduced the number
of duplicate event bindings.</message>
  <tree>d30a8a3e74d8f3dd5193738826e9f933b51103de</tree>
  <committer>
    <name>Paul Mucur</name>
    <email>mudge@mudge.name</email>
  </committer>
</commit>
