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

JavaScript for Acrobat Reader Mobile API Reference (iOS)

File: Field.js

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. * Copyright 2014 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 field {Object} The underlying field.
  27. */
  28. function Field(field)
  29. {
  30. this.field = field;
  31. };
  32. Field.prototype =
  33. {
  34. /**
  35. * This property returns the fully qualified field name of the field as a string object.
  36. *
  37. * @property name
  38. * @type {String}
  39. */
  40. get name()
  41. {
  42. return this.field.name;
  43. },
  44. /**
  45. * Returns the type of the field as a string.
  46. *
  47. * @property type
  48. * @type {String}
  49. * @readonly
  50. */
  51. get type()
  52. {
  53. return this.field.type;
  54. },
  55. /**
  56. * The value of the field data that the user has entered. Depending on the type of the field,
  57. * may be a String, Date, or Number. Typically, the value is used to create calculated fields.
  58. *
  59. * @property value
  60. * @type {Any}
  61. */
  62. get value()
  63. {
  64. var returnVal;
  65. var _val = this.field.value;
  66. if (typeof _val == 'number' || ! isNaN(_val))
  67. {
  68. if (typeof _val == 'string')
  69. {
  70. if (_val.trim() != "")
  71. returnVal = parseFloat(_val);
  72. else
  73. returnVal = _val;
  74. }
  75. else
  76. {
  77. returnVal = parseFloat(_val);
  78. }
  79. }
  80. else
  81. {
  82. returnVal = _val;
  83. }
  84. return returnVal;
  85. },
  86. set value(_val)
  87. {
  88. if (this.field.setValueWillFail())
  89. throw { name : "InvalidSetError", message : "Set not possible, invalid or unknown" };
  90. this.field.value = _val + "";
  91. },
  92. /**
  93. * The foreground color of a field. It represents the text color for text, button,
  94. * or list box fields and the check color for check box or radio button fields. Values
  95. * are defined by Color arrays.
  96. *
  97. * @private
  98. * @property textColor
  99. * @type {Object}
  100. */
  101. set textColor(_textColor)
  102. {
  103. this.field.textColor = _textColor;
  104. }
  105. };
  106. /**
  107. * Gets the array of terminal child fields (that is, fields that can have a value) for
  108. * this Field object, the parent field.
  109. *
  110. * @method getArray
  111. * @return {Object} An array of Field objects.
  112. */
  113. Field.prototype.getArray = function()
  114. {
  115. var returnVal = new Array();
  116. var fieldsArray = this.field.getArray();
  117. if (fieldsArray)
  118. {
  119. // iterate array of field names and create field objects
  120. for (var index = 0; index < fieldsArray.length; index++)
  121. {
  122. returnVal[index] = new Field(fieldsArray[index]);
  123. }
  124. }
  125. return returnVal;
  126. };
  127. /**
  128. * Sets the focus to this field. This can involve changing the page that the user is
  129. * currently on or causing the view to scroll to a new position in the document.
  130. *
  131. * @method setFocus
  132. */
  133. Field.prototype.setFocus = function()
  134. {
  135. this.field.setFocus();
  136. };
  137. // register undefined properties on the Field.prototype object
  138. registerUndefinedProperty(Field.prototype, 'Field', 'alignment');
  139. registerUndefinedProperty(Field.prototype, 'Field', 'borderStyle');
  140. registerUndefinedProperty(Field.prototype, 'Field', 'buttonAlignX');
  141. registerUndefinedProperty(Field.prototype, 'Field', 'buttonAlignY');
  142. registerUndefinedProperty(Field.prototype, 'Field', 'buttonFitBounds');
  143. registerUndefinedProperty(Field.prototype, 'Field', 'buttonPosition');
  144. registerUndefinedProperty(Field.prototype, 'Field', 'buttonScaleHow');
  145. registerUndefinedProperty(Field.prototype, 'Field', 'buttonScaleWhen');
  146. registerUndefinedProperty(Field.prototype, 'Field', 'calcOrderIndex');
  147. registerUndefinedProperty(Field.prototype, 'Field', 'charLimit');
  148. registerUndefinedProperty(Field.prototype, 'Field', 'comb');
  149. registerUndefinedProperty(Field.prototype, 'Field', 'commitOnSelChange');
  150. registerUndefinedProperty(Field.prototype, 'Field', 'currentValueIndices');
  151. registerUndefinedProperty(Field.prototype, 'Field', 'defaultStyle');
  152. registerUndefinedProperty(Field.prototype, 'Field', 'defaultValue');
  153. registerUndefinedProperty(Field.prototype, 'Field', 'doNotScroll');
  154. registerUndefinedProperty(Field.prototype, 'Field', 'doNotSpellCheck');
  155. registerUndefinedProperty(Field.prototype, 'Field', 'delay');
  156. registerUndefinedProperty(Field.prototype, 'Field', 'display');
  157. registerUndefinedProperty(Field.prototype, 'Field', 'doc');
  158. registerUndefinedProperty(Field.prototype, 'Field', 'editable');
  159. registerUndefinedProperty(Field.prototype, 'Field', 'exportValues');
  160. registerUndefinedProperty(Field.prototype, 'Field', 'fileSelect');
  161. registerUndefinedProperty(Field.prototype, 'Field', 'fillColor');
  162. registerUndefinedProperty(Field.prototype, 'Field', 'hidden');
  163. registerUndefinedProperty(Field.prototype, 'Field', 'highlight');
  164. registerUndefinedProperty(Field.prototype, 'Field', 'lineWidth');
  165. registerUndefinedProperty(Field.prototype, 'Field', 'multiline');
  166. registerUndefinedProperty(Field.prototype, 'Field', 'multipleSelection');
  167. registerUndefinedProperty(Field.prototype, 'Field', 'numItems');
  168. registerUndefinedProperty(Field.prototype, 'Field', 'page');
  169. registerUndefinedProperty(Field.prototype, 'Field', 'password');
  170. registerUndefinedProperty(Field.prototype, 'Field', 'print');
  171. registerUndefinedProperty(Field.prototype, 'Field', 'radiosInUnison');
  172. registerUndefinedProperty(Field.prototype, 'Field', 'readonly');
  173. registerUndefinedProperty(Field.prototype, 'Field', 'rect');
  174. registerUndefinedProperty(Field.prototype, 'Field', 'required');
  175. registerUndefinedProperty(Field.prototype, 'Field', 'richText');
  176. registerUndefinedProperty(Field.prototype, 'Field', 'richValue');
  177. registerUndefinedProperty(Field.prototype, 'Field', 'rotation');
  178. registerUndefinedProperty(Field.prototype, 'Field', 'strokeColor');
  179. registerUndefinedProperty(Field.prototype, 'Field', 'style');
  180. registerUndefinedProperty(Field.prototype, 'Field', 'submitName');
  181. registerUndefinedProperty(Field.prototype, 'Field', 'textFont');
  182. registerUndefinedProperty(Field.prototype, 'Field', 'textSize');
  183. registerUndefinedProperty(Field.prototype, 'Field', 'userName');
  184. 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.