]> err.no Git - scalable-opengroupware.org/commitdiff
proper validation for UIxMailToSelection
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 16:36:39 +0000 (16:36 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 16:36:39 +0000 (16:36 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@831 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SOGo.xcodeproj/project.pbxproj
SOGo/UI/MailerUI/ChangeLog
SOGo/UI/MailerUI/UIxMailToSelection.m
SOGo/UI/MailerUI/Version
SOGo/UI/MailerUI/product.plist
SOGo/UI/Templates/ChangeLog
SOGo/UI/Templates/UIxMailToSelection.wox
SOGo/UI/WebServerResources/UIxAppointmentEditor.js
SOGo/UI/WebServerResources/UIxContactEditor.js
SOGo/UI/WebServerResources/UIxMailToSelection.js [new file with mode: 0644]
SOGo/UI/WebServerResources/mailer.js

index 24a5151510fa5c2d6e8efb6d6d23e9be03bfafbb..cf4c8d13404898dc502b08a08612ea2bf88e35a8 100644 (file)
                AD3D6101088BF4E600CBB51B /* UIxContactEditorBase.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = UIxContactEditorBase.m; sourceTree = "<group>"; };
                AD3D6102088BF4E600CBB51B /* UIxContactsListViewBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = UIxContactsListViewBase.h; sourceTree = "<group>"; };
                AD3D6103088BF4E600CBB51B /* UIxContactsListViewBase.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = UIxContactsListViewBase.m; sourceTree = "<group>"; };
+               AD3D6336088D2E7400CBB51B /* UIxMailToSelection.js */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 2; lastKnownFileType = sourcecode.javascript; path = UIxMailToSelection.js; sourceTree = "<group>"; tabWidth = 4; };
+               AD3D63CE088D5EB000CBB51B /* calendar.css */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = calendar.css; sourceTree = "<group>"; };
+               AD3D63CF088D5EB000CBB51B /* UIxAppointmentEditor.js */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.javascript; path = UIxAppointmentEditor.js; sourceTree = "<group>"; };
+               AD3D63D0088D5EB000CBB51B /* UIxContactEditor.js */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.javascript; path = UIxContactEditor.js; sourceTree = "<group>"; };
                AD494C6206F5EA6600E51EC9 /* UIxContactSelector.m */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = UIxContactSelector.m; sourceTree = "<group>"; };
                AD494C8E06F606F900E51EC9 /* UIxContactsSelectionView.m */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = UIxContactsSelectionView.m; sourceTree = "<group>"; };
                AD494D1806F6EB3A00E51EC9 /* SOGoMailAccount.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = SOGoMailAccount.h; sourceTree = "<group>"; };
                ADDF4D7306DE0BAB00C4E7F8 /* Version */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; indentWidth = 8; path = Version; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; };
                ADDF4D7706DE0BFE00C4E7F8 /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 8; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; };
                ADDF4DBC06DE0E9900C4E7F8 /* bundle-info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = "bundle-info.plist"; sourceTree = "<group>"; };
-               ADDF4DBD06DE0E9900C4E7F8 /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 8; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; tabWidth = 8; };
+               ADDF4DBD06DE0E9900C4E7F8 /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 8; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; };
                ADDF4DBE06DE0E9900C4E7F8 /* common.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
                ADDF4DBF06DE0E9900C4E7F8 /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYING; sourceTree = "<group>"; };
                ADDF4DC006DE0E9900C4E7F8 /* COPYRIGHT */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYRIGHT; sourceTree = "<group>"; };
                        name = Components;
                        sourceTree = "<group>";
                };
-               AD2C74C3071AA0190087E027 /* CSS / Scripts */ = {
+               AD2C74C3071AA0190087E027 /* JS / CSS */ = {
                        isa = PBXGroup;
                        children = (
+                               ADE0AC130885C45100E62D67 /* mailer.css */,
+                               AD3D63CE088D5EB000CBB51B /* calendar.css */,
                                ADE0AC120885C45100E62D67 /* generic.js */,
                                ADE0AC140885C45100E62D67 /* mailer.js */,
                                ADE0AC150885C45100E62D67 /* searchfield.js */,
-                               ADE0AC130885C45100E62D67 /* mailer.css */,
                                ADE0AC160885C45100E62D67 /* uix.css */,
+                               AD3D63CF088D5EB000CBB51B /* UIxAppointmentEditor.js */,
+                               AD3D63D0088D5EB000CBB51B /* UIxContactEditor.js */,
+                               AD3D6336088D2E7400CBB51B /* UIxMailToSelection.js */,
                        );
-                       name = "CSS / Scripts";
+                       name = "JS / CSS";
+                       path = ../WebServerResources;
                        sourceTree = "<group>";
                };
                AD2C74C6071AA0ED0087E027 /* Formatters */ = {
                                ADDF4DC906DE0E9A00C4E7F8 /* product.plist */,
                                ADDF4DC106DE0E9A00C4E7F8 /* Localizable.strings */,
                                ADDF4DD306DE0EB600C4E7F8 /* Makefiles */,
-                               AD2C74C3071AA0190087E027 /* CSS / Scripts */,
+                               AD2C74C3071AA0190087E027 /* JS / CSS */,
                                ADDF4DD906DE0ECB00C4E7F8 /* Classes */,
                                ADDF4DD606DE0EC100C4E7F8 /* Components */,
                        );
index 6d7ff44d18073116b3c2efcdb747f5db30577b6f..2b20ddd30c56945b31c78fe2dbd46463446bb621 100644 (file)
@@ -1,3 +1,11 @@
+2005-07-19  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * v0.9.155
+
+       * UIxMailToSelection.m: externalized JavaScript
+
+       * product.plist: added new JavaScript files as public resources
+
 2005-07-19  Helge Hess  <helge.hess@opengroupware.org>
 
        * UIxMailEditor.m: do not complain on drafts not being found when the
index bada2e378a6924e14ba6e8414f513a248f4ab20c..9f4cc5269da6a66bc5b4cafdc42172bdae806ee1 100644 (file)
@@ -307,175 +307,15 @@ static NSArray *headers = nil;
   [self getAddressesFromFormValues:d];
 }
 
-/* response generation */
-
-- (NSString *)jsCode {
-  // TODO: can't we put this into a resource?
-  // TODO: might be better to use -stringByReplacingBindings: etc
-  static NSString *script = \
-  @"var currentIndex = %d;\n"
-  @"var lastIndex    = currentIndex;\n"
-  @"\n"
-  @"function hasAddress(email) {\n"
-  @"  var e = document.getElementById(email);\n"
-  @"  if(e)\n"
-  @"    return true;\n"
-  @"  return false;\n"
-  @"}\n"
-  @"\n"
-  @"function rememberAddress(email) {\n"
-  @"  var list, span, idx;\n"
-  @"  \n"
-  @"  list = document.getElementById('addr_addresses');\n"
-  @"  span = document.createElement('span');\n"
-  @"  span.id = email;\n"
-  @"  idx = document.createTextNode(currentIndex);\n"
-  @"  span.appendChild(idx);\n"
-  @"  list.appendChild(span);\n"
-  @"}\n"
-  @"\n"
-  @"function sanitizedCn(cn) {\n"
-  @"  var parts;\n"
-  @"  parts = cn.split(', ');\n"
-  @"  if(parts.length == 1)\n"
-  @"    return cn;\n"
-  @"  return parts[0];\n"
-  @"}\n"
-  @"\n"
-  @"function addAddress(type, email, uid, sn, cn, dn) {\n"
-  @"  var shouldAddRow, s, e;\n"
-  @"  \n"
-  @"  shouldAddRow = true;\n"
-  @"  s = this.sanitizedCn(cn) + ' <' + email + '>';\n"
-  @"\n"
-  @"  if(this.hasAddress(email))\n"
-  @"    return;\n"
-  @"\n"
-  @"  e = document.getElementById('addr_0');\n"
-  @"  if(e.value == '') {\n"
-  @"    e.value = s;\n"
-  @"    shouldAddRow = false;\n"
-  @"  }\n"
-  @"  if(shouldAddRow) {\n"
-  @"    this.fancyAddRow(false, s);\n"
-  @"  }\n"
-  @"  this.rememberAddress(email);\n"
-  @"}\n"
-  @"\n"
-  @"function fancyAddRow(shouldEdit, text) {\n"
-  @"  var addr, table, lastChild, proto, row, select, input;\n"
-  @"\n"
-  @"  addr = document.getElementById('addr_' + lastIndex);\n"
-  @"  if (addr && addr.value == '') {\n"
-  @"    input = document.getElementById('compose_subject_input');\n"
-  @"    if (input) {\n"
-  @"      input.focus();\n"
-  @"      input.select();\n"
-  @"      return;\n"
-  @"    }\n"
-  @"  }\n"
-  @"  table = this.getTable();\n"
-  @"  lastChild = document.getElementById('row_last');\n"
-  @"\n"
-  @"  currentIndex++;\n"
-  @"\n"
-  @"  proto = document.getElementById('row_' + lastIndex);\n"
-  @"  row = proto.cloneNode(true);\n"
-  @"  row.id = 'row_' + currentIndex;\n"
-  @"\n"
-  @"  // select popup\n"
-  @"  select = row.childNodes[1].childNodes[1];\n"
-  @"  select.name = 'popup_' + currentIndex;\n"
-  @"  select.value = proto.childNodes[1].childNodes[1].value;\n"
-  @"  input = row.childNodes[3].childNodes[1];\n"
-  @"  input.name  = 'addr_' + currentIndex;\n"
-  @"  input.id    = 'addr_' + currentIndex;\n"
-  @"  input.value = text;\n"
-  @"\n"
-  @"  table.insertBefore(row, lastChild);\n"
-  @"  if(shouldEdit) {\n"
-  @"    input.focus();\n"
-  @"    input.select();\n"
-  @"  }\n"
-  @"}\n"
-  @"\n"
-  @"function addressFieldGotFocus(sender) {\n"
-  @"  var idx;\n"
-  @"\n"
-  @"  idx = this.getIndexFromIdentifier(sender.id);\n"
-  @"  if ((lastIndex == idx) || (idx == 0)) return;\n"
-  @"  this.removeLastEditedRowIfEmpty();\n"
-  @"}\n"
-  @"function addressFieldLostFocus(sender) {\n"
-  @"  lastIndex = this.getIndexFromIdentifier(sender.id);\n"
-  @"}\n"
-  @"\n"
-  @"function removeIfNecessary(sender) {\n"
-  @"/*"
-  @"  var idx, addr, table, senderRow;\n"
-  @"\n"
-  @"  if(sender.value != '')\n"
-  @"    return;\n"
-  @"  if(sender.id == 'addr_0')\n"
-  @"    return;\n"
-  @"  idx = this.getIndexFromIdentifier(sender.id);\n"
-  @"  addr = this.findAddressWithIndex(idx);\n"
-  @"  if(addr) {\n"
-  @"     var addresses = document.getElementById('addr_addresses');\n"
-  @"     addresses.removeChild(addr);\n"
-  @"  }\n"
-  @"  table = this.getTable();\n"
-  @"  senderRow = this.findRowWithIndex(idx);\n"
-  @"  table.removeChild(senderRow);\n"
-  @"*/"
-  @"}\n"
-  @"\n"
-  @"function removeLastEditedRowIfEmpty() {\n"
-  @"  var idx, addr, table, senderRow;\n"
-  @"\n"
-  @"  idx = lastIndex;\n"
-  @"  addr = document.getElementById('addr_' + idx);\n"
-  @"  if (!addr) return;\n"
-  @"  if (addr.value != '') return;\n"
-  @"  addr = this.findAddressWithIndex(idx);\n"
-  @"  if(addr) {\n"
-  @"     var addresses = document.getElementById('addr_addresses');\n"
-  @"     addresses.removeChild(addr);\n"
-  @"  }\n"
-  @"  table = this.getTable();\n"
-  @"  senderRow = this.findRowWithIndex(idx);\n"
-  @"  table.removeChild(senderRow);\n"
-  @"}\n"
-  @"\n"
-  @"function findAddressWithIndex(idx) {\n"
-  @"  var list, i, count, addr, idx\n"
-  @"  list = document.getElementById('addr_addresses').childNodes;\n"
-  @"  count = list.length;\n"
-  @"  for(i = 0; i < count; i++) {\n"
-  @"    addr = list[i];\n"
-  @"    if(addr.innerHTML == idx)\n"
-  @"      return addr;\n"
-  @"  }\n"
-  @"  return null;\n"
-  @"}\n"
-  @"\n"
-  @"function findRowWithIndex(idx) {\n"
-  @"  var id = 'row_' + idx;\n"
-  @"  return document.getElementById(id);\n"
-  @"}\n"
-  @"\n"
-  @"function getIndexFromIdentifier(id) {\n"
-  @"  return id.split('_')[1];\n"
-  @"}\n"
-  @"\n"
-  @"function getTable() {\n"
-  @"  return document.getElementById('addr_table').childNodes[1];\n"
-  @"}\n";
-  unsigned idx;
-  
-  idx = [self->to count] + [self->cc count] + [self->bcc count];
-  
-  return [NSString stringWithFormat:script, idx];
+- (int)addressCount {
+  return [self->to count] + [self->cc count] + [self->bcc count];
+}
+
+- (int)currentIndex {
+  int count;
+
+  count = [self addressCount];
+  return count > 0 ? count - 1 : 0;
 }
 
 @end /* UIxMailToSelection */
index 3a1e35de9954050f22671f6072ef30e19a7e5ee8..6e79fcddac6293a2086028726f9a6d3587f27c5e 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=154
+SUBMINOR_VERSION:=155
 
 # v0.9.140 requires SoObjects/Mailer v0.9.100
 # v0.9.134 requires libSOGo          v0.9.41
index 099c97a8d1531b5232867ff9fcd1addec8340dcb..6babb46faf7e9bd5b6ba4c6a5f32d3f7a46a94f4 100644 (file)
@@ -7,7 +7,10 @@
     "mailer.js",
     "generic.js",
     "searchfield.js",
-    
+    "UIxAppointmentEditor.js",
+    "UIxContactEditor.js",
+    "UIxMailToSelection.js",
+
     "lori_32x32.png",
     
     "tbtv_account_17x17.gif",
index f700586ce74fda67b69a8bacb223d4dca0d89b05..b973e9b9a4bb3db7e9255fd2316e20b4b9a543d0 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-19  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * UIxMailToSelection.wox: changed inclusion of JavaScript to resource
+         lookup (with a little global stub being the exception)
+
 2005-07-19  Helge Hess  <helge.hess@opengroupware.org>
 
        * UIxAppointmentEditor.wox: import scheduler labels to the client,
index 6e217ef3271d195441d48576f1318d79b199795c..63fccb403edbb0ded6fbb857a32c9b63149f690f 100644 (file)
@@ -7,9 +7,10 @@
       border="0"
       width="100%"
 >
-  <script language="JavaScript"> <!-- TODO: use a resource -->
-    <var:string value="jsCode" const:escapeHTML="NO" />
+  <script language="JavaScript">
+    var currentIndex = <var:string value="currentIndex" />;
   </script>
+  <script language="JavaScript" rsrc:src="UIxMailToSelection.js"> <!-- Space! --></script>
 
   <table id="addr_table" style="width: 100%;">
     <var:foreach list="addressLists" item="addressList">
@@ -52,6 +53,9 @@
       </td>
     </tr>
   </table>
-  <span id="addr_addresses" style="visibility: hidden;">
+  <var:if condition="isUIxDebugEnabled">
+    <a href="#" onclick="checkAddresses();">check addresses</a>
+  </var:if>
+  <span id="addr_addresses" style="visibility: hidden;"><var:foreach list="addressLists" item="addressList"><var:foreach list="addressList" item="address"><span var:id="address" /></var:foreach></var:foreach>
   </span>
 </span>
\ No newline at end of file
index a2bfec1d56c1635a5e86b2d14fc37af272140f97..0285a1bb7948199e6bfba52b565635c0cd480370 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ Copyright (C) 2005 SKYRIX Software AG
+ This file is part of OpenGroupware.org.
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING.  If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
 function validateAptEditor() {
       var e;
       
index bfc1adeb74d2803027f812db09a39868636d10da..abf74d9bbdb9593747d2b2694308ef4e45368fd9 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ Copyright (C) 2005 SKYRIX Software AG
+ This file is part of OpenGroupware.org.
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING.  If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+
 function unescapeCallbackParameter(s) {
   if(!s || s.length == 0)
     return s;
diff --git a/SOGo/UI/WebServerResources/UIxMailToSelection.js b/SOGo/UI/WebServerResources/UIxMailToSelection.js
new file mode 100644 (file)
index 0000000..8a917e5
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ Copyright (C) 2005 SKYRIX Software AG
+ This file is part of OpenGroupware.org.
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING.  If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+/* Dependencies:
+ * It's required that "currentIndex" is defined in a top level context.
+ *
+ * Exports:
+ * defines UIxRecipientSelectorHasRecipients() returning a bool for the
+ * surrounding context to check.
+ */
+
+var lastIndex = currentIndex;
+
+function sanitizedCn(cn) {
+  var parts;
+  parts = cn.split(', ');
+  if(parts.length == 1)
+    return cn;
+  return parts[0];
+}
+
+function hasAddress(email) {
+  var e = document.getElementById(email);
+  if(e)
+    return true;
+  return false;
+}
+
+function rememberAddress(email) {
+  var list, span, idx;
+  
+  list    = document.getElementById('addr_addresses');
+  span    = document.createElement('span');
+  span.id = email;
+  idx     = document.createTextNode(currentIndex);
+  span.appendChild(idx);
+  list.appendChild(span);
+}
+
+function checkAddresses() {
+  alert("addressCount: " + this.getAddressCount() + " currentIndex: " + currentIndex + " lastIndex: " + lastIndex);
+}
+
+function addAddress(type, email, uid, sn, cn, dn) {
+  var shouldAddRow, s, e;
+  
+  shouldAddRow = true;
+  if (cn)
+    s = this.sanitizedCn(cn) + ' <' + email + '>';
+  else
+    s = email;
+
+  if(this.hasAddress(email))
+    return;
+  
+  e = document.getElementById('addr_0');
+  if(e.value == '') {
+    e.value = s;
+    shouldAddRow = false;
+  }
+  if(shouldAddRow) {
+    this.fancyAddRow(false, s);
+  }
+  this.rememberAddress(email);
+}
+
+function fancyAddRow(shouldEdit, text) {
+  var addr, table, lastChild, proto, row, select, input;
+  
+  addr = document.getElementById('addr_' + lastIndex);
+  if (addr && addr.value == '') {
+    input = document.getElementById('compose_subject_input');
+    if (input && input.value != '') {
+      input.focus();
+      input.select();
+      return;
+    }
+  }
+  table = this.getTable();
+  lastChild = document.getElementById('row_last');
+  
+  currentIndex++;
+  
+  proto = document.getElementById('row_' + lastIndex);
+  row = proto.cloneNode(true);
+  row.id = 'row_' + currentIndex;
+  
+  // select popup
+  select = row.childNodes[1].childNodes[1];
+  select.name = 'popup_' + currentIndex;
+  select.value = proto.childNodes[1].childNodes[1].value;
+  input = row.childNodes[3].childNodes[1];
+  input.name  = 'addr_' + currentIndex;
+  input.id    = 'addr_' + currentIndex;
+  input.value = text;
+  
+  table.insertBefore(row, lastChild);
+
+  if(shouldEdit) {
+    input.focus();
+    input.select();
+  }
+}
+
+function addressFieldGotFocus(sender) {
+  var idx;
+  
+  idx = this.getIndexFromIdentifier(sender.id);
+  if ((lastIndex == idx) || (idx == 0)) return;
+  this.removeLastEditedRowIfEmpty();
+}
+function addressFieldLostFocus(sender) {
+  lastIndex = this.getIndexFromIdentifier(sender.id);
+}
+
+function removeLastEditedRowIfEmpty() {
+  var idx, addr, table, senderRow;
+  
+  idx = lastIndex;
+  if (idx == 0) return;
+  addr = document.getElementById('addr_' + idx);
+  if (!addr) return;
+  if (addr.value != '') return;
+  addr = this.findAddressWithIndex(idx);
+  if(addr) {
+    var addresses = document.getElementById('addr_addresses');
+    addresses.removeChild(addr);
+  }
+  table = this.getTable();
+  senderRow = this.findRowWithIndex(idx);
+  table.removeChild(senderRow);
+}
+
+function findAddressWithIndex(idx) {
+  var list, i, count, addr, idx
+  list = document.getElementById('addr_addresses').childNodes;
+  count = list.length;
+  for(i = 0; i < count; i++) {
+    addr = list[i];
+    if(addr.innerHTML == idx)
+      return addr;
+  }
+  return null;
+}
+
+function findRowWithIndex(idx) {
+  var id = 'row_' + idx;
+  return document.getElementById(id);
+}
+
+function getIndexFromIdentifier(id) {
+  return id.split('_')[1];
+}
+
+function getTable() {
+  return document.getElementById('addr_table').childNodes[1];
+};
+
+function getAddressIDs() {
+  var table, rows, i, count, addressIDs;
+
+  addressIDs = new Array();
+
+  table = this.getTable();
+  rows  = table.childNodes;
+  count = rows.length;
+  
+  for (i = 0; i < count; i++) {
+    var row, rowId;
+    
+    row   = table.childNodes[i];
+    rowId = row.id;
+    if (rowId && rowId != 'row_last') {
+      var idx;
+
+      idx = this.getIndexFromIdentifier(rowId);
+      addressIDs.push(idx);
+    }
+  }
+  return addressIDs;
+}
+
+function getAddressCount() {
+  var addressCount, addressIDs, i, count;
+  
+  addressCount = 0;
+  addressIDs   = this.getAddressIDs();
+  count        = addressIDs.length;
+  for (i = 0; i < count; i++) {
+    var idx, input;
+
+    idx   = addressIDs[i];
+    input = document.getElementById('addr_' + idx);
+    if (input.value != '')
+      addressCount++;
+  }
+  return addressCount;
+}
+
+function UIxRecipientSelectorHasRecipients() {
+  var count;
+  
+  count = this.getAddressCount();
+  if (count > 0)
+    return true;
+  return false;
+}
index 58f3d604932c9df6891a2d74e269ab0bf7c7a4c5..049e78c045c4931e041d7dcdec65865f9f90946c 100644 (file)
@@ -113,7 +113,12 @@ function clickedEditorSend(sender) {
     return false;
 
   // TODO: validate whether we have a recipient! (#1220)
-  
+  /*
+  if (!UIxRecipientSelectorHasRecipients()) {
+    alert("do not have any recipients?!");
+    return false;
+  }
+  */
   document.pageform.action="send";
   document.pageform.submit();
   // if everything is ok, close the window