Use IMPDialog for DIMP folder actions.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Jul 2010 04:11:01 +0000 (22:11 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Jul 2010 04:11:25 +0000 (22:11 -0600)
imp/js/dialog.js
imp/js/dimpbase.js
imp/templates/dimp/index.inc

index 9f1ef79..759b9ba 100644 (file)
@@ -6,6 +6,7 @@
  * 'dialog_load' - TODO
  * 'form' - TODO
  * 'form_id' - The ID for the form (default: RB_confirm).
+ * 'input_val' - TODO
  * 'noinput' - TODO
  * 'ok_text' - OK text.
  * 'password' - TODO
@@ -60,7 +61,7 @@ var IMPDialog = {
         if (data.form) {
             n.insert(data.form);
         } else if (!data.noinput) {
-            n.insert(new Element('INPUT', { name: 'dialog_input', type: data.password ? 'password' : 'text', size: 15 }));
+            n.insert(new Element('INPUT', { name: 'dialog_input', type: data.password ? 'password' : 'text', size: 15 }).setValue(data.input_val));
         }
 
         if (data.ok_text) {
index cf27aba..455afb3 100644 (file)
@@ -703,7 +703,7 @@ var DimpBase = {
 
         case 'ctx_container_rename':
         case 'ctx_folder_rename':
-            this.renameFolder(baseelt);
+            this.renameFolder(e.findElement('LI'));
             break;
 
         case 'ctx_folder_empty':
@@ -1728,11 +1728,7 @@ var DimpBase = {
                 break;
 
             case Event.KEY_RETURN:
-                // Catch returns in RedBox
-                if (form.readAttribute('id') == 'RB_folder') {
-                    this.cfolderaction(e);
-                    e.stop();
-                } else if (elt.readAttribute('id') == 'qsearch_input') {
+                if (elt.readAttribute('id') == 'qsearch_input') {
                     if ($F('qsearch_input')) {
                         this.quicksearchRun();
                     } else {
@@ -2099,15 +2095,7 @@ var DimpBase = {
                 return;
 
             default:
-                if (elt.hasClassName('RBFolderOk')) {
-                    this.cfolderaction(e);
-                    e.stop();
-                    return;
-                } else if (elt.hasClassName('RBFolderCancel')) {
-                    this._closeRedBox();
-                    e.stop();
-                    return;
-                } else if (elt.hasClassName('printAtc')) {
+                if (elt.hasClassName('printAtc')) {
                     DimpCore.popupWindow(DimpCore.addURLParam(DIMP.conf.URI_VIEW, { uid: this.pp.imapuid, mailbox: this.pp.view, actionID: 'print_attach', id: elt.readAttribute('mimeid') }, true), this.pp.imapuid + '|' + this.pp.view + '|print', IMP.printWindow);
                     e.stop();
                     return;
@@ -2154,8 +2142,7 @@ var DimpBase = {
         }
 
         folder = $(folder);
-        var n = this._createFolderForm(this._folderAction.bindAsEventListener(this, folder, 'rename'), DIMP.text.rename_prompt);
-        n.down('input').setValue(folder.retrieve('l'));
+        this._createFolderForm(this._folderAction.bindAsEventListener(this, folder, 'rename'), DIMP.text.rename_prompt, folder.retrieve('l'));
     },
 
     /* Handle insert folder actions. */
@@ -2171,29 +2158,20 @@ var DimpBase = {
         }
     },
 
-    _createFolderForm: function(action, text)
+    _createFolderForm: function(action, text, val)
     {
-        var n = $($('folderform').down().clone(true)).writeAttribute('id', 'RB_folder');
-        n.down('P').insert(text);
-
         this.cfolderaction = action;
-
-        RedBox.overlay = true;
-        RedBox.onDisplay = Form.focusFirstElement.curry(n);
-        RedBox.showHtml(n);
-        return n;
-    },
-
-    _closeRedBox: function()
-    {
-        RedBox.close();
-        this.cfolderaction = null;
+        IMPDialog.display({
+            cancel_text: DIMP.text.cancel,
+            form_id: 'RB_Folder',
+            input_val: val,
+            ok_text: DIMP.text.ok,
+            text: text
+        });
     },
 
     _folderAction: function(e, folder, mode)
     {
-        this._closeRedBox();
-
         var action, params, val,
             form = e.findElement('form');
         val = $F(form.down('input'));
@@ -3120,6 +3098,13 @@ document.observe('DragDrop2:end', DimpBase.onDragEnd.bindAsEventListener(DimpBas
 document.observe('DragDrop2:mousedown', DimpBase.onDragMouseDown.bindAsEventListener(DimpBase));
 document.observe('DragDrop2:mouseup', DimpBase.onDragMouseUp.bindAsEventListener(DimpBase));
 
+/* IMPDialog listener. */
+document.observe('IMPDialog:onClick', function(e) {
+    if (e.element().identify() == 'RB_Folder') {
+        this.cfolderaction(e.memo);
+    }
+}.bindAsEventListener(DimpBase));
+
 /* Route AJAX responses through ViewPort. */
 DimpCore.onDoActionComplete = function(r) {
     DimpBase.deleteCallback(r);
index cc94b8f..3fae746 100644 (file)
@@ -493,12 +493,3 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
   <span class="dispaddrlist" style="display:none"></span>
  </span>
 </div>
-
-<div id="folderform" style="display:none">
- <form action="#" class="RBForm">
-  <p></p>
-  <input type="text" size="15" />
-  <input type="button" class="button RBFolderOk" value="<?php echo _("Ok") ?>" />
-  <input type="button" class="button RBFolderCancel" value="<?php echo _("Cancel") ?>" />
- </form>
-</div>