<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,8 @@
 * Before release 0.20 [0/8]
-  - [ ] inplace editor doesn't handle escape correctly
+  - [ ] null titles break taboo
+  - [ ] make sure re-clicking the taboo button doesn't overwrite data?
+  - [ ] inplace editor doesn't handle escape key correctly:
+    click to edit, save changes, then click escape again to change
   - [ ] inplace editor breaks if you change textarea while it is in edit mode
   - [ ] deleting from grid mode doesn't show the undelete box
   - [ ] undelete / delete all isn't show correctly on trash.js</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -48,20 +48,15 @@
   * @name  editInPlace
   * @type  jQuery
   * @param Hash    options                        additional options
-  * @param String  options[url]                    POST URL to send edited content
-  * @param String  options[params]                paramters sent via the post request to the server; string; ex: name=dave&amp;last_name=hauenstein
   * @param String  options[field_type]            can be: text, textarea, select; default: text
-  * @param String  options[select_options]        this is a string seperated by commas for the dropdown options, if field_type is dropdown
   * @param String  options[textarea_cols]        number of columns textarea will have, if field_type is textarea; default: 25
   * @param String  options[textarea_rows]        number of rows textarea will have, if field_type is textarea; default: 10
   * @param String  options[bg_over]                background color of editable elements on HOVER
   * @param String  options[bg_out]                background color of editable elements on RESTORE from hover
-  * @param String  options[saving_text]            text to be used when server is saving information; default: 'Saving...'
-  * @param String  options[saving_image]        specify an image location instead of text while server is saving; default: uses saving text
+  * @param String  options[default_text]            text to be used when element has no value
   * @param String  options[value_required]        if set to true, the element will not be saved unless a value is entered
   * @param String  options[element_id]            name of parameter holding element_id; default: element_id
   * @param String  options[update_value]        name of parameter holding update_value; default: update_value
-  * @param String  options[original_html]        name of parameter holding original_html; default: original_html
   * @param String  options[save_button]            image button tag to use as &quot;Save&quot; button
   * @param String  options[cancel_button]        image button tag to use as &quot;Cancel&quot; button
   * @param String  options[callback]            call function instead of submitting to url
@@ -73,22 +68,15 @@ jQuery.fn.editInPlace = function(options) {
   //#######################################################################
   //DEFINE THE DEFAULT SETTINGS, SWITCH THEM WITH THE OPTIONS USER PROVIDES
   var settings = {
-    url: &quot;&quot;,
-    params: &quot;&quot;,
     field_type: &quot;text&quot;,
-    select_options: &quot;&quot;,
     textarea_cols:  &quot;25&quot;,
     textarea_rows:  &quot;10&quot;,
     bg_over: &quot;#ffc&quot;,
     bg_out:  &quot;transparent&quot;,
-    saving_text:   &quot;Saving...&quot;,
-    saving_image:  &quot;&quot;,
     default_text:  &quot;(Click here to add text)&quot;,
-    select_text: &quot;Choose new value&quot;,
     value_required: null,
     element_id:    &quot;element_id&quot;,
     update_value:  &quot;update_value&quot;,
-    original_html: &quot;original_html&quot;,
     save_button:   '&lt;input type=&quot;submit&quot; class=&quot;inplace_save&quot; value=&quot;Save&quot;/&gt;',
     cancel_button: '&lt;input type=&quot;submit&quot; class=&quot;inplace_cancel&quot; value=&quot;Cancel&quot;/&gt;',
     callback: null,
@@ -102,23 +90,8 @@ jQuery.fn.editInPlace = function(options) {
     jQuery.extend(settings, options);
   }
 
-  //#######################################################################
-  //preload the loading icon if it exists
-  if (settings.saving_image != &quot;&quot;){
-    var loading_image = new Image();
-    loading_image.src = settings.saving_image;
-  }
-
-  //#######################################################################
-  //THIS FUNCTION WILL TRIM WHITESPACE FROM BEFORE/AFTER A STRING
-  String.prototype.trim = function() {
-    return this.replace(/^\s+/, '').replace(/\s+$/, '');
-  };
-
-  //#######################################################################
-  //THIS FUNCTION WILL ESCAPE ANY HTML ENTITIES SO &quot;Quoted Values&quot; work
-  String.prototype.escape_html = function() {
-    return this.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;)
+  function escape_html(str) {
+    return str.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;)
       .replace(/&gt;/g, &quot;&amp;gt;&quot;)
       .replace(/\&quot;/g, &quot;&amp;quot;&quot;);
   };
@@ -127,162 +100,104 @@ jQuery.fn.editInPlace = function(options) {
   //CREATE THE INPLACE EDITOR
   return this.each(function(){
 
-    if(jQuery(this).html() == &quot;&quot;) jQuery(this).html(settings.default_text);
-
+    var element = jQuery(this);
+    var value;
     var editing = false;
+    var click_count = 0;
 
-    //save the original element - for change of scope
-    var original_element = jQuery(this);
+    element.bind('update', function(event, val) {
+		   if (val == null || val == &quot;&quot;) {
+		     element.text(settings.default_text);
+		   }
+		   else {
+		     element.text(val);
+		   }
+		 });
 
-    var click_count = 0;
+    element.bind('cancel', function() {
+		   editing = false;
+		   click_count = 0;
+
+		   //put the original background color in
+		   element.css(&quot;background&quot;, settings.bg_out);
+
+		   //put back the original text
+		   element.trigger('update', [value]);
+		 });
+
+    element.bind('save', function() {
+		   editing = false;
+		   click_count = 0;
 
-    jQuery(this).mouseover(function(){
-      jQuery(this).css(&quot;background&quot;, settings.bg_over);
+		   //put the original background color in
+		   element.css(&quot;background&quot;, settings.bg_out);
+
+		   value = element.children('form').children('.inplace_field').val();
+		   element.trigger('callback', [value]);
+		   element.trigger('update', [value]);
+		 });
+
+    element.mouseover(function(){
+      element.css(&quot;background&quot;, settings.bg_over);
     }).mouseout(function(){
-      jQuery(this).css(&quot;background&quot;, settings.bg_out);
+      element.css(&quot;background&quot;, settings.bg_out);
     }).click(function(){
       click_count++;
 
       if (!editing) {
 
         editing = true;
-
-	//save original text - for cancellation functionality
-	var original_html = jQuery(this).html();
+	value = element.text();
 	var buttons_code  = settings.save_button + ' ' + settings.cancel_button;
 
-	//if html is our default text, clear it out to prevent saving accidentally
-	if (original_html == settings.default_text) jQuery(this).html('');
+	// if html is our default text, clear it out to prevent saving accidentally
+	// FIXME: I think original_html should be set to '' as well
+	if (value == settings.default_text) element.text('');
 
 	if (settings.field_type == &quot;textarea&quot;) {
 
-	  var use_field_type = '&lt;textarea name=&quot;inplace_value&quot; class=&quot;inplace_field&quot; rows=&quot;' +
+	  var use_field_type = '&lt;textarea class=&quot;inplace_field&quot; rows=&quot;' +
 	    settings.textarea_rows +
             '&quot; cols=&quot;' + settings.textarea_cols + '&quot;&gt;' +
-            jQuery(this).text().trim().escape_html() +
+            escape_html(element.text()) +
             '&lt;/textarea&gt;';
         }
 	else if (settings.field_type == &quot;text&quot;) {
-	  var use_field_type = '&lt;input type=&quot;text&quot; name=&quot;inplace_value&quot; class=&quot;inplace_field&quot; value=&quot;' +
-            jQuery(this).text().trim().escape_html() + '&quot; /&gt;';
-          }
-          else if (settings.field_type == &quot;select&quot;) {
-        var optionsArray = settings.select_options.split(',');
-        var use_field_type = '&lt;select name=&quot;inplace_value&quot; class=&quot;inplace_field&quot;&gt;&lt;option value=&quot;&quot;&gt;' +
-          settings.select_text + '&lt;/option&gt;';
-        for (var i=0; i&lt;optionsArray.length; i++) {
-          var optionsValuesArray = optionsArray[i].split(':');
-          var use_value = optionsValuesArray[1] || optionsValuesArray[0];
-          var selected = use_value == original_html ? 'selected=&quot;selected&quot; ' : '';
-          use_field_type += '&lt;option ' + selected + 'value=&quot;' +
-            use_value.trim().escape_html() + '&quot;&gt;' +
-            optionsValuesArray[0].trim().escape_html() + '&lt;/option&gt;';
-          }
-	  use_field_type += '&lt;/select&gt;';
+	  var use_field_type = '&lt;input type=&quot;text&quot; class=&quot;inplace_field&quot; value=&quot;' +
+            escape_html(element.text()) + '&quot; /&gt;';
         }
 
 	//insert the new in place form after the element they click, then empty out the original element
-	jQuery(this).html('&lt;form class=&quot;inplace_form&quot; style=&quot;display: inline; margin: 0; padding: 0;&quot;&gt;' +
+	element.html('&lt;form class=&quot;inplace_form&quot; style=&quot;display: inline; margin: 0; padding: 0;&quot;&gt;' +
 	  use_field_type + ' ' + buttons_code + '&lt;/form&gt;');
 
-      }//END- if(!editing) -END
+      }
 
-      if(click_count == 1) {
+      if (click_count == 1) {
         //set the focus to the new input element
-        original_element.children(&quot;form&quot;).children(&quot;.inplace_field&quot;).focus().select();
-
-	function cancel() {
-	  editing = false;
-          click_count = 0;
-
-          //put the original background color in
-          original_element.css(&quot;background&quot;, settings.bg_out);
-
-          //put back the original text
-          original_element.html(original_html);
+        element.children(&quot;form&quot;).children(&quot;.inplace_field&quot;).focus().select();
 
-          return false;
-	}
 
 	//HIT ESC KEY
+	// FIXME: this is kinda evil since each inplace editor creation adds another binding
 	$(document).keyup(function(event){
-	  if (event.keyCode == 27) {
-            cancel();
+	  if (editing &amp;&amp; event.keyCode == 27) {
+	    element.trigger('cancel');
           }
 	});
 
 	//CLICK CANCEL BUTTON functionality
-	original_element.children(&quot;form&quot;).children(&quot;.inplace_cancel&quot;).click(cancel);
+	element.children(&quot;form&quot;).children(&quot;.inplace_cancel&quot;).click(function() {
+									      element.trigger('cancel');
+									      return false;
+									    });
 
         //CLICK SAVE BUTTON functionality
-        original_element.children(&quot;form&quot;).children(&quot;.inplace_save&quot;).click(function(){
-        //put the original background color in
-        original_element.css(&quot;background&quot;, settings.bg_out);
-
-        var new_html = jQuery(this).parent().children(0).val();
-
-        //set saving message
-        if (settings.saving_image != &quot;&quot;){
-          var saving_message = '&lt;img src=&quot;' + settings.saving_image + '&quot; alt=&quot;Saving...&quot; /&gt;';
-        } else {
-          var saving_message = settings.saving_text;
-        }
-
-        //place the saving text/image in the original element
-        original_element.html(saving_message);
-
-        if (settings.params != &quot;&quot;){
-          settings.params = &quot;&amp;&quot; + settings.params;
-        }
-
-        if (settings.callback) {
-          html = settings.callback(original_element.attr(&quot;id&quot;), new_html, original_html, settings.params);
-          editing = false;
-          click_count = 0;
-          if (html) {
-            // put the newly updated info into the original element
-            original_element.html(html || new_html);
-          } else {
-            // failure; put original back
-            alert(&quot;Failed to save value: &quot; + new_html);
-            original_element.html(original_html);
-          }
-        } else if (settings.value_required &amp;&amp; new_html == &quot;&quot;) {
-          editing = false;
-          click_count = 0;
-          original_element.html(original_html);
-          alert(&quot;Error: You must enter a value to save this field&quot;);
-        } else {
-          jQuery.ajax({
-	    url: settings.url,
-	    type: &quot;POST&quot;,
-            data: settings.update_value + '=' + new_html + '&amp;' + settings.element_id + '=' +
-              original_element.attr(&quot;id&quot;) + settings.params +
-              '&amp;' + settings.original_html + '=' + original_html,
-            dataType: &quot;html&quot;,
-            complete: function(request) {
-              editing = false;
-              click_count = 0;
-            },
-            success: function(html) {
-              // if the text returned by the server is empty,
-                 // put a marker as text in the original element
-              var new_text = html || settings.default_text;
-
-              // put the newly updated info into the original element
-              original_element.html(new_text);
-              if (settings.success) settings.success(html, original_element);
-            },
-            error: function(request) {
-              original_element.html(original_html);
-              if (settings.error) settings.error(request, original_element);
-            }
-	    });
-        }
-
-	return false;
-	});
-      }//END- if(click_count == 1) -END
+        element.children(&quot;form&quot;).children(&quot;.inplace_save&quot;).click(function(){
+									    element.trigger('save');
+									    return false;
+									  });
+      }
     });
   });
-};
\ No newline at end of file
+};</diff>
      <filename>chrome/content/jquery.inplace.source.js</filename>
    </modified>
    <modified>
      <diff>@@ -26,23 +26,22 @@ function Mosaic(container) {
 
   container.appendChild(DIV({id: 'main'}, img, url, title, description));
 
-  $(title).editInPlace({
-    callback: function(original_element, html) {
-      SVC.update(currentUrl, html, null);
-      return html.replace(/&lt;/g, '&amp;lt;');
-    }
-  });
+  $(title).editInPlace();
+
+  $(title).bind('callback', function(e, value) {
+		  SVC.update(currentUrl, value, null);
+		});
 
   $(description).editInPlace({
-    field_type: &quot;textarea&quot;,
-    textarea_rows: &quot;5&quot;,
-    textarea_cols: &quot;35&quot;,
-    bg_out: '#fff',
-    callback: function(original_element, html) {
-      SVC.update(currentUrl, null, html);
-      return html.replace(/&lt;/g, '&amp;lt;');
-    }
-  });
+			       field_type: &quot;textarea&quot;,
+			       textarea_rows: &quot;5&quot;,
+			       textarea_cols: &quot;35&quot;,
+			       bg_out: '#fff'
+			     });
+
+  $(description).bind('callback', function(e, value) {
+			SVC.update(currentUrl, null, value);
+		      });
 
   function openCurrent(event) {
     SVC.open(currentUrl, whereToOpenLink(event));
@@ -53,14 +52,14 @@ function Mosaic(container) {
 
   var list = document.createElement('div');
   list.setAttribute('id', 'list');
-  container.appendChild(list)
+  container.appendChild(list);
 
   this.start = function() {
     currentUrl = null;
     list.innerHTML = '';
-  }
+  };
 
-  this.finish = function() {}
+  this.finish = function() {};
 
   var currentUrl = null;
 
@@ -78,9 +77,9 @@ function Mosaic(container) {
     box.onclick = function(event) {
       currentUrl = tab.url;
       img.setAttribute('src', tab.imageURL);
+      $(title).trigger('update', [tab.title]);
+      $(description).trigger('update', [tab.description]);
       setText(url, tab.url);
-      setText(title, tab.title);
-      setText(description, tab.description);
     };
 
     box.onmouseover = function(event) {</diff>
      <filename>chrome/content/mosaic.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>43d5c35b987e28ee2681012543b54adcf4eb5495</id>
    </parent>
  </parents>
  <author>
    <name>Jesse Andrews</name>
    <email>anotherjesse@gmail.com</email>
  </author>
  <url>http://github.com/anotherjesse/taboo/commit/2fb2024fd7118be3148f9d065a70cbbf38b00c85</url>
  <id>2fb2024fd7118be3148f9d065a70cbbf38b00c85</id>
  <committed-date>2008-06-18T02:31:23-07:00</committed-date>
  <authored-date>2008-06-18T02:31:23-07:00</authored-date>
  <message>rewrite jquery inplace editor - and adapt mosaic code to use it</message>
  <tree>9131255e810fa6ebd5b0cdbfd6b6e5ccc78981ed</tree>
  <committer>
    <name>Jesse Andrews</name>
    <email>anotherjesse@gmail.com</email>
  </committer>
</commit>
