sproutcore 1.5.0.pre.4 → 1.5.0.pre.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/CHANGELOG +6 -0
  2. data/VERSION.yml +1 -1
  3. data/lib/Buildfile +1 -1
  4. data/lib/buildtasks/build.rake +14 -6
  5. data/lib/buildtasks/manifest.rake +171 -72
  6. data/lib/frameworks/sproutcore/Buildfile +3 -5
  7. data/lib/frameworks/sproutcore/CHANGELOG.md +9 -0
  8. data/lib/frameworks/sproutcore/apps/test_controls/resources/main_page.js +2 -1
  9. data/lib/frameworks/sproutcore/apps/test_controls/resources/progress_page.js +7 -17
  10. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +7 -1
  11. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +14 -1
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +0 -2
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +1 -1
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +14 -3
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/collection.js +1 -1
  16. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +2 -2
  17. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +6 -0
  18. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +1 -1
  19. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
  20. data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +49 -4
  21. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +8 -0
  22. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +46 -1
  23. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +32 -5
  24. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/checkbox.js +32 -6
  25. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +31 -3
  26. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +15 -3
  27. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio.js +28 -7
  28. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -1
  29. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +20 -1
  30. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/well.js +2 -4
  31. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +40 -34
  32. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +35 -0
  33. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +43 -0
  34. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +47 -0
  35. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +6 -16
  36. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/ui.js +21 -0
  37. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/disclosure/ui.js +41 -1
  38. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +128 -0
  39. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/ui.js +93 -3
  40. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +13 -1
  41. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +28 -0
  42. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +47 -0
  43. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +51 -0
  44. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/toolbar/method.js +33 -0
  45. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/toolbar/ui.js +29 -0
  46. data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +28 -0
  47. data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +9 -1
  48. data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +148 -134
  49. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +18 -0
  50. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +30 -3
  51. data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +9 -0
  52. data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +52 -4
  53. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +2 -1
  54. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +36 -3
  55. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +1 -1
  56. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +9 -1
  57. data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +15 -4
  58. data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +1 -6
  59. data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +4 -2
  60. data/lib/frameworks/sproutcore/frameworks/desktop/views/toolbar.js +7 -0
  61. data/lib/frameworks/sproutcore/frameworks/desktop/views/well.js +1 -2
  62. data/lib/frameworks/sproutcore/frameworks/forms/views/form.js +3 -1
  63. data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/bootstrap.rhtml +1 -1
  64. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +0 -9
  65. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/editable.js +1 -1
  66. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +2 -0
  67. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
  68. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +25 -1
  69. data/lib/frameworks/sproutcore/frameworks/foundation/system/chance.js +64 -0
  70. data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +34 -27
  71. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/editable/ui.js +42 -0
  72. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/ui.js +62 -0
  73. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +0 -8
  74. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +12 -0
  75. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +48 -1
  76. data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +19 -0
  77. data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +2 -0
  78. data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +11 -5
  79. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +152 -74
  80. data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +12 -9
  81. data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +1476 -176
  82. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +0 -2
  83. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +227 -32
  84. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +11 -11
  85. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +1 -1
  86. data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +10 -0
  87. data/lib/frameworks/sproutcore/lib/index.rhtml +30 -8
  88. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/18px/segmented.css +4 -4
  89. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented.css +4 -4
  90. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented.css +4 -4
  91. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/44px/segmented.css +4 -4
  92. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/segmented.css +4 -0
  93. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/slider.css +5 -1
  94. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/slider.js +11 -3
  95. data/lib/frameworks/sproutcore/themes/ace/resources/well/well.css +7 -8
  96. data/lib/frameworks/sproutcore/themes/ace/resources/well/well.js +2 -4
  97. data/lib/gen/app/templates/apps/@target_name@/Buildfile +14 -0
  98. data/lib/gen/app/templates/apps/@target_name@/theme.js +27 -0
  99. data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +4 -0
  100. data/lib/gen/project/templates/@filename@/Buildfile +7 -2
  101. data/lib/gen/theme/templates/themes/@target_name@/Buildfile +3 -0
  102. data/lib/gen/theme/templates/themes/@target_name@/theme.js +23 -0
  103. data/lib/sproutcore/builders.rb +2 -0
  104. data/lib/sproutcore/builders/chance.rb +64 -0
  105. data/lib/sproutcore/builders/chance_file.rb +59 -0
  106. data/lib/sproutcore/builders/combine.rb +0 -45
  107. data/lib/sproutcore/builders/html.rb +1 -1
  108. data/lib/sproutcore/builders/minify.rb +5 -17
  109. data/lib/sproutcore/builders/module.rb +2 -2
  110. data/lib/sproutcore/builders/string_wrapper.rb +13 -15
  111. data/lib/sproutcore/helpers.rb +1 -1
  112. data/lib/sproutcore/helpers/minifier.rb +56 -0
  113. data/lib/sproutcore/helpers/static_helper.rb +86 -40
  114. data/lib/sproutcore/models/generator.rb +16 -0
  115. data/lib/sproutcore/models/manifest_entry.rb +8 -1
  116. data/lib/sproutcore/models/target.rb +101 -33
  117. data/lib/sproutcore/tools.rb +0 -7
  118. data/lib/sproutcore/tools/build.rb +2 -37
  119. data/spec/buildtasks/manifest/prepare_build_tasks/chance_spec.rb +100 -0
  120. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +86 -9
  121. data/spec/buildtasks/manifest/prepare_build_tasks/css_spec.rb +1 -1
  122. data/spec/buildtasks/manifest/prepare_build_tasks/minify_spec.rb +1 -1
  123. data/spec/buildtasks/manifest/prepare_build_tasks/module_info_spec.rb +96 -0
  124. data/spec/buildtasks/manifest/prepare_build_tasks/module_spec.rb +83 -0
  125. data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +37 -4
  126. data/spec/buildtasks/manifest/spec_helper.rb +4 -0
  127. data/spec/fixtures/builder_tests/Buildfile +11 -9
  128. data/spec/fixtures/builder_tests/apps/chance_test/Buildfile +14 -0
  129. data/spec/fixtures/builder_tests/apps/chance_test/core.js +27 -0
  130. data/spec/fixtures/builder_tests/apps/chance_test/main.js +30 -0
  131. data/spec/fixtures/builder_tests/apps/chance_test/resources/demo.css +6 -0
  132. data/spec/fixtures/builder_tests/apps/chance_test/resources/last_file.css +7 -0
  133. data/spec/fixtures/builder_tests/apps/chance_test/resources/loading.rhtml +9 -0
  134. data/spec/fixtures/builder_tests/apps/chance_test/resources/main_page.js +24 -0
  135. data/spec/fixtures/builder_tests/apps/chance_test/resources/z_first_file.css +6 -0
  136. data/spec/fixtures/builder_tests/apps/chance_test/theme.js +27 -0
  137. data/spec/fixtures/builder_tests/apps/module_test/module.js +1 -0
  138. data/spec/fixtures/builder_tests/apps/module_test/modules/deferred_module/english.lproj/req_style_2.css +0 -0
  139. data/spec/fixtures/builder_tests/apps/module_test/modules/deferred_module/english.lproj/test.rhtml +1 -0
  140. data/spec/fixtures/builder_tests/apps/module_test/modules/deferred_module/javascript.js +1 -0
  141. data/spec/fixtures/builder_tests/apps/module_test/modules/deferred_module/lib/alt_layout.rhtml +0 -0
  142. data/spec/fixtures/builder_tests/apps/module_test/modules/deferred_module/req_js_2.js +0 -0
  143. data/spec/fixtures/builder_tests/apps/module_test/modules/dynamic_req_target_1/dynamic_req_js_1.js +0 -0
  144. data/spec/fixtures/builder_tests/apps/module_test/modules/dynamic_req_target_1/english.lproj/dynamic_req_style_1.css +0 -0
  145. data/spec/fixtures/builder_tests/apps/module_test/modules/inlined_module/README +0 -0
  146. data/spec/fixtures/builder_tests/apps/module_test/modules/required_target/english.lproj/req_style_1.css +0 -0
  147. data/spec/fixtures/builder_tests/apps/module_test/modules/required_target/english.lproj/strings.js +4 -0
  148. data/spec/fixtures/builder_tests/apps/module_test/modules/required_target/english.lproj/test.rhtml +1 -0
  149. data/spec/fixtures/builder_tests/apps/module_test/modules/required_target/req_js_1.js +0 -0
  150. data/spec/fixtures/helper_tests/apps/minifier_test/core.js +8 -0
  151. data/spec/fixtures/real_world/Buildfile +11 -1
  152. data/spec/fixtures/real_world/apps/account/modules/preferences/README +0 -0
  153. data/spec/fixtures/real_world/apps/calendar/modules/preferences/README +0 -0
  154. data/spec/fixtures/real_world/apps/contacts/modules/preferences/README +0 -0
  155. data/spec/fixtures/real_world/apps/contacts/modules/printing/README +0 -0
  156. data/spec/fixtures/real_world/apps/mail/modules/preferences/README +0 -0
  157. data/spec/fixtures/real_world/apps/mail/modules/printing/README +0 -0
  158. data/spec/fixtures/real_world/apps/photos/modules/email/README +0 -0
  159. data/spec/fixtures/real_world/apps/photos/modules/preferences/README +0 -0
  160. data/spec/lib/builders/chance_file_spec.rb +63 -0
  161. data/spec/lib/builders/chance_spec.rb +81 -0
  162. data/spec/lib/builders/module_spec.rb +133 -0
  163. data/spec/lib/helpers/minifier.rb +31 -0
  164. data/spec/lib/models/project/find_targets_for_spec.rb +1 -1
  165. data/vendor/chance/lib/chance/imagers/data_url.rb +68 -17
  166. data/vendor/chance/lib/chance/instance.rb +55 -30
  167. data/vendor/chance/lib/chance/parser.rb +1 -1
  168. data/vendor/chance/lib/chance/slicing.rb +39 -3
  169. metadata +52 -7
  170. data/lib/frameworks/sproutcore/frameworks/foundation/system/logger.js +0 -163
  171. data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/logger.js +0 -44
  172. data/spec/buildtasks/manifest/prepare_build_tasks/bundle_spec.rb +0 -254
  173. data/spec/fixtures/builder_tests/apps/bundle_test/bundle.js +0 -1
  174. data/spec/lib/builders/bundle_spec.rb +0 -295
@@ -32,6 +32,14 @@ SC.FieldView = SC.View.extend(SC.Control, SC.Validatable,
32
32
  */
33
33
  isTextArea: NO,
34
34
 
35
+ /**
36
+ The WAI-ARIA role for field view. This property's value should not be
37
+ changed.
38
+
39
+ @property {String}
40
+ */
41
+ ariaRole: 'textbox',
42
+
35
43
  _field_isMouseDown: NO,
36
44
 
37
45
  /**
@@ -312,7 +320,18 @@ SC.FieldView = SC.View.extend(SC.Control, SC.Validatable,
312
320
  var ret = this.getFieldValue() ;
313
321
  if (this.objectForFieldValue) ret = this.objectForFieldValue(ret);
314
322
  return ret ;
323
+ },
324
+
325
+ render: function(context, firstTime) {
326
+ sc_super();
327
+
328
+ //addressing accessibility
329
+ if(firstTime) {
330
+ context.attr('aria-multiline', this.get('isTextArea'));
331
+ context.attr('aria-disabled', !this.get('isEnabled'));
332
+ }
315
333
  }
334
+
316
335
 
317
336
  });
318
337
 
@@ -48,6 +48,8 @@ SC.ImageView = SC.View.extend(SC.Control, SC.InnerFrame,
48
48
  /** @scope SC.ImageView.prototype */ {
49
49
 
50
50
  classNames: 'sc-image-view',
51
+
52
+ ariaRole: 'img',
51
53
 
52
54
  displayProperties: 'frame image imageValue innerFrame status toolTip type'.w(),
53
55
 
@@ -32,7 +32,15 @@ SC.LabelView = SC.View.extend(SC.Control, SC.InlineEditorDelegate, SC.InlineEdit
32
32
 
33
33
  displayProperties: 'displayTitle textAlign fontWeight icon escapeHTML needsEllipsis hint'.w(),
34
34
 
35
+ /**
36
+ The WAI-ARIA attribute for the label view. This property is assigned to
37
+ 'aria-labelledby' attribute, which defines a string value that labels the
38
+ element. Used to support voiceover. It should be assigned a non-empty string,
39
+ if the 'aria-labelledby' attribute has to be set for the element.
35
40
 
41
+ @property {String}
42
+ */
43
+ ariaLabeledBy: null,
36
44
 
37
45
  isEditable: NO,
38
46
 
@@ -63,16 +71,14 @@ SC.LabelView = SC.View.extend(SC.Control, SC.InlineEditorDelegate, SC.InlineEdit
63
71
  This is a default value that can be overridden by the
64
72
  settings on the owner view.
65
73
  */
66
- escapeHTML: true,
74
+ escapeHTML: YES,
67
75
  escapeHTMLBindingDefault: SC.Binding.oneWay().bool(),
68
76
 
69
77
  /**
70
78
  If true, then the value will be localized.
71
-
72
- This is a default default that can be overidden by the
73
- settings in the owner view.
79
+ This is a default that can be overidden by the settings in the owner view.
74
80
  */
75
- localize: false,
81
+ localize: NO,
76
82
  localizeBindingDefault: SC.Binding.oneWay().bool(),
77
83
 
78
84
  /**
@@ -27,14 +27,32 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
27
27
  classNames: ['sc-text-field-view'],
28
28
  isTextField: YES,
29
29
 
30
+ /**
31
+ The WAI-ARIA role for text field view. This property's value should not be
32
+ changed.
33
+
34
+ @property {String}
35
+ */
36
+ ariaRole: 'textbox',
37
+
30
38
  // ..........................................................
31
39
  // PROPERTIES
32
40
  //
33
41
 
42
+ /**
43
+ When applyImmediately is turned on, every keystroke will set the value
44
+ of the underlying object. Turning it off will only set the value on blur.
45
+
46
+ @property
47
+ @type String
48
+ */
34
49
  applyImmediately: YES,
35
50
 
36
51
  /**
37
52
  If YES, the field will hide its text from display. The default value is NO.
53
+
54
+ @property
55
+ @type Boolean
38
56
  */
39
57
  isPassword: NO,
40
58
 
@@ -42,29 +60,56 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
42
60
  If YES then allow multi-line input. This will also change the default
43
61
  tag type from "input" to "textarea". Otherwise, pressing return will
44
62
  trigger the default insertion handler.
63
+
64
+ @property
65
+ @type Boolean
45
66
  */
46
67
  isTextArea: NO,
47
68
 
48
69
  /**
49
- The hint to display while the field is not active. Can be a loc key.
70
+ The hint to display while the field is not active.
71
+
72
+ @property
73
+ @type String
50
74
  */
51
75
  hint: '',
52
76
 
77
+ /*
78
+ * Localizes the hint if necessary.
79
+ */
80
+ formattedHint: function() {
81
+ var hint = this.get('hint');
82
+
83
+ return this.get('localize') ? hint.loc() : hint;
84
+ }.property('hint', 'localize').cacheable(),
85
+
86
+ /*
87
+ * Whether the hint should be localized or not.
88
+ */
89
+ localize: YES,
90
+
53
91
  /**
54
92
  If YES then the text field is currently editing.
93
+
94
+ @property
95
+ @type Boolean
55
96
  */
56
97
  isEditing: NO,
57
98
 
58
- hintON:YES,
59
-
60
99
  /**
61
100
  If you set this property to false the tab key won't trigger its default
62
101
  behavior (tabbing to the next field).
102
+
103
+ @property
104
+ @type Boolean
63
105
  */
64
- defaultTabbingEnabled:YES,
106
+ defaultTabbingEnabled: YES,
65
107
 
66
108
  /**
67
109
  Enabled context menu for textfields.
110
+
111
+ @property
112
+ @type Boolean
68
113
  */
69
114
  isContextMenuEnabled: YES,
70
115
 
@@ -73,6 +118,9 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
73
118
  If false, 'value' is only updated when commitEditing() is called (this
74
119
  is called automatically when the text field loses focus), or whenever
75
120
  the return key is pressed while editing the field.
121
+
122
+ @property
123
+ @type Boolean
76
124
  */
77
125
  continuouslyUpdatesValue: YES,
78
126
 
@@ -80,6 +128,9 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
80
128
  If no, will not allow transform or validation errors (SC.Error objects)
81
129
  to be passed to 'value'. Upon focus lost, the text field will revert
82
130
  to its previous value.
131
+
132
+ @property
133
+ @type Boolean
83
134
  */
84
135
  allowsErrorAsValue: YES,
85
136
 
@@ -102,6 +153,9 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
102
153
  defined on the "padding" element. If you would like to customize the
103
154
  amount of left padding used when the accessory view is visible, make the
104
155
  accessory view wider, with empty space on the right.
156
+
157
+ @property
158
+ @type SC.View
105
159
  */
106
160
  leftAccessoryView: null,
107
161
 
@@ -125,26 +179,45 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
125
179
  defined on the "padding" element. If you would like to customize the
126
180
  amount of right padding used when the accessory view is visible, make the
127
181
  accessory view wider, with empty space on the left.
182
+
183
+ @property
184
+ @type SC.View
128
185
  */
129
186
  rightAccessoryView: null,
130
187
 
131
-
132
188
  /**
133
189
  This property will enable disable HTML5 spell checking if available on the
134
- browser. As of today Safari 4+, Chrome 3+ and Firefox 3+ support it
135
- */
190
+ browser. As of today Safari 4+, Chrome 3+ and Firefox 3+ support it
136
191
 
192
+ @property
193
+ @type Boolean
194
+ */
137
195
  spellCheckEnabled: YES,
138
196
 
197
+ /**
198
+ Maximum amount of characters this field will allow.
199
+
200
+ @property
201
+ @type Number
202
+ */
139
203
  maxLength: 5096,
140
204
 
205
+ /**
206
+ Whether to render a border or not.
207
+
208
+ @property
209
+ @type Boolean
210
+ */
211
+ shouldRenderBorder: YES,
141
212
 
142
- _isFocused: NO,
143
-
213
+ /** @private
214
+ Whether to show hint or not
215
+ */
216
+ _hintON: YES,
144
217
 
145
218
  init: function() {
146
219
  var val = this.get('value');
147
- this.set('hintON', (!val || val && val.length === 0));
220
+ this._hintON = (!val || val && val.length===0) ? YES : NO;
148
221
  return sc_super();
149
222
  },
150
223
 
@@ -179,7 +252,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
179
252
  }
180
253
  else {
181
254
  // In IE8, input elements don't have hasOwnProperty() defined.
182
- try{
255
+ try {
183
256
  if ('selectionStart' in element) {
184
257
  start = element.selectionStart ;
185
258
  }
@@ -264,7 +337,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
264
337
  // INTERNAL SUPPORT
265
338
  //
266
339
 
267
- displayProperties: 'hint fieldValue isEditing leftAccessoryView rightAccessoryView isTextArea'.w(),
340
+ displayProperties: 'formattedHint fieldValue isEditing leftAccessoryView rightAccessoryView isTextArea'.w(),
268
341
 
269
342
  createChildViews: function() {
270
343
  sc_super();
@@ -369,6 +442,15 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
369
442
  // update layer classes always
370
443
  context.setClass('not-empty', v.length > 0);
371
444
 
445
+ //addressing accessibility
446
+ if(firstTime) {
447
+ context.attr('aria-multiline', this.get('isTextArea'));
448
+ context.attr('aria-disabled', !this.get('isEnabled'));
449
+ }
450
+ if(!SC.ok(this.get('value'))) {
451
+ context.attr('aria-invalid', YES);
452
+ }
453
+
372
454
  // If we have accessory views, we'll want to update the padding on the
373
455
  // hint to compensate for the width of the accessory view. (It'd be nice
374
456
  // if we could add in the original padding, too, but there's no efficient
@@ -385,29 +467,29 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
385
467
  if(SC.browser.mozilla) this.invokeLast(this._applyFirefoxCursorFix);
386
468
  },
387
469
 
388
- /**
470
+ /** @private
389
471
  If isTextArea is changed (this might happen in inlineeditor constantly)
390
472
  force the field render to render like the firsttime to avoid writing extra
391
473
  code. This can be useful also
392
474
  */
393
475
  _forceRenderFirstTime: NO,
394
-
476
+
477
+ /** @private */
395
478
  _renderFieldLikeFirstTime: function(){
396
479
  this.set('_forceRenderFirstTime', YES);
397
480
  }.observes('isTextArea'),
398
481
 
399
- shouldRenderBorder: YES,
400
-
482
+ /** @private */
401
483
  _renderField: function(context, firstTime, value, leftAdjustment, rightAdjustment) {
402
484
  // TODO: The cleanest thing might be to create a sub- rendering context
403
485
  // here, but currently SC.RenderContext will render sibling
404
486
  // contexts as parent/child.
405
487
 
406
- var hint = this.get('hint'), disabled, name, adjustmentStyle, type,
488
+ var hint = this.get('formattedHint'), disabled, name, adjustmentStyle, type,
407
489
  hintElements, element, paddingElementStyle, fieldClassNames,
408
490
  spellCheckEnabled=this.get('spellCheckEnabled'), spellCheckString,
409
491
  maxLength = this.get('maxLength'), isOldSafari;
410
-
492
+
411
493
  context.setClass('text-area', this.get('isTextArea'));
412
494
 
413
495
  //Adding this to differentiate between older and newer versions of safari
@@ -434,9 +516,9 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
434
516
  }
435
517
  context.push('<span class="padding" '+adjustmentStyle+'>');
436
518
 
437
- value = this.get('escapeHTML')?SC.RenderContext.escapeHTML(value):value;
519
+ value = this.get('escapeHTML') ? SC.RenderContext.escapeHTML(value) : value;
438
520
  if(!this.get('_supportsPlaceHolder') && (!value || (value && value.length===0))) {
439
- value = this.get('hint');
521
+ value = hint;
440
522
  context.setClass('sc-hint', YES);
441
523
  }
442
524
 
@@ -468,12 +550,11 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
468
550
  if(!this.get('_supportsPlaceHolder')){
469
551
  var val = this.get('value');
470
552
  if((!val || (val && val.length===0))){
471
- if(this.get('hintON') && !this.get('isFirstResponder')){
472
- //console.log('hint on render');
553
+ if(this._hintON && !this.get('isFirstResponder')){
473
554
  context.setClass('sc-hint', YES);
474
555
  input.val(hint);
475
- }else{
476
- // console.log('removing hint on render');
556
+ }
557
+ else {
477
558
  context.setClass('sc-hint', NO);
478
559
  input.val('');
479
560
  }
@@ -560,11 +641,10 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
560
641
  // For some strange reason if we add focus/blur events to textarea
561
642
  // inmediately they won't work. However if I add them at the end of the
562
643
  // runLoop it works fine.
563
- if(!this.get('_supportsPlaceHolder') && this.get('hintON')){
644
+ if(!this.get('_supportsPlaceHolder') && this._hintON){
564
645
  var currentValue = this.$input().val();
565
646
  if(!currentValue || (currentValue && currentValue.length===0)){
566
- // console.log('hint on didcreatelayer');
567
- this.$input().val(this.get('hint'));
647
+ this.$input().val(this.get('formattedHint'));
568
648
  }
569
649
  }
570
650
  if(this.get('isTextArea')) {
@@ -611,14 +691,13 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
611
691
  }
612
692
  },
613
693
 
614
-
615
694
  /**
616
695
  Removes all the events attached to the textfield
617
696
  */
618
697
 
619
698
  willDestroyLayer: function() {
620
699
  sc_super();
621
-
700
+
622
701
  var input = this.$input();
623
702
  SC.Event.remove(input, 'focus', this, this._textField_fieldDidFocus);
624
703
  SC.Event.remove(input, 'blur', this, this._textField_fieldDidBlur);
@@ -626,26 +705,23 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
626
705
  SC.Event.remove(input, 'keypress', this, this._firefox_dispatch_keypress);
627
706
  },
628
707
 
629
- /**
708
+ /** @private
630
709
  This function is called by the event when the textfield gets focus
631
710
  */
632
-
633
711
  _textField_fieldDidFocus: function(evt) {
634
712
  SC.run(function() {
635
713
  this.set('focused',YES);
636
714
  this.fieldDidFocus(evt);
637
715
  var val = this.get('value');
638
- if(!this.get('_supportsPlaceHolder') && ((!val) || (val && val.length===0))){
639
- // console.log('turn off hint');
640
- this.set('hintON', NO);
716
+ if(!this.get('_supportsPlaceHolder') && ((!val) || (val && val.length===0))) {
717
+ this._hintON = NO;
641
718
  }
642
719
  }, this);
643
720
  },
644
-
645
- /**
721
+
722
+ /** @private
646
723
  This function is called by the event when the textfield blurs
647
724
  */
648
-
649
725
  _textField_fieldDidBlur: function(evt) {
650
726
  SC.run(function() {
651
727
  this.set('focused',NO);
@@ -654,9 +730,8 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
654
730
  // use it for the delegate to end editing
655
731
  this.fieldDidBlur(this._origEvent);
656
732
  var val = this.get('value');
657
- if(!this.get('_supportsPlaceHolder') && ((!val) || (val && val.length===0))){
658
- // console.log('turn on hint');
659
- this.set('hintON', YES);
733
+ if(!this.get('_supportsPlaceHolder') && ((!val) || (val && val.length===0))) {
734
+ this._hintON = YES;
660
735
  }
661
736
  }, this);
662
737
  },
@@ -701,13 +776,12 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
701
776
  }
702
777
  },
703
778
 
704
- /**
779
+ /** @private
705
780
  Move magic number out so it can be over-written later in inline editor
706
781
  */
707
782
  _topOffsetForFirefoxCursorFix: 3,
708
-
709
-
710
- /**
783
+
784
+ /** @private
711
785
  Mozilla had this bug until firefox 3.5 or gecko 1.8 They rewrote input text
712
786
  and textareas and now they work better. But we have to keep this for older
713
787
  versions.
@@ -758,7 +832,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
758
832
  },
759
833
 
760
834
 
761
- /**
835
+ /** @private
762
836
  In Firefox, as of 3.6 -- including 3.0 and 3.5 -- for input fields only
763
837
  (that is, not textarea elements), if the cursor is at the end of the
764
838
  field, the "down" key will not result in a "keypress" event for the
@@ -780,7 +854,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
780
854
  }
781
855
  },
782
856
 
783
-
857
+ /** @private */
784
858
  _textField_selectionDidChange: function() {
785
859
  this.notifyPropertyChange('selection');
786
860
  },
@@ -791,9 +865,10 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
791
865
  // When we become first responder, make sure the field gets focus and
792
866
  // the hint value is hidden if needed.
793
867
 
794
- // when we become first responder, focus the text field if needed and
795
- // hide the hint text.
796
- /** @private */
868
+ /** @private
869
+ When we become first responder, focus the text field if needed and
870
+ hide the hint text.
871
+ */
797
872
  willBecomeKeyResponderFrom: function(keyView) {
798
873
  if(this.get('isVisibleInWindow')) {
799
874
  var inp = this.$input()[0];
@@ -807,23 +882,22 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
807
882
  }
808
883
  },
809
884
 
810
- willLoseKeyResponderTo: function(responder) {
811
- //if (this._isFocused) this._isFocused = NO ;
812
- },
813
-
814
- // In IE, you can't modify functions on DOM elements so we need to wrap the
815
- // call to select() like this.
885
+ /** @private
886
+ In IE, you can't modify functions on DOM elements so we need to wrap the
887
+ call to select() like this.
888
+ */
816
889
  _selectRootElement: function() {
817
- // make sure input element still exists, as a redraw could have remove it
818
- // already
819
890
  var inputElem = this.$input()[0];
891
+ // Make sure input element still exists, as a redraw could have remove it
892
+ // already.
820
893
  if(inputElem) inputElem.select() ;
821
894
  else this._textField_selectionDidChange();
822
895
  },
823
-
824
- // when we lose first responder, blur the text field if needed and show
825
- // the hint text if needed.
826
- /** @private */
896
+
897
+ /** @private
898
+ When we lose first responder, blur the text field if needed and show
899
+ the hint text if needed.
900
+ */
827
901
  didLoseKeyResponderTo: function(keyView) {
828
902
  var el = this.$input()[0];
829
903
  if (el) el.blur();
@@ -831,8 +905,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
831
905
  this.invokeLater("scrollToOriginIfNeeded", 100);
832
906
  },
833
907
 
834
- /**
835
- @private
908
+ /** @private
836
909
  Scrolls to origin if necessary (if the pane's current firstResponder is not a text field).
837
910
  */
838
911
  scrollToOriginIfNeeded: function() {
@@ -844,7 +917,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
844
917
  document.body.scrollTop = document.body.scrollLeft = 0;
845
918
  }
846
919
  },
847
-
920
+
848
921
  parentViewDidResize: function() {
849
922
  if (SC.browser.mozilla) {
850
923
  this.invokeLast(this._applyFirefoxCursorFix);
@@ -852,7 +925,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
852
925
  sc_super();
853
926
  },
854
927
 
855
- /** @private
928
+ /**
856
929
  Simply allow keyDown & keyUp to pass through to the default web browser
857
930
  implementation.
858
931
  */
@@ -883,7 +956,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
883
956
 
884
957
  // handle tab key
885
958
  if ((which === 9 || evt.keyCode===9) && this.get('defaultTabbingEnabled')) {
886
- var view = evt.shiftKey ? this.get('previousValidKeyView') : this.get('nextValidKeyView');
959
+ view = evt.shiftKey ? this.get('previousValidKeyView') : this.get('nextValidKeyView');
887
960
  if (view) view.becomeFirstResponder();
888
961
  else evt.allowDefault();
889
962
  return YES ; // handled
@@ -917,7 +990,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
917
990
  }
918
991
  return YES;
919
992
  },
920
-
993
+
921
994
  keyUp: function(evt) {
922
995
  if(SC.browser.mozilla && evt.keyCode===13) this.fieldValueDidChange();
923
996
  // The caret/selection could have moved. In some browsers, though, the
@@ -928,7 +1001,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
928
1001
  evt.allowDefault();
929
1002
  return YES;
930
1003
  },
931
-
1004
+
932
1005
  mouseDown: function(evt) {
933
1006
  var fieldValue = this.get('fieldValue'); // use 'fieldValue' since we want actual text
934
1007
  this._txtFieldMouseDown=YES;
@@ -972,24 +1045,29 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
972
1045
  return YES;
973
1046
  },
974
1047
 
975
- /**
1048
+ /** @private
976
1049
  This function is to notify if the browser supports the placeholder attribute
977
1050
  or not. Currently is disabled as in webkit there is a bug where the color
978
1051
  of the placeholder doesn't refresh all the time.
979
1052
  */
980
1053
  _supportsPlaceHolder: SC.platform.input.placeholder,
981
1054
 
982
-
983
- valueObserver: function(){
984
- // console.log('value observer');
1055
+ /** @private
1056
+ This observer makes sure to hide the hint when a value is entered, or
1057
+ show it if it becomes empty.
1058
+ */
1059
+ _valueObserver: function() {
985
1060
  var val = this.get('value'), max;
986
1061
  if (val && val.length>0) {
987
- this.set('hintON', NO);
1062
+ this._hintON = NO;
988
1063
  max = this.get('maxLength');
989
1064
  if(!SC.browser.webkit && val.length>max){
990
1065
  this.set('value', val.substr(0, max));
991
1066
  }
992
- }else this.set('hintON', YES);
1067
+ }
1068
+ else {
1069
+ this._hintON = YES;
1070
+ }
993
1071
  }.observes('value')
994
1072
 
995
1073
  });