From 48060129e51d8fd77386e4d59026847a8b82954d Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Tue, 8 Feb 2000 02:39:41 +0000 Subject: [PATCH] Fix related to bug 10932 and 26344. Need to reset all the event handlers of a dynamically created node after it has been inserted in the DOM. Also do not created a new recipient row when the user press enter after entering a recipient. R=mscott --- .../content/addressingWidgetOverlay.js | 80 ++++++++++++++----- .../content/addressingWidgetOverlay.xul | 9 ++- 2 files changed, 67 insertions(+), 22 deletions(-) diff --git a/mailnews/compose/resources/content/addressingWidgetOverlay.js b/mailnews/compose/resources/content/addressingWidgetOverlay.js index d559ec229ff..5e6aad84d91 100644 --- a/mailnews/compose/resources/content/addressingWidgetOverlay.js +++ b/mailnews/compose/resources/content/addressingWidgetOverlay.js @@ -175,24 +175,21 @@ function awSetInputAndPopupFromArray(firstRow, inputArray, popupValue) return(firstRow); } -function awClickRow() -{ - dump("awClickRow\n"); - if (! top.notAnEmptyArea) - awClickEmptySpace(true); - top.notAnEmptyArea=false; - return; -} - -function awNotAnEmptyArea() +function awNotAnEmptyArea(event) { + //This is temporary until i figure out how to ensure to always having an empty space after the last row dump("awNotAnEmptyArea\n"); - top.notAnEmptyArea=true; - return; + + var lastInput = awGetInputElement(top.MAX_RECIPIENTS); + if ( lastInput && lastInput.value ) + awAppendNewRow(false); + + event.preventBubble(); } function awClickEmptySpace(setFocus) { + dump("awClickEmptySpace\n"); var lastInput = awGetInputElement(top.MAX_RECIPIENTS); if ( lastInput && lastInput.value ) @@ -220,8 +217,12 @@ function awInputChanged(inputElement) { dump("awInputChanged\n"); AutoCompleteAddress(inputElement); - //call awClickEmptySpace to add a new row if needed - awClickEmptySpace(false); + + //Do we need to add a new row? + var lastInput = awGetInputElement(top.MAX_RECIPIENTS); + if ( lastInput && lastInput.value && !top.doNotCreateANewRow) + awAppendNewRow(false); + top.doNotCreateANewRow = false; } function awAppendNewRow(setFocus) @@ -455,12 +456,11 @@ function _awSetFocus() var tree = document.getElementById('addressingWidgetTree'); try { + theNewRow = awGetTreeRow(top.awRow); //temporary patch for bug 26344 - //top.awInputElement.setAttribute("onclick", top.awInputElement.getAttribute("onclick")); - //top.awInputElement.setAttribute("onkeyup", top.awInputElement.getAttribute("onkeyup")); - //end of patch + awFinishCopyNode(theNewRow); - tree.ensureElementIsVisible(awGetTreeRow(top.awRow)); + tree.ensureElementIsVisible(theNewRow); top.awInputElement.focus(); } catch(ex) @@ -475,3 +475,47 @@ function _awSetFocus() dump("_awSetFocus failed, forget about it!\n"); } } + + +//temporary patch for bug 26344 +function awFinishCopyNode(node) +{ +// dump ("awFinishCopyNode, node name=" + node.nodeName + "\n"); + // Because event handler attributes set into a node before this node is inserted + // into the DOM are not recognised (in fact not compiled), we need to parsed again + // the whole node and reset event handlers. + + var attributes = node.attributes; + if ( attributes && attributes.length ) + { + var attrNode, name; + + for ( var index = 0; index < attributes.length; index++ ) + { + attrNode = attributes.item(index); + name = attrNode.nodeName; + if (name.substring(0, 2) == 'on') + { + node.setAttribute(name, attrNode.nodeValue); +// dump(" -->reset attribute " + name + "\n"); + } + } + } + + // children of nodes + if ( node.childNodes ) + { + var childNode; + + for ( var child = 0; child < node.childNodes.length; child++ ) + childNode = awFinishCopyNode(node.childNodes[child]); + } +} + + +function awTabFromRecipient(element, event) +{ + //If we are le last element in the tree, we don't want to create a new row. + if (element == awGetInputElement(top.MAX_RECIPIENTS)) + top.doNotCreateANewRow = true; +} \ No newline at end of file diff --git a/mailnews/compose/resources/content/addressingWidgetOverlay.xul b/mailnews/compose/resources/content/addressingWidgetOverlay.xul index 4da0880e429..abf26fc3104 100644 --- a/mailnews/compose/resources/content/addressingWidgetOverlay.xul +++ b/mailnews/compose/resources/content/addressingWidgetOverlay.xul @@ -36,7 +36,7 @@ Rights Reserved. @@ -45,7 +45,7 @@ Rights Reserved. - + &toAddr.label; &ccAddr.label; @@ -56,17 +56,18 @@ Rights Reserved. - + - +