Index: /branches/new-dialogs/plugins/UnFormat/dialog.html
===================================================================
--- /branches/new-dialogs/plugins/UnFormat/dialog.html (revision 1015)
+++ /branches/new-dialogs/plugins/UnFormat/dialog.html (revision 1015)
@@ -0,0 +1,28 @@
+<h1 id="[h1]"><l10n>Page Cleaner</l10n></h1>
+
+<form action="" method="get" style="padding-top:10px" id="[inputs]">
+  <fieldset>
+  <legend><l10n>Cleaning Area</l10n></legend>
+    <span><l10n>Selection</l10n></span><input type="radio" name="[cleaning_area]" id="[clean_selection]" value="selection" checked="checked" />
+    <span><l10n>All</l10n></span><input type="radio" name="[cleaning_area]" id="[clean_page]" value="all" />
+  </fieldset>
+  <br />
+  <fieldset>
+  <legend><l10n>Cleaning options</l10n></legend>
+    <div class="space"></div>
+    <div class="fr"><l10n>Formatting:</l10n></div>
+    <input type="checkbox" name="[formatting]" id="[formatting]" checked />
+    <p />
+    <div class="fr"><l10n>All HTML:</l10n></div>
+    <input type="checkbox" name="[html_all]" id="[html_all]" />
+    <p />
+   </fieldset>
+   <br /><br />
+   <p style="text-align:center"><l10n>Select which types of formatting you would like to remove.</l10n></p>
+
+<div class="buttons" id="[buttons]">
+  <input type="button" id="[ok]"     value="_(OK)"     />
+  <input type="button" id="[cancel]" value="_(Cancel)" />
+</div>
+
+</form>
Index: /branches/new-dialogs/plugins/UnFormat/un-format.js
===================================================================
--- /branches/new-dialogs/plugins/UnFormat/un-format.js (revision 856)
+++ /branches/new-dialogs/plugins/UnFormat/un-format.js (revision 1015)
@@ -1,3 +1,10 @@
 // Unormat plugin for Xinha
+
+
+UnFormat._pluginInfo = {
+  name          : "UnFormat",
+  version       : "1.0",
+  license       : "htmlArea"
+};
 
 
@@ -9,9 +16,9 @@
   cfg.registerButton({
     id       : "unformat",
-    tooltip  : this._lc("Page Cleaner"),
+    tooltip  : Xinha._lc("Page Cleaner",'UnFormat'),
     image    : editor.imgURL("unformat.gif", "UnFormat"),
     textMode : false,
     action   : function(editor) {
-                 self.buttonPress(editor);
+                 self.show();
                }
   });
@@ -20,46 +27,81 @@
 }
 
-UnFormat._pluginInfo = {
-  name          : "UnFormat",
-  version       : "1.0",
-  license       : "htmlArea"
+UnFormat.prototype.onGenerateOnce = function(editor){
+  // Load assets
+  var self = UnFormat;
+  if (self.loading) return;
+  self.loading = true;
+  self.methodsReady = true;
+  Xinha._getback(_editor_url + 'plugins/UnFormat/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; });
+}
+UnFormat.prototype.onUpdateToolbar = function(editor){
+  if (!(UnFormat.dialogReady && UnFormat.methodsReady))
+  {
+    this.editor._toolbarObjects.UnFormat.state("enabled", false);
+  }
+  else this.onUpdateToolbar = null;
+
+}
+UnFormat.prototype.prepareDialog = function(editor){
+  var self = this;
+  var editor = this.editor;
+
+  var dialog = this.dialog = new Xinha.Dialog(editor, UnFormat.html, 'Xinha',{width:400})
+  // Connect the OK and Cancel buttons
+  dialog.getElementById('ok').onclick = function() {self.apply();}
+  dialog.getElementById('cancel').onclick = function() { self.dialog.hide()};
+  
+  this.dialogReady = true;
+}
+UnFormat.prototype.show = function(editor){
+ if (!this.dialog) this.prepareDialog();
+
+  var editor = this.editor;
+
+  var values = 
+  {
+    "cleaning_area"    : 'selection',
+    "formatting"       : '',
+    "html_all"         : ''
+  }
+  // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog
+  this.dialog.show(values);
+  this.dialog.onresize();
+}
+UnFormat.prototype.apply = function(editor){
+  var editor = this.editor;
+  var doc = editor._doc;
+  var param = this.dialog.getValues();
+  
+  // selection is only restored on dialog.hide()
+  this.dialog.hide();
+  // assign the given arguments
+  
+  if (param["cleaning_area"] == "all") {
+    var html = editor._doc.body.innerHTML;
+  } else {
+    var html = editor.getSelectedHTML();
+  }
+
+  if (param.html_all) {
+    html = html.replace(/<[\!]*?[^<>]*?>/g, "");
+  }
+
+  if (param.formatting) {
+    html = html.replace(/style="[^"]*"/gi, "");
+    html = html.replace(/<\/?font[^>]*>/gi,"");
+    html = html.replace(/<\/?b>/gi,"");
+    html = html.replace(/<\/?strong[^>]*>/gi,"");
+    html = html.replace(/<\/?i>/gi,"");
+    html = html.replace(/<\/?em[^>]*>/gi,"");
+    html = html.replace(/<\/?u[^>]*>/gi,"");
+    html = html.replace(/<\/?strike[^>]*>/gi,"");
+    html = html.replace(/ align=[^\s|>]*/gi,"");
+    html = html.replace(/ class=[^\s|>]*/gi,"");
+  }
+  if (param["cleaning_area"] == "all") {
+    editor._doc.body.innerHTML = html;
+  } else {
+    editor.insertHTML(html);
+  }
 };
-
-
-UnFormat.prototype._lc = function(string) {
-  return Xinha._lc(string, 'UnFormat');
-};
-
-UnFormat.prototype.buttonPress = function(editor){
-  editor._popupDialog( "plugin://UnFormat/unformat", function( param){
-    if (param) {
-      if (param["cleaning_area"] == "all") {
-        var html = editor._doc.body.innerHTML;
-      } else {
-        var html = editor.getSelectedHTML();
-      }
-
-      if (param["html_all"]== true) {
-        html = html.replace(/<[\!]*?[^<>]*?>/g, ""); 				
-      }
-
-      if (param["formatting"] == true) {
-        html = html.replace(/style="[^"]*"/gi, "");
-        html = html.replace(/<\/?font[^>]*>/gi,"");
-        html = html.replace(/<\/?b>/gi,"");
-        html = html.replace(/<\/?strong[^>]*>/gi,"");
-        html = html.replace(/<\/?i>/gi,"");
-        html = html.replace(/<\/?em[^>]*>/gi,"");
-        html = html.replace(/<\/?u[^>]*>/gi,"");
-        html = html.replace(/<\/?strike[^>]*>/gi,"");
-        html = html.replace(/ align=[^\s|>]*/gi,"");
-        html = html.replace(/ class=[^\s|>]*/gi,"");
-      }
-      if (param["cleaning_area"] == "all") {
-        editor._doc.body.innerHTML = html;
-      } else	{
-        editor.insertHTML(html);
-      }
-    } else { return false; }
-  }, null);
-};
