Enterprise Tookit for Acrobat Products > Mobile > (Android | iOS)

JavaScript for Acrobat Reader Mobile API Reference (Android)

File: Field.js

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. * Copyright 2012 Adobe Systems Incorporated
  7. * All Rights Reserved.
  8. *
  9. * NOTICE: All information contained herein is, and remains
  10. * the property of Adobe Systems Incorporated and its suppliers,
  11. * if any. The intellectual and technical concepts contained
  12. * herein are proprietary to Adobe Systems Incorporated and its
  13. * suppliers and are protected by trade secret or copyright law.
  14. * Dissemination of this information or reproduction of this material
  15. * is strictly forbidden unless prior written permission is obtained
  16. * from Adobe Systems Incorporated.
  17. *
  18. **************************************************************************/
  19. /**
  20. * This object represents an Acrobat form field (that is, a field created using the Acrobat
  21. * form tool or the Doc addField method). In the same manner that a form author can modify an
  22. * existing field's properties, the JavaScript user can use the Field object to perform the
  23. * same modifications.
  24. *
  25. * @class Field
  26. * @param name {String} The name of the field.
  27. */
  28. function Field(name)
  29. {
  30. this.name = name;
  31. };
  32. Field.prototype =
  33. {
  34. /**
  35. * Returns the type of the field as a string.
  36. *
  37. * @property type
  38. * @type {String}
  39. * @readonly
  40. */
  41. get type()
  42. {
  43. return window._field.getType(this.name);
  44. },
  45. /**
  46. * The value of the field data that the user has entered. Depending on the type of the field,
  47. * may be a String, Date, or Number. Typically, the value is used to create calculated fields.
  48. *
  49. * @property value
  50. * @type {Any}
  51. */
  52. get value()
  53. {
  54. var val = window._field.getValue(this.name);
  55. if ((window._field.isNumberFormatType(this.name) || !isNaN(val)) && val != "")
  56. val = parseFloat(val);
  57. return val;
  58. },
  59. set value(_val)
  60. {
  61. window._field.setValue(_val, this.name);
  62. },
  63. /**
  64. * The foreground color of a field. It represents the text color for text, button,
  65. * or list box fields and the check color for check box or radio button fields. Values
  66. * are defined by Color arrays.
  67. *
  68. * @private
  69. * @property textColor
  70. * @type {Object}
  71. */
  72. set textColor(_textColor)
  73. {
  74. if (_textColor.length >= 2 && typeof _textColor[0] == "string" && _textColor[0] == "G" &&
  75. typeof _textColor[1] == "number")
  76. {
  77. window._field.setGrayTextColor(_textColor[1], this.name);
  78. }
  79. else if (_textColor.length >= 4 && typeof _textColor[0] == "string" && _textColor[0] == "RGB" &&
  80. typeof _textColor[1] == "number" && typeof _textColor[2] == "number" && typeof _textColor[3] == "number")
  81. {
  82. window._field.setRGBTextColor(_textColor[1], _textColor[2], _textColor[3], this.name);
  83. }
  84. }
  85. };
  86. /**
  87. * Gets the array of terminal child fields (that is, fields that can have a value) for
  88. * this Field object, the parent field.
  89. *
  90. * @method getArray
  91. * @return {Object} An array of Field objects.
  92. */
  93. Field.prototype.getArray = function()
  94. {
  95. var returnVal;
  96. // get the comma separated field names from native
  97. var fieldNames = window._field.getArray(this.name);
  98. if (!isNullOrUndefined(fieldNames) && fieldNames.length > 0)
  99. {
  100. returnVal = new Array();
  101. // split the comma separate field names and create field object
  102. // using each field name
  103. var fieldNameArray = fieldNames.split(",");
  104. for (var i = 0; i<fieldNameArray.length; i++)
  105. {
  106. returnVal[i] = new Field(fieldNameArray[i]);
  107. }
  108. }
  109. return returnVal;
  110. };
  111. /**
  112. * Sets the focus to this field. This can involve changing the page that the user is
  113. * currently on or causing the view to scroll to a new position in the document.
  114. *
  115. * @method setFocus
  116. */
  117. Field.prototype.setFocus = function()
  118. {
  119. window._field.setFocus(this.name);
  120. };
  121. //register undefined properties on the Field.prototype object
  122. registerUndefinedProperty(Field.prototype, 'Field', 'alignment');
  123. registerUndefinedProperty(Field.prototype, 'Field', 'borderStyle');
  124. registerUndefinedProperty(Field.prototype, 'Field', 'buttonAlignX');
  125. registerUndefinedProperty(Field.prototype, 'Field', 'buttonAlignY');
  126. registerUndefinedProperty(Field.prototype, 'Field', 'buttonFitBounds');
  127. registerUndefinedProperty(Field.prototype, 'Field', 'buttonPosition');
  128. registerUndefinedProperty(Field.prototype, 'Field', 'buttonScaleHow');
  129. registerUndefinedProperty(Field.prototype, 'Field', 'buttonScaleWhen');
  130. registerUndefinedProperty(Field.prototype, 'Field', 'calcOrderIndex');
  131. registerUndefinedProperty(Field.prototype, 'Field', 'charLimit');
  132. registerUndefinedProperty(Field.prototype, 'Field', 'comb');
  133. registerUndefinedProperty(Field.prototype, 'Field', 'commitOnSelChange');
  134. registerUndefinedProperty(Field.prototype, 'Field', 'currentValueIndices');
  135. registerUndefinedProperty(Field.prototype, 'Field', 'defaultStyle');
  136. registerUndefinedProperty(Field.prototype, 'Field', 'defaultValue');
  137. registerUndefinedProperty(Field.prototype, 'Field', 'doNotScroll');
  138. registerUndefinedProperty(Field.prototype, 'Field', 'doNotSpellCheck');
  139. registerUndefinedProperty(Field.prototype, 'Field', 'delay');
  140. registerUndefinedProperty(Field.prototype, 'Field', 'display');
  141. registerUndefinedProperty(Field.prototype, 'Field', 'doc');
  142. registerUndefinedProperty(Field.prototype, 'Field', 'editable');
  143. registerUndefinedProperty(Field.prototype, 'Field', 'exportValues');
  144. registerUndefinedProperty(Field.prototype, 'Field', 'fileSelect');
  145. registerUndefinedProperty(Field.prototype, 'Field', 'fillColor');
  146. registerUndefinedProperty(Field.prototype, 'Field', 'hidden');
  147. registerUndefinedProperty(Field.prototype, 'Field', 'highlight');
  148. registerUndefinedProperty(Field.prototype, 'Field', 'lineWidth');
  149. registerUndefinedProperty(Field.prototype, 'Field', 'multiline');
  150. registerUndefinedProperty(Field.prototype, 'Field', 'multipleSelection');
  151. registerUndefinedProperty(Field.prototype, 'Field', 'numItems');
  152. registerUndefinedProperty(Field.prototype, 'Field', 'page');
  153. registerUndefinedProperty(Field.prototype, 'Field', 'password');
  154. registerUndefinedProperty(Field.prototype, 'Field', 'print');
  155. registerUndefinedProperty(Field.prototype, 'Field', 'radiosInUnison');
  156. registerUndefinedProperty(Field.prototype, 'Field', 'readonly');
  157. registerUndefinedProperty(Field.prototype, 'Field', 'rect');
  158. registerUndefinedProperty(Field.prototype, 'Field', 'required');
  159. registerUndefinedProperty(Field.prototype, 'Field', 'richText');
  160. registerUndefinedProperty(Field.prototype, 'Field', 'richValue');
  161. registerUndefinedProperty(Field.prototype, 'Field', 'rotation');
  162. registerUndefinedProperty(Field.prototype, 'Field', 'strokeColor');
  163. registerUndefinedProperty(Field.prototype, 'Field', 'style');
  164. registerUndefinedProperty(Field.prototype, 'Field', 'submitName');
  165. registerUndefinedProperty(Field.prototype, 'Field', 'textFont');
  166. registerUndefinedProperty(Field.prototype, 'Field', 'textSize');
  167. registerUndefinedProperty(Field.prototype, 'Field', 'userName');
  168. registerUndefinedProperty(Field.prototype, 'Field', 'valueAsString');

© 2013-15 Adobe Systems, Inc. All rights reserved. Use of these APIs including, the download of software, submission of comments, ideas, feature requests and techniques, and Adobe's rights to use such submitted materials, is governed by the Adobe.com Terms of Use and the Adobe Privacy Policy.