API Docs for: 1.0.0
Show:

File: Resources/public/js/views/fields/ez-textblock-editview.js

  1. /*
  2. * Copyright (C) eZ Systems AS. All rights reserved.
  3. * For full copyright and license information view LICENSE file distributed with this source code.
  4. */
  5. YUI.add('ez-textblock-editview', function (Y) {
  6. "use strict";
  7. /**
  8. * Provides the field edit view for the Text Block (eztext) fields
  9. *
  10. * @module ez-textblock-editview
  11. */
  12. Y.namespace('eZ');
  13.  
  14. var FIELDTYPE_IDENTIFIER = 'eztext';
  15.  
  16. /**
  17. * Text Block edit view
  18. *
  19. * @namespace eZ
  20. * @class TextBlockEditView
  21. * @constructor
  22. * @extends eZ.FieldEditView
  23. */
  24. Y.eZ.TextBlockEditView = Y.Base.create('textBlockEditView', Y.eZ.FieldEditView, [], {
  25. events: {
  26. '.ez-textblock-input-ui textarea': {
  27. 'blur': 'validate',
  28. 'valuechange': 'validate'
  29. }
  30. },
  31.  
  32. /**
  33. * Validates the current input of text block
  34. *
  35. * @method validate
  36. */
  37. validate: function () {
  38. if ( this._getInputValidity().valueMissing ) {
  39. this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
  40. } else {
  41. this.set('errorStatus', false);
  42. }
  43. },
  44.  
  45. /**
  46. * Defines the variables to imported in the field edit template for text
  47. * block.
  48. *
  49. * @protected
  50. * @method _variables
  51. * @return {Object} containing isRequired entry
  52. */
  53. _variables: function () {
  54. return {
  55. "isRequired": this.get('fieldDefinition').isRequired
  56. };
  57. },
  58.  
  59. /**
  60. * Returns the input validity state object for the input generated by
  61. * the text block template
  62. *
  63. * See https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
  64. *
  65. * @protected
  66. * @method _getInputValidity
  67. * @return {ValidityState}
  68. */
  69. _getInputValidity: function () {
  70. return this._getTextareaNode().get('validity');
  71. },
  72.  
  73. /**
  74. * Returns the currently filled value of the text block field
  75. *
  76. * @method _getFieldValue
  77. * @protected
  78. * @return String
  79. */
  80. _getFieldValue: function () {
  81. return this._getTextareaNode().get('value');
  82. },
  83.  
  84. /**
  85. * Returns the Y.Node of the textarea used for the user input
  86. *
  87. * @method _getTextareaNode
  88. * @private
  89. * @return {Y.Node}
  90. */
  91. _getTextareaNode: function () {
  92. return this.get('container').one('.ez-textblock-input-ui textarea');
  93. },
  94. });
  95.  
  96. Y.eZ.FieldEditView.registerFieldEditView(
  97. FIELDTYPE_IDENTIFIER, Y.eZ.TextBlockEditView
  98. );
  99. });
  100.