?? addressingwidgetoverlay.js
字號(hào):
awGetInputElement(row).value = ""; awGetPopupElement(row).selectedIndex = 0; }}function awCleanupRows(){ var maxRecipients = top.MAX_RECIPIENTS; var rowID = 1; for (var row = 1; row <= maxRecipients; row ++) { var inputElem = awGetInputElement(row); if (inputElem.value == "" && row < maxRecipients) awRemoveRow(row, 1); else { inputElem.setAttribute("id", "addressCol2#" + rowID); awGetPopupElement(row).setAttribute("id", "addressCol1#" + rowID); rowID ++; } } awTestRowSequence();}function awDeleteRow(rowToDelete){ /* When we delete a row, we must reset the id of others row in order to not break the sequence */ var maxRecipients = top.MAX_RECIPIENTS; awRemoveRow(rowToDelete); var numberOfCols = awGetNumberOfCols(); for (var row = rowToDelete + 1; row <= maxRecipients; row ++) for (var col = 1; col <= numberOfCols; col++) awGetElementByCol(row, col).setAttribute("id", "addressCol" + (col) + "#" + (row-1)); awTestRowSequence();}function awClickEmptySpace(target, setFocus){ if (target == null || (target.localName != "listboxbody" && target.localName != "listcell" && target.localName != "listitem")) return; var lastInput = awGetInputElement(top.MAX_RECIPIENTS); if ( lastInput && lastInput.value ) awAppendNewRow(setFocus); else if (setFocus) awSetFocus(top.MAX_RECIPIENTS, lastInput);}function awReturnHit(inputElement){ var row = awGetRowByInputElement(inputElement); var nextInput = awGetInputElement(row+1); if ( !nextInput ) { if ( inputElement.value ) awAppendNewRow(true); else // No address entered, switch to Subject field { var subjectField = document.getElementById( 'msgSubject' ); subjectField.select(); subjectField.focus(); } } else { nextInput.select(); awSetFocus(row+1, nextInput); } // be sure to add the user add recipient to our ignore list // when the user hits enter in an autocomplete widget... addRecipientsToIgnoreList(inputElement.value);}function awDeleteHit(inputElement){ var row = awGetRowByInputElement(inputElement); /* 1. don't delete the row if it's the last one remaining, just reset it! */ if (top.MAX_RECIPIENTS <= 1) { inputElement.value = ""; return; } /* 2. Set the focus to the previous field if possible */ if (row > 1) awSetFocus(row - 1, awGetInputElement(row - 1)) else awSetFocus(1, awGetInputElement(2)) /* We have to cheat a little bit because the focus will */ /* be set asynchronusly after we delete the current row, */ /* therefore the row number still the same! */ /* 3. Delete the row */ awDeleteRow(row);}function awInputChanged(inputElement){ //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){ var listbox = document.getElementById('addressingWidget'); var listitem1 = awGetListItem(1); if ( listbox && listitem1 ) { var lastRecipientType = awGetPopupElement(top.MAX_RECIPIENTS).selectedItem.getAttribute("value"); var nextDummy = awGetNextDummyRow(); var newNode = listitem1.cloneNode(true); if (nextDummy) listbox.replaceChild(newNode, nextDummy); else listbox.appendChild(newNode); top.MAX_RECIPIENTS++; var input = newNode.getElementsByTagName(awInputElementName()); if ( input && input.length == 1 ) { input[0].setAttribute("value", ""); input[0].setAttribute("id", "addressCol2#" + top.MAX_RECIPIENTS); //this copies the autocomplete sessions list from recipient#1 input[0].syncSessions(document.getElementById('addressCol2#1')); // also clone the showCommentColumn setting // input[0].showCommentColumn = document.getElementById("addressCol2#1").showCommentColumn; // We always clone the first row. The problem is that the first row // could be focused. When we clone that row, we end up with a cloned // XUL textbox that has a focused attribute set. Therefore we think // we're focused and don't properly refocus. The best solution to this // would be to clone a template row that didn't really have any presentation, // rather than using the real visible first row of the listbox. // // For now we'll just put in a hack that ensures the focused attribute // is never copied when the node is cloned. if (input[0].getAttribute('focused') != '') input[0].removeAttribute('focused'); } var select = newNode.getElementsByTagName(awSelectElementName()); if ( select && select.length == 1 ) { // It only makes sense to clone some field types; others // should not be cloned, since it just makes the user have // to go to the trouble of selecting something else. In such // cases let's default to 'To' (a reasonable default since // we already default to 'To' on the first dummy field of // a new message). switch (lastRecipientType) { case "addr_reply": case "addr_other": select[0].selectedIndex = awGetSelectItemIndex("addr_to"); break; case "addr_followup": select[0].selectedIndex = awGetSelectItemIndex("addr_newsgroups"); break; default: // e.g. "addr_to","addr_cc","addr_bcc","addr_newsgroups": select[0].selectedIndex = awGetSelectItemIndex(lastRecipientType); } select[0].setAttribute("id", "addressCol1#" + top.MAX_RECIPIENTS); if (input) _awSetAutoComplete(select[0], input[0]); } // focus on new input widget if (setFocus && input[0] ) awSetFocus(top.MAX_RECIPIENTS, input[0]); }}// functions for accessing the elements in the addressing widgetfunction awGetPopupElement(row){ return document.getElementById("addressCol1#" + row);}function awGetInputElement(row){ return document.getElementById("addressCol2#" + row);}function awGetElementByCol(row, col){ var colID = "addressCol" + col + "#" + row; return document.getElementById(colID);}function awGetListItem(row){ var listbox = document.getElementById('addressingWidget'); if ( listbox && row > 0) { var listitems = listbox.getElementsByTagName('listitem'); if ( listitems && listitems.length >= row ) return listitems[row-1]; } return 0;}function awGetRowByInputElement(inputElement){ var row = 0; if (inputElement) { var listitem = inputElement.parentNode.parentNode; while (listitem) { if (listitem.localName == "listitem") ++row; listitem = listitem.previousSibling; } } return row;}// Copy Node - copy this node and insert ahead of the (before) node. Append to end if before=0function awCopyNode(node, parentNode, beforeNode){ var newNode = node.cloneNode(true); if ( beforeNode ) parentNode.insertBefore(newNode, beforeNode); else parentNode.appendChild(newNode); return newNode;}// remove rowfunction awRemoveRow(row){ var listbox = document.getElementById('addressingWidget'); awRemoveNodeAndChildren(listbox, awGetListItem(row)); awFitDummyRows(); top.MAX_RECIPIENTS --;}function awRemoveNodeAndChildren(parent, nodeToRemove){ nodeToRemove.parentNode.removeChild(nodeToRemove);}function awSetFocus(row, inputElement){ top.awRow = row; top.awInputElement = inputElement; top.awFocusRetry = 0; setTimeout("_awSetFocus();", 0);}function _awSetFocus(){ var listbox = document.getElementById('addressingWidget'); //try //{ var theNewRow = awGetListItem(top.awRow); //Warning: firstVisibleRow is zero base but top.awRow is one base! var firstVisibleRow = listbox.getIndexOfFirstVisibleRow(); var numOfVisibleRows = listbox.getNumberOfVisibleRows(); //Do we need to scroll in order to see the selected row? if (top.awRow <= firstVisibleRow) listbox.scrollToIndex(top.awRow - 1); else if (top.awRow - 1 >= (firstVisibleRow + numOfVisibleRows)) listbox.scrollToIndex(top.awRow - numOfVisibleRows); top.awInputElement.focus(); /*} catch(ex) { top.awFocusRetry ++; if (top.awFocusRetry < 3) { dump("_awSetFocus failed, try it again...\n"); setTimeout("_awSetFocus();", 0); } else dump("_awSetFocus failed, forget about it!\n"); }*/}function awTabFromRecipient(element, event){ //If we are the last element in the listbox, we don't want to create a new row. if (element == awGetInputElement(top.MAX_RECIPIENTS)) top.doNotCreateANewRow = true; var row = awGetRowByInputElement(element); if (!event.shiftKey && row < top.MAX_RECIPIENTS) { var listBoxRow = row - 1; // listbox row indices are 0-based, ours are 1-based. var listBox = document.getElementById("addressingWidget"); listBox.listBoxObject.ensureIndexIsVisible(listBoxRow + 1); } // be sure to add the user add recipient to our ignore list // when the user tabs out of an autocomplete line... addRecipientsToIgnoreList(element.value);}function awTabFromMenulist(element, event){ var row = awGetRowByInputElement(element); if (event.shiftKey && row > 1) { var listBoxRow = row - 1; // listbox row indices are 0-based, ours are 1-based. var listBox = document.getElementById("addressingWidget"); listBox.listBoxObject.ensureIndexIsVisible(listBoxRow - 1); }}function awGetNumberOfRecipients(){ return top.MAX_RECIPIENTS;}function DragOverAddressingWidget(event){ var validFlavor = false; var dragSession = dragSession = gDragService.getCurrentSession(); if (dragSession.isDataFlavorSupported("text/x-moz-address")) validFlavor = true; if (validFlavor) dragSession.canDrop = true;}function DropOnAddressingWidget(event){ var dragSession = gDragService.getCurrentSession(); var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); trans.addDataFlavor("text/x-moz-address"); for ( var i = 0; i < dragSession.numDropItems; ++i ) { dragSession.getData ( trans, i ); var dataObj = new Object(); var bestFlavor = new Object(); var len = new Object(); trans.getAnyTransferData ( bestFlavor, dataObj, len ); if ( dataObj ) dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString); if ( !dataObj ) continue; // pull the address out of the data object var address = dataObj.data.substring(0, len.value); if (!address) continue; DropRecipient(event.target, address); }}function DropRecipient(target, recipient){ // break down and add each address return parseAndAddAddresses(recipient, awGetPopupElement(top.MAX_RECIPIENTS).selectedItem.getAttribute("value"));}function _awSetAutoComplete(selectElem, inputElem){ inputElem.disableAutocomplete = selectElem.value == 'addr_newsgroups' || selectElem.value == 'addr_followup' || selectElem.value == 'addr_other';}function awSetAutoComplete(rowNumber){ var inputElem = awGetInputElement(rowNumber); var selectElem = awGetPopupElement(rowNumber); _awSetAutoComplete(selectElem, inputElem)}function awRecipientTextCommand(userAction, element){ if (userAction == "typing" || userAction == "scrolling") awReturnHit(element);}// Called when an autocomplete session item is selected and the status of// the session it was selected from is nsIAutoCompleteStatus::failureItems.//// As of this writing, the only way that can happen is when an LDAP // autocomplete session returns an error to be displayed to the user.//// There are hardcoded messages in here, but these are just fallbacks for// when string bundles have already failed us.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -