modules/property.js

  1. aeq = ( function ( aeq ) {
  2. /**
  3. * Module for dealing with Property objects.
  4. * @namespace aeq.property
  5. * @memberof aeq
  6. * @type {Object}
  7. */
  8. aeq.property = aeq.extend({}, {
  9. toString: function () {
  10. return '[object aeq.property]';
  11. },
  12. // Function for extending the prototype using objects
  13. extend: aeq.extend,
  14. /**
  15. * Returns the property value type of a Property as a string.
  16. * @method
  17. * @memberof aeq.property
  18. * @param {Property} property The property to get the value type of.
  19. * @return {string} The property value type, on of:
  20. *
  21. * - `NO_VALUE`: Stores no data.
  22. * - `ThreeD_SPATIAL`: Array of three floating-point positional values.
  23. * For example, an Anchor Point value might be `[10.0, 20.2, 0.0]`
  24. * - `ThreeD`: Array of three floating-point quantitative values.
  25. * For example, a Scale value might be `[100.0, 20.2, 0.0]`
  26. * - `TwoD_SPATIAL`: Array of 2 floating-point positional values.
  27. * For example, an Anchor Point value might be `[5.1, 10.0]`
  28. * - `TwoD`: Array of 2 floating-point quantitative values.
  29. * For example, a Scale value might be `[5.1, 100.0]`
  30. * - `OneD`: A floating-point value.
  31. * - `COLOR`:Array of 4 floating-point values, in the range `[0.0..1.0]`.
  32. * For example, `[0.8, 0.3, 0.1, 1.0]`
  33. * - `CUSTOM_VALUE`: Custom property value, such as the Histogram
  34. * property for the Levels effect.
  35. * - `MARKER`: MarkerValue object
  36. * - `LAYER_INDEX`: Integer; a value of `0` means no layer.
  37. * - `MASK_INDEX`: Integer; a value of `0` means no mask.
  38. * - `SHAPE`: Shape object
  39. * - `TEXT_DOCUMENT`: TextDocument object
  40. *
  41. * @example <caption>Returns "ThreeD_SPATIAL"</caption>
  42. * aeq.property.valueType( layer.Transform.Position )
  43. */
  44. valueType: function ( property ) {
  45. return aeq.valueInObject( property.propertyValueType || property, PropertyValueType );
  46. },
  47. /**
  48. * Returns the property type as a string.
  49. * @method
  50. * @memberof aeq.property
  51. * @param {Property} property The property to get the type of
  52. * @return {string} The property type, on of:
  53. *
  54. * - `PROPERTY`: A single property such as position or zoom.
  55. * - `INDEXED_GROUP`: A property group whose members have an editable name
  56. * and an index. Effects and masks are indexed groups. For example,
  57. * the masks property of a layer refers to a variable number of individual
  58. * masks by index number.
  59. * - `NAMED_GROUP`: A property group in which the member names are not
  60. * editable. Layers are named groups.
  61. */
  62. type: function ( property ) {
  63. return aeq.valueInObject( property.propertyType || property, PropertyType );
  64. },
  65. /**
  66. * Gets the layer the given property is contained in.
  67. * @method
  68. * @memberof aeq.property
  69. * @param {Property} property The Property to get layer from.
  70. * @return {Layer} The containing Layer object.
  71. */
  72. getLayer: function ( property ) {
  73. var depth = property.propertyDepth;
  74. return property.propertyGroup( depth );
  75. }
  76. });
  77. // Function aliases
  78. aeq.prop = aeq.property;
  79. return aeq;
  80. }( aeq || {}) );