attachment.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* The contents of this file are subject to the Mozilla Public
  2. * License Version 1.1 (the "License"); you may not use this file
  3. * except in compliance with the License. You may obtain a copy of
  4. * the License at http://www.mozilla.org/MPL/
  5. *
  6. * Software distributed under the License is distributed on an "AS
  7. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  8. * implied. See the License for the specific language governing
  9. * rights and limitations under the License.
  10. *
  11. * The Original Code is the Bugzilla Bug Tracking System.
  12. *
  13. * The Initial Developer of the Original Code is Netscape Communications
  14. * Corporation. Portions created by Netscape are
  15. * Copyright (C) 1998 Netscape Communications Corporation. All
  16. * Rights Reserved.
  17. *
  18. * Contributor(s): Myk Melez <myk@mozilla.org>
  19. * Joel Peshkin <bugreport@peshkin.net>
  20. * Erik Stambaugh <erik@dasbistro.com>
  21. * Marc Schumann <wurblzap@gmail.com>
  22. */
  23. function updateCommentPrivacy(checkbox) {
  24. var text_elem = document.getElementById('comment');
  25. if (checkbox.checked) {
  26. text_elem.className='bz_private';
  27. } else {
  28. text_elem.className='';
  29. }
  30. }
  31. function setContentTypeDisabledState(form)
  32. {
  33. var isdisabled = false;
  34. if (form.ispatch.checked)
  35. isdisabled = true;
  36. for (var i=0 ; i<form.contenttypemethod.length ; i++)
  37. form.contenttypemethod[i].disabled = isdisabled;
  38. form.contenttypeselection.disabled = isdisabled;
  39. form.contenttypeentry.disabled = isdisabled;
  40. // if WEBKIT_CHANGES
  41. if (isdisabled) {
  42. document.getElementById('legal').style.visibility = "visible";
  43. document.getElementById('create').value = "Agree and Submit";
  44. } else {
  45. document.getElementById('create').value = "Submit";
  46. document.getElementById('legal').style.visibility = "collapse";
  47. }
  48. // endif WEBKIT_CHANGES
  49. }
  50. function URLFieldHandler() {
  51. var field_attachurl = document.getElementById("attachurl");
  52. var greyfields = new Array("data", "ispatch", "autodetect",
  53. "list", "manual", "bigfile",
  54. "contenttypeselection",
  55. "contenttypeentry");
  56. var i, thisfield;
  57. if (field_attachurl.value.match(/^\s*$/)) {
  58. for (i = 0; i < greyfields.length; i++) {
  59. thisfield = document.getElementById(greyfields[i]);
  60. if (thisfield) {
  61. thisfield.removeAttribute("disabled");
  62. }
  63. }
  64. } else {
  65. for (i = 0; i < greyfields.length; i++) {
  66. thisfield = document.getElementById(greyfields[i]);
  67. if (thisfield) {
  68. thisfield.setAttribute("disabled", "disabled");
  69. }
  70. }
  71. }
  72. }
  73. function DataFieldHandler() {
  74. var field_data = document.getElementById("data");
  75. var greyfields = new Array("attachurl");
  76. var i, thisfield;
  77. if (field_data.value.match(/^\s*$/)) {
  78. for (i = 0; i < greyfields.length; i++) {
  79. thisfield = document.getElementById(greyfields[i]);
  80. if (thisfield) {
  81. thisfield.removeAttribute("disabled");
  82. }
  83. }
  84. } else {
  85. for (i = 0; i < greyfields.length; i++) {
  86. thisfield = document.getElementById(greyfields[i]);
  87. if (thisfield) {
  88. thisfield.setAttribute("disabled", "disabled");
  89. }
  90. }
  91. }
  92. }
  93. function clearAttachmentFields() {
  94. var element;
  95. document.getElementById('data').value = '';
  96. DataFieldHandler();
  97. if ((element = document.getElementById('bigfile')))
  98. element.checked = '';
  99. if ((element = document.getElementById('attachurl'))) {
  100. element.value = '';
  101. URLFieldHandler();
  102. }
  103. document.getElementById('description').value = '';
  104. document.getElementById('ispatch').checked = '';
  105. if ((element = document.getElementById('isprivate')))
  106. element.checked = '';
  107. }