From 034c899d59320b764bdcb750d2d1a3eaf0fb7af1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 6 Jul 2010 22:11:01 -0600 Subject: [PATCH] Use IMPDialog for DIMP folder actions. --- imp/js/dialog.js | 3 ++- imp/js/dimpbase.js | 53 ++++++++++++++++---------------------------- imp/templates/dimp/index.inc | 9 -------- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/imp/js/dialog.js b/imp/js/dialog.js index 9f1ef7900..759b9baf2 100644 --- a/imp/js/dialog.js +++ b/imp/js/dialog.js @@ -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) { diff --git a/imp/js/dimpbase.js b/imp/js/dimpbase.js index cf27aba61..455afb37e 100644 --- a/imp/js/dimpbase.js +++ b/imp/js/dimpbase.js @@ -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); diff --git a/imp/templates/dimp/index.inc b/imp/templates/dimp/index.inc index cc94b8f6d..3fae74690 100644 --- a/imp/templates/dimp/index.inc +++ b/imp/templates/dimp/index.inc @@ -493,12 +493,3 @@ function _simpleButton($id, $text, $image, $nodisplay = false) - - -- 2.11.0