sproutcore 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +233 -0
- data/Manifest.txt +67 -34
- data/bin/sc-build +12 -1
- data/bin/sc-gen +1 -1
- data/bin/sproutcore +14 -0
- data/clients/sc_docs/controllers/docs.js +38 -8
- data/clients/sc_docs/english.lproj/body.css +80 -127
- data/clients/sc_docs/english.lproj/body.rhtml +43 -23
- data/clients/sc_docs/english.lproj/no_docs.rhtml +2 -1
- data/clients/sc_docs/english.lproj/tabs.rhtml +16 -0
- data/clients/sc_docs/main.js +14 -9
- data/clients/sc_docs/models/doc.js +1 -1
- data/clients/sc_docs/tests/controllers/docs.rhtml +1 -2
- data/clients/sc_docs/tests/models/doc.rhtml +1 -2
- data/clients/sc_docs/tests/views/doc_frame.rhtml +1 -2
- data/clients/sc_docs/tests/views/doc_label_view.rhtml +1 -2
- data/clients/sc_docs/views/doc_frame.js +1 -1
- data/clients/sc_test_runner/controllers/runner.js +31 -8
- data/clients/sc_test_runner/english.lproj/body.css +62 -122
- data/clients/sc_test_runner/english.lproj/body.rhtml +62 -26
- data/clients/sc_test_runner/main.js +1 -6
- data/clients/sc_test_runner/models/test.js +14 -1
- data/clients/sc_test_runner/views/runner_frame.js +4 -2
- data/clients/view_builder/builders/builder.js +339 -0
- data/clients/view_builder/builders/button.js +81 -0
- data/clients/view_builder/controllers/document.js +21 -0
- data/clients/view_builder/core.js +19 -0
- data/clients/view_builder/english.lproj/body.css +77 -0
- data/clients/view_builder/english.lproj/body.rhtml +41 -0
- data/clients/{sc_docs → view_builder}/english.lproj/controls.css +0 -0
- data/clients/view_builder/english.lproj/strings.js +14 -0
- data/clients/view_builder/main.js +38 -0
- data/clients/view_builder/tests/controllers/document.rhtml +20 -0
- data/clients/view_builder/tests/views/builder.rhtml +20 -0
- data/clients/view_builder/views/builder.js +23 -0
- data/frameworks/prototype/prototype.js +1 -1
- data/frameworks/sproutcore/Core.js +32 -7
- data/frameworks/sproutcore/README +1 -1
- data/frameworks/sproutcore/animation/animation.js +411 -0
- data/frameworks/sproutcore/controllers/array.js +17 -9
- data/frameworks/sproutcore/controllers/collection.js +9 -110
- data/frameworks/sproutcore/controllers/controller.js +1 -1
- data/frameworks/sproutcore/controllers/object.js +2 -1
- data/frameworks/sproutcore/drag/drag.js +267 -56
- data/frameworks/sproutcore/drag/drag_data_source.js +24 -16
- data/frameworks/sproutcore/drag/drag_source.js +53 -42
- data/frameworks/sproutcore/drag/drop_target.js +2 -2
- data/frameworks/sproutcore/english.lproj/buttons.css +337 -236
- data/frameworks/sproutcore/english.lproj/core.css +115 -0
- data/frameworks/sproutcore/english.lproj/icons.css +227 -0
- data/{clients/sc_docs → frameworks/sproutcore}/english.lproj/images/indicator.gif +0 -0
- data/frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png +0 -0
- data/frameworks/sproutcore/english.lproj/images/sc-theme-ysprite.png +0 -0
- data/frameworks/sproutcore/english.lproj/images/shared-icons.png +0 -0
- data/frameworks/sproutcore/english.lproj/menu.css +1 -1
- data/frameworks/sproutcore/english.lproj/strings.js +1 -1
- data/frameworks/sproutcore/english.lproj/theme.css +405 -31
- data/frameworks/sproutcore/foundation/application.js +15 -11
- data/frameworks/sproutcore/foundation/benchmark.js +1 -1
- data/frameworks/sproutcore/foundation/binding.js +2 -2
- data/frameworks/sproutcore/foundation/date.js +1 -1
- data/frameworks/sproutcore/foundation/error.js +1 -1
- data/frameworks/sproutcore/foundation/input_manager.js +32 -21
- data/frameworks/sproutcore/foundation/mock.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +9 -6
- data/frameworks/sproutcore/foundation/object.js +249 -177
- data/frameworks/sproutcore/foundation/page.js +5 -2
- data/frameworks/sproutcore/foundation/path_module.js +11 -10
- data/frameworks/sproutcore/foundation/responder.js +5 -2
- data/frameworks/sproutcore/foundation/routes.js +17 -13
- data/frameworks/sproutcore/foundation/run_loop.js +249 -11
- data/frameworks/sproutcore/foundation/server.js +1 -1
- data/frameworks/sproutcore/foundation/set.js +3 -3
- data/frameworks/sproutcore/foundation/string.js +5 -3
- data/frameworks/sproutcore/foundation/timer.js +371 -0
- data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
- data/frameworks/sproutcore/foundation/unittest.js +3 -3
- data/frameworks/sproutcore/foundation/utils.js +161 -2
- data/frameworks/sproutcore/globals/panels.js +1 -1
- data/frameworks/sproutcore/globals/popups.js +4 -3
- data/frameworks/sproutcore/globals/window.js +44 -4
- data/frameworks/sproutcore/lib/button_views.rb +328 -0
- data/frameworks/sproutcore/lib/collection_view.rb +80 -0
- data/frameworks/sproutcore/lib/core_views.rb +281 -0
- data/frameworks/sproutcore/lib/form_views.rb +253 -0
- data/frameworks/sproutcore/lib/index.rhtml +2 -0
- data/frameworks/sproutcore/lib/menu_views.rb +88 -0
- data/frameworks/sproutcore/{foundation → mixins}/array.js +60 -29
- data/frameworks/sproutcore/mixins/control.js +265 -0
- data/frameworks/sproutcore/mixins/delegate_support.js +66 -0
- data/frameworks/sproutcore/{foundation → mixins}/observable.js +176 -6
- data/frameworks/sproutcore/mixins/scrollable.js +245 -0
- data/frameworks/sproutcore/mixins/selection_support.js +148 -0
- data/frameworks/sproutcore/mixins/validatable.js +152 -0
- data/frameworks/sproutcore/models/collection.js +5 -5
- data/frameworks/sproutcore/models/record.js +1 -1
- data/frameworks/sproutcore/models/store.js +1 -1
- data/frameworks/sproutcore/panes/dialog.js +1 -1
- data/frameworks/sproutcore/panes/manager.js +1 -1
- data/frameworks/sproutcore/panes/menu.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +2 -2
- data/frameworks/sproutcore/panes/panel.js +1 -1
- data/frameworks/sproutcore/panes/picker.js +1 -1
- data/frameworks/sproutcore/tests/controllers/array.rhtml +44 -4
- data/frameworks/sproutcore/tests/foundation/timer/invalidate.rhtml +33 -0
- data/frameworks/sproutcore/tests/foundation/timer/invokeLater.rhtml +145 -0
- data/frameworks/sproutcore/tests/foundation/timer/isPaused.rhtml +70 -0
- data/frameworks/sproutcore/tests/foundation/timer/schedule.rhtml +145 -0
- data/frameworks/sproutcore/tests/views/{scroll.rhtml → checkbox.rhtml} +3 -3
- data/frameworks/sproutcore/tests/views/{collection.rhtml → collection/base.rhtml} +33 -32
- data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +260 -0
- data/frameworks/sproutcore/tests/views/image_cell.rhtml +19 -0
- data/frameworks/sproutcore/tests/views/label_item.rhtml +2 -4
- data/frameworks/sproutcore/tests/views/list.rhtml +2 -3
- data/frameworks/sproutcore/tests/views/list_item.rhtml +20 -0
- data/frameworks/sproutcore/tests/views/slider.rhtml +20 -0
- data/frameworks/sproutcore/tests/views/text_cell.rhtml +19 -0
- data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +395 -0
- data/frameworks/sproutcore/tests/views/view/frame.rhtml +353 -0
- data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +347 -0
- data/frameworks/sproutcore/tests/views/view/isVisibleInWindow.rhtml +148 -0
- data/frameworks/sproutcore/tests/views/view/scrollFrame.rhtml +468 -0
- data/frameworks/sproutcore/validators/credit_card.js +33 -13
- data/frameworks/sproutcore/validators/date.js +26 -6
- data/frameworks/sproutcore/validators/email.js +21 -3
- data/frameworks/sproutcore/validators/not_empty.js +11 -1
- data/frameworks/sproutcore/validators/number.js +18 -4
- data/frameworks/sproutcore/validators/password.js +12 -1
- data/frameworks/sproutcore/validators/validator.js +204 -194
- data/frameworks/sproutcore/views/{button.js → button/button.js} +96 -94
- data/frameworks/sproutcore/views/button/checkbox.js +29 -0
- data/frameworks/sproutcore/views/button/disclosure.js +42 -0
- data/frameworks/sproutcore/views/button/radio.js +29 -0
- data/frameworks/sproutcore/views/{collection.js → collection/collection.js} +1373 -1024
- data/frameworks/sproutcore/views/collection/grid.js +124 -46
- data/frameworks/sproutcore/views/collection/image_cell.js +17 -46
- data/frameworks/sproutcore/views/collection/list.js +45 -35
- data/frameworks/sproutcore/views/collection/source_list.js +386 -0
- data/frameworks/sproutcore/views/collection/table.js +118 -0
- data/frameworks/sproutcore/views/container.js +7 -2
- data/frameworks/sproutcore/views/error_explanation.js +23 -10
- data/frameworks/sproutcore/views/{checkbox_field.js → field/checkbox_field.js} +16 -6
- data/frameworks/sproutcore/views/field/field.js +219 -0
- data/frameworks/sproutcore/views/{radio_field.js → field/radio_field.js} +27 -12
- data/frameworks/sproutcore/views/{select_field.js → field/select_field.js} +116 -90
- data/frameworks/sproutcore/views/{text_field.js → field/text_field.js} +57 -8
- data/frameworks/sproutcore/views/{textarea_field.js → field/textarea_field.js} +13 -3
- data/frameworks/sproutcore/views/filter_button.js +2 -2
- data/frameworks/sproutcore/views/form.js +3 -3
- data/frameworks/sproutcore/views/image.js +128 -21
- data/frameworks/sproutcore/views/inline_text_editor.js +1 -1
- data/frameworks/sproutcore/views/label.js +149 -92
- data/frameworks/sproutcore/views/list_item.js +225 -0
- data/frameworks/sproutcore/views/menu_item.js +10 -4
- data/frameworks/sproutcore/views/pagination.js +11 -4
- data/frameworks/sproutcore/views/popup_button.js +25 -21
- data/frameworks/sproutcore/views/popup_menu.js +10 -4
- data/frameworks/sproutcore/views/progress.js +29 -16
- data/frameworks/sproutcore/views/radio_group.js +1 -1
- data/frameworks/sproutcore/views/scroll.js +60 -20
- data/frameworks/sproutcore/views/segmented.js +1 -1
- data/frameworks/sproutcore/views/slider.js +132 -0
- data/frameworks/sproutcore/views/source_list_group.js +130 -0
- data/frameworks/sproutcore/views/spinner.js +1 -1
- data/frameworks/sproutcore/views/split.js +292 -0
- data/frameworks/sproutcore/views/split_divider.js +109 -0
- data/frameworks/sproutcore/views/tab.js +1 -1
- data/frameworks/sproutcore/views/toolbar.js +1 -1
- data/frameworks/sproutcore/views/view.js +1272 -591
- data/generators/client/templates/english.lproj/body.css +1 -1
- data/generators/controller/controller_generator.rb +1 -1
- data/generators/controller/templates/test.rhtml +2 -1
- data/generators/model/templates/test.rhtml +1 -1
- data/generators/test/templates/test.rhtml +1 -1
- data/generators/view/templates/test.rhtml +1 -1
- data/jsdoc/templates/sproutcore/class.tmpl +241 -338
- data/jsdoc/templates/sproutcore/default.css +105 -155
- data/jsdoc/templates/sproutcore/index.tmpl +43 -8
- data/jsdoc/templates/sproutcore/publish.js +9 -4
- data/lib/sproutcore/build_tools/html_builder.rb +29 -13
- data/lib/sproutcore/build_tools/resource_builder.rb +1 -1
- data/lib/sproutcore/bundle.rb +86 -25
- data/lib/sproutcore/jsdoc.rb +2 -0
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore/view_helpers.rb +36 -3
- data/tasks/deployment.rake +1 -1
- metadata +69 -36
- data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
- data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_docs/english.lproj/warning.rhtml +0 -6
- data/clients/sc_test_runner/english.lproj/warning.rhtml +0 -6
- data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
- data/frameworks/sproutcore/english.lproj/collections.css +0 -82
- data/frameworks/sproutcore/english.lproj/images/buttons-sprite.png +0 -0
- data/frameworks/sproutcore/views/collection/collection_item.js +0 -36
- data/frameworks/sproutcore/views/collection/text_cell.js +0 -128
- data/frameworks/sproutcore/views/field.js +0 -214
- data/frameworks/sproutcore/views/workspace.js +0 -170
- data/generators/client/templates/english.lproj/controls.css +0 -0
- data/generators/framework/templates/english.lproj/body.css +0 -0
- data/generators/framework/templates/english.lproj/body.rhtml +0 -3
- data/generators/framework/templates/english.lproj/controls.css +0 -0
- data/lib/sproutcore/view_helpers/button_views.rb +0 -302
- data/lib/sproutcore/view_helpers/core_views.rb +0 -292
- data/lib/sproutcore/view_helpers/form_views.rb +0 -258
- data/lib/sproutcore/view_helpers/menu_views.rb +0 -94
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<% view :warning_panel, :panel => true, :width => 400 do %>
|
|
2
|
-
<h1>Client Name Required</h1>
|
|
3
|
-
<p style="font-size: 15px;">To access documents for a client, add the client name at the end of the URL preceded by a hash (#). For example, to access the docs for the "contacts" client enter:</p>
|
|
4
|
-
<p style="font-size: 15px; text-align: center;"><%= label_view :outlet => true, :tag => 'span', :bind => { :content => 'Docs.docsController.windowLocation' } %><b>#contacts</b></p>
|
|
5
|
-
</div>
|
|
6
|
-
<% end %>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<% view :warning_panel, :panel => true, :width => 400 do %>
|
|
2
|
-
<h1>Client Name Required</h1>
|
|
3
|
-
<p style="font-size: 15px;">To test a client, add the client name at the end of the URL preceded by a hash (#). For example, to run unit tests for the "contacts" client enter:</p>
|
|
4
|
-
<p style="font-size: 15px; text-align: center;"><%= label_view :outlet => true, :tag => 'span', :bind => { :content => 'TestRunner.runnerController.windowLocation' } %><b>#contacts</b></p>
|
|
5
|
-
</div>
|
|
6
|
-
<% end %>
|
|
Binary file
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* @override http://localhost:4020/static/sproutcore/en/_cache/collections-1205614097.css */
|
|
2
|
-
|
|
3
|
-
/* @group Common */
|
|
4
|
-
|
|
5
|
-
body {
|
|
6
|
-
overflow: hidden;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.collection-item {
|
|
10
|
-
cursor: pointer ;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* @end */
|
|
14
|
-
|
|
15
|
-
/* @group List View */
|
|
16
|
-
|
|
17
|
-
.sc-theme .sc-collection-view {
|
|
18
|
-
background-color: white ;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.sc-theme .list-insertion-point {
|
|
22
|
-
border: 1px #4e4977 solid;
|
|
23
|
-
position: absolute ;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.sc-theme .list-insertion-point .anchor {
|
|
27
|
-
position: absolute ;
|
|
28
|
-
width: 7px;
|
|
29
|
-
height: 7px;
|
|
30
|
-
left: -6px;
|
|
31
|
-
top: -4px;
|
|
32
|
-
background: static_url('images/buttons-sprite.png') no-repeat 0px -931px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* @end */
|
|
36
|
-
|
|
37
|
-
/* @group Grid View */
|
|
38
|
-
|
|
39
|
-
.sc-theme .grid-insertion-point {
|
|
40
|
-
border: 1px #4e4977 solid;
|
|
41
|
-
position: absolute ;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.sc-theme .grid-insertion-point .anchor {
|
|
45
|
-
position: absolute ;
|
|
46
|
-
width: 7px;
|
|
47
|
-
height: 7px;
|
|
48
|
-
left: -4px;
|
|
49
|
-
top: -6px;
|
|
50
|
-
background: static_url('images/buttons-sprite.png') no-repeat 0px -931px;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* @end */
|
|
54
|
-
|
|
55
|
-
/* @group Text Cell */
|
|
56
|
-
|
|
57
|
-
.sc-theme .collection-item {
|
|
58
|
-
text-decoration: none ;
|
|
59
|
-
color: #000;
|
|
60
|
-
border-top: 1px white solid;
|
|
61
|
-
background-color: white ;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.sc-theme .collection-item.text-cell {
|
|
65
|
-
display: block ;
|
|
66
|
-
padding: 0 6px;
|
|
67
|
-
line-height: 22px;
|
|
68
|
-
}
|
|
69
|
-
.sc-theme .collection-item.sel {
|
|
70
|
-
background-color: #ddd;
|
|
71
|
-
border-top: 1px solid #eee;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.sc-theme .sc-collection-view.focus .collection-item.sel {
|
|
75
|
-
background-color: #40007e;
|
|
76
|
-
color: white ;
|
|
77
|
-
border-top: 1px solid #84788f;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* @end */
|
|
81
|
-
|
|
82
|
-
|
|
Binary file
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// ========================================================================
|
|
2
|
-
// SproutCore
|
|
3
|
-
// copyright 2006-2007 Sprout Systems, Inc.
|
|
4
|
-
// ========================================================================
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
Apply this mixin to any view class to automatically inherit most of the
|
|
8
|
-
basic properties you need to support to act as an item view in a collection.
|
|
9
|
-
|
|
10
|
-
In addition to this module, make sure that your view class knows how to
|
|
11
|
-
render the object set on the 'content' property.
|
|
12
|
-
|
|
13
|
-
This module provides both the properties and reasonable default observers.
|
|
14
|
-
You can override them in your own class as well.
|
|
15
|
-
|
|
16
|
-
@namespace
|
|
17
|
-
*/
|
|
18
|
-
SC.CollectionItem = {
|
|
19
|
-
|
|
20
|
-
/** Set to true when the item is selected. */
|
|
21
|
-
isSelected: false,
|
|
22
|
-
|
|
23
|
-
/** By default, adds the 'sel' CSS class if selected. */
|
|
24
|
-
isSelectedObserver: function() {
|
|
25
|
-
this.setClassName('sel', this.get('isSelected')) ;
|
|
26
|
-
}.observes('isSelected'),
|
|
27
|
-
|
|
28
|
-
/** Set to true when the item is enabled. */
|
|
29
|
-
isEnabled: true,
|
|
30
|
-
|
|
31
|
-
/** By default, adds the disabled CSS class if disabled. */
|
|
32
|
-
isEnabledObserver: function() {
|
|
33
|
-
this.setClassName('disabled', !this.get('isEnabled'));
|
|
34
|
-
}.observes('isEnabled')
|
|
35
|
-
|
|
36
|
-
};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// ==========================================================================
|
|
2
|
-
// SC.TextCellView
|
|
3
|
-
// ==========================================================================
|
|
4
|
-
|
|
5
|
-
require('views/collection/collection_item') ;
|
|
6
|
-
|
|
7
|
-
/** @class
|
|
8
|
-
|
|
9
|
-
A Text Cell can display some textual or HTML content based on a content
|
|
10
|
-
object. Unlike a label view, a text cell relies on an owner view (usually
|
|
11
|
-
a collection view) to handle all of its event management and many of its
|
|
12
|
-
drawing properties and functions.
|
|
13
|
-
|
|
14
|
-
@extends SC.View
|
|
15
|
-
@author AuthorName
|
|
16
|
-
@version 0.1
|
|
17
|
-
*/
|
|
18
|
-
SC.TextCellView = SC.View.extend(SC.CollectionItem,
|
|
19
|
-
/** @scope SC.TextCellView.prototype */ {
|
|
20
|
-
|
|
21
|
-
emptyElement: '<div class="text-cell collection-item"></div>',
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
The content object this text item view will display.
|
|
25
|
-
*/
|
|
26
|
-
content: null,
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
The owner view of this cell. The TextCell relies on this
|
|
30
|
-
view to provide many of its behavioral defaults and for
|
|
31
|
-
event handling.
|
|
32
|
-
*/
|
|
33
|
-
owner: null,
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
If true, value will be escaped to avoid scripting attacks.
|
|
37
|
-
|
|
38
|
-
This is a default value that can be overridden by the
|
|
39
|
-
settings on the owner view.
|
|
40
|
-
*/
|
|
41
|
-
escapeHtml: true,
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
If true, then the value will be localized.
|
|
45
|
-
|
|
46
|
-
This is a default default that can be overidden by the
|
|
47
|
-
settings in the owner view.
|
|
48
|
-
*/
|
|
49
|
-
localize: false,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
Set this to a validator or to a function and the value
|
|
53
|
-
will be passed through it before being set.
|
|
54
|
-
|
|
55
|
-
This is a default default that can be overidden by the
|
|
56
|
-
settings in the owner view.
|
|
57
|
-
*/
|
|
58
|
-
formatter: null,
|
|
59
|
-
|
|
60
|
-
displayProperty: null,
|
|
61
|
-
|
|
62
|
-
// invoked whenever the content object changes.
|
|
63
|
-
_contentObserver: function() {
|
|
64
|
-
var content = this.get('content') ;
|
|
65
|
-
if (this._content == content) return ;
|
|
66
|
-
var f = this._boundValueDidChange() ;
|
|
67
|
-
|
|
68
|
-
// stop observing the old display property, if there is one.
|
|
69
|
-
if (this._content && this._displayProperty) {
|
|
70
|
-
this._content.removeObserver(this._displayProperty, f) ;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// start observing the new display property, if there is one
|
|
74
|
-
this._displayProperty = this._getDefault('displayProperty') ;
|
|
75
|
-
this._content = content ;
|
|
76
|
-
if (this._content && this._displayProperty) {
|
|
77
|
-
this._content.addObserver(this._displayProperty, f) ;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// notify value did change
|
|
81
|
-
this._valueDidChange() ;
|
|
82
|
-
}.observes('content'),
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
@private
|
|
86
|
-
|
|
87
|
-
Invoked whenever the monitored value on the content object
|
|
88
|
-
changes.
|
|
89
|
-
|
|
90
|
-
The value processed is either the displayProperty, if set, or
|
|
91
|
-
it is the content object itself.
|
|
92
|
-
*/
|
|
93
|
-
_valueDidChange: function() {
|
|
94
|
-
var content = this.get('content') ;
|
|
95
|
-
var value = (content && this._displayProperty) ? content.get(this._displayProperty) : content;
|
|
96
|
-
var owner = this.get('owner') ;
|
|
97
|
-
|
|
98
|
-
// prepare the value...
|
|
99
|
-
|
|
100
|
-
// 1. apply the formatter
|
|
101
|
-
var formatter = this._getDefault('formatter') ;
|
|
102
|
-
if (formatter) {
|
|
103
|
-
var formattedValue = ($type(formatter) == T_FUNCTION) ? formatter(value, this) : formatter.fieldValueForObject(value, this) ;
|
|
104
|
-
if (formattedValue != null) value = formattedValue ;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 2. If the returned value is not a string, convert it.
|
|
108
|
-
if (($type(value) != T_NULL) && value.toString) value = value.toString() ;
|
|
109
|
-
|
|
110
|
-
// 3. Localize
|
|
111
|
-
if (value && this._getDefault('localize')) value = value.loc() ;
|
|
112
|
-
|
|
113
|
-
// 4. Escape HTML
|
|
114
|
-
if (value && this._getDefault('escapeHtml')) value = value.escapeHTML() ;
|
|
115
|
-
|
|
116
|
-
this.set('asHTML', value || '') ;
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
_boundValueDidChange: function() {
|
|
120
|
-
return this._boundValueDidChange = this._boundValueDidChange || this._valueDidChange.bind(this);
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
// Retrieves the default value from the owner or locally.
|
|
124
|
-
_getDefault: function(keyName) {
|
|
125
|
-
var ret = (this.owner) ? this.owner.get(keyName) : null ;
|
|
126
|
-
return (ret != null) ? ret : this.get(keyName) ;
|
|
127
|
-
}
|
|
128
|
-
}) ;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
// ========================================================================
|
|
2
|
-
// SproutCore
|
|
3
|
-
// copyright 2006-2007 Sprout Systems, Inc.
|
|
4
|
-
// ========================================================================
|
|
5
|
-
|
|
6
|
-
require('views/view') ;
|
|
7
|
-
|
|
8
|
-
// This is the generic base class for input-type views such as text fields,
|
|
9
|
-
// checkboxes, etc. You can extend this for your own purposes as well.
|
|
10
|
-
SC.FieldView = SC.View.extend({
|
|
11
|
-
|
|
12
|
-
// PUBLIC PROPERTIES
|
|
13
|
-
// You generally do not need to override these properties though you might
|
|
14
|
-
// change them....
|
|
15
|
-
|
|
16
|
-
// this is the value of the field. The form view will pick up whatever
|
|
17
|
-
// value is published here. Generally you do not need to override this
|
|
18
|
-
// method. Instead you should override setFieldValue(), getFieldValue()
|
|
19
|
-
// and the error property.
|
|
20
|
-
value: null,
|
|
21
|
-
|
|
22
|
-
// set to true to enable editing on the field.
|
|
23
|
-
isEnabled: true,
|
|
24
|
-
|
|
25
|
-
// points to the validator for this field. Set to a validator class or
|
|
26
|
-
// instance. If this points to a class, it will be instantiated when the
|
|
27
|
-
// validator is first used.
|
|
28
|
-
validator: null,
|
|
29
|
-
|
|
30
|
-
// this should be set to the name of the key you want to be published for
|
|
31
|
-
// the owner form.
|
|
32
|
-
fieldKey: null,
|
|
33
|
-
|
|
34
|
-
// this should be set to the human readable label you want shown for errors.
|
|
35
|
-
// defaults to the value of fieldKey.
|
|
36
|
-
fieldLabel: null,
|
|
37
|
-
|
|
38
|
-
// computed property returns the human readable label for this field for
|
|
39
|
-
// use in error strings. This is either the fieldLabel or a humanized
|
|
40
|
-
// form of the fieldKey.
|
|
41
|
-
errorLabel: function() {
|
|
42
|
-
var ret = this.get('fieldLabel') ;
|
|
43
|
-
if (ret) return ret ;
|
|
44
|
-
|
|
45
|
-
// if field label is not provided, compute something...
|
|
46
|
-
var fk = this.get('fieldKey') ;
|
|
47
|
-
var def = (fk || '').humanize().capitalize() ;
|
|
48
|
-
return "FieldKey.%@".fmt(fk).locWithDefault(def) ; // localize if poss.
|
|
49
|
-
}.property('fieldLabel','fieldKey'),
|
|
50
|
-
|
|
51
|
-
// computed property, true when error is null.
|
|
52
|
-
isValid: function() {
|
|
53
|
-
return $type(this.get('value')) != T_ERROR;
|
|
54
|
-
}.property('value'),
|
|
55
|
-
|
|
56
|
-
// this is the raw value of the field, ignoring validation. You generally
|
|
57
|
-
// should not override this. Instead override setFieldValue and
|
|
58
|
-
// getFieldValue.
|
|
59
|
-
fieldValue: function(key,value) {
|
|
60
|
-
if (value !== undefined) this._setFieldValue(value) ;
|
|
61
|
-
return this._getFieldValue() ;
|
|
62
|
-
}.property('value'),
|
|
63
|
-
|
|
64
|
-
// ACTIONS
|
|
65
|
-
// You generally do not need to override these but they may be used.
|
|
66
|
-
|
|
67
|
-
// This is called to perform validation on the field just before the form
|
|
68
|
-
// is submitted. If you have a validator attached, this will get the
|
|
69
|
-
// validators.
|
|
70
|
-
validateSubmit: function() {
|
|
71
|
-
var ret = true ;
|
|
72
|
-
var value ;
|
|
73
|
-
|
|
74
|
-
if (this._validator) {
|
|
75
|
-
ret = this._validator.validateSubmit(this.get('ownerForm'),this) ;
|
|
76
|
-
value = ($type(ret) == T_ERROR) ? ret : this._getFieldValue() ;
|
|
77
|
-
} else value = this._getFieldValue() ;
|
|
78
|
-
|
|
79
|
-
if (value != this.get('value')) this.set('value',value) ;
|
|
80
|
-
return ret ;
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
// OVERRIDE IN YOUR SUBCLASS
|
|
84
|
-
// Override these primitives in your subclass as required.
|
|
85
|
-
|
|
86
|
-
// the two primitives below can be overridden by subclasses to translate
|
|
87
|
-
// the FieldView value to an element value and visa-versa.
|
|
88
|
-
setFieldValue: function(newValue) {
|
|
89
|
-
if (this.rootElement.value != newValue) this.rootElement.value = newValue;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
getFieldValue: function() {
|
|
93
|
-
return this.rootElement.value;
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
// This method should be called by you subclass anytime you want the view to
|
|
97
|
-
// pick up the current value from the form and post it out.
|
|
98
|
-
//
|
|
99
|
-
// partial (opt): default false. If true, this will be validated as a
|
|
100
|
-
// partial. Otherwise validated as a change.
|
|
101
|
-
//
|
|
102
|
-
fieldValueDidChange: function(partialChange) {
|
|
103
|
-
var ret = true ;
|
|
104
|
-
|
|
105
|
-
if (this._validator) {
|
|
106
|
-
var form = this.get('ownerForm') ;
|
|
107
|
-
if (partialChange == true) {
|
|
108
|
-
ret = this._validator.validatePartial(form,this) ;
|
|
109
|
-
|
|
110
|
-
// if the partial returned NO_CHANGE, then check to see if the
|
|
111
|
-
// field is valid anyway. If it is not valid, then don't update the
|
|
112
|
-
// value. This way the user can have partially constructed values
|
|
113
|
-
// without the validator trying to convert it to an object.
|
|
114
|
-
if (ret == SC.Validator.NO_CHANGE) {
|
|
115
|
-
if (this._validator.validateChange(form, this) != SC.Validator.OK) {
|
|
116
|
-
return ret ; // EXIT POINT
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
ret = this._validator.validateChange(form, this) ;
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// get the field value and set it.
|
|
126
|
-
// if ret is an error, use that instead of the field value.
|
|
127
|
-
var value = ($type(ret) == T_ERROR) ? ret : this._getFieldValue() ;
|
|
128
|
-
if (value != this.get('value')) this.set('value',value) ;
|
|
129
|
-
|
|
130
|
-
// if the validator says everything is OK, then in addition to posting
|
|
131
|
-
// out the value, go ahead and pass the value back through itself.
|
|
132
|
-
// This way if you have a formatter applied, it will reformat.
|
|
133
|
-
if (!partialChange && ($type(ret) != T_ERROR)) {
|
|
134
|
-
this._setFieldValue(value) ;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return ret ;
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
// override to enable editing of this field.
|
|
141
|
-
enableField: function() {
|
|
142
|
-
Form.Element.enable(this.rootElement) ;
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
// override to disable editing of this field.
|
|
146
|
-
disableField: function() {
|
|
147
|
-
Form.Element.disable(this.rootElement) ;
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// PRIVATE SUPPORT METHODS
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
init: function() {
|
|
155
|
-
arguments.callee.base.call(this) ;
|
|
156
|
-
this._validatorObserver() ;
|
|
157
|
-
this._enabledObserver() ;
|
|
158
|
-
if (this.rootElement) this._setFieldValue(this.get('value')) ;
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
// add a class name when the valid state changes.
|
|
163
|
-
_validObserver: function() {
|
|
164
|
-
this.setClassName('invalid',!this.get('isValid')) ;
|
|
165
|
-
}.observes('isValid'),
|
|
166
|
-
|
|
167
|
-
// called whenever isEnabled changes.
|
|
168
|
-
_enabledObserver: function(target, key, isEnabled) {
|
|
169
|
-
isEnabled = this.get('isEnabled') ;
|
|
170
|
-
this.setClassName('disabled', !isEnabled) ;
|
|
171
|
-
(isEnabled) ? this.enableField() : this.disableField();
|
|
172
|
-
}.observes('isEnabled'),
|
|
173
|
-
|
|
174
|
-
// called whenever the value is set on the object. Will set the value
|
|
175
|
-
// on the field if the value is changed.
|
|
176
|
-
_valueObserver: function() {
|
|
177
|
-
var value = this.get('value') ;
|
|
178
|
-
var isError = $type(value) == T_ERROR ;
|
|
179
|
-
if (!isError && (value != this._getFieldValue())) {
|
|
180
|
-
this._setFieldValue(value) ;
|
|
181
|
-
}
|
|
182
|
-
}.observes('value'),
|
|
183
|
-
|
|
184
|
-
// invoked whenever the attached validator changes.
|
|
185
|
-
_validatorObserver: function() {
|
|
186
|
-
var form = this.get('ownerForm') ;
|
|
187
|
-
var val = SC.Validator.findFor(form, this, this.get('validator')) ;
|
|
188
|
-
if (val != this._validator) {
|
|
189
|
-
if (this._validator) this._validator.detachFrom(form, this) ;
|
|
190
|
-
this._validator = val;
|
|
191
|
-
if (this._validator) this._validator.attachTo(form, this) ;
|
|
192
|
-
}
|
|
193
|
-
}.observes('validator', 'ownerForm'),
|
|
194
|
-
|
|
195
|
-
// these methods use the validator to conver the raw field value returned
|
|
196
|
-
// by your subclass into an object and visa versa.
|
|
197
|
-
_setFieldValue: function(newValue) {
|
|
198
|
-
if (this._validator) {
|
|
199
|
-
newValue = this._validator.fieldValueForObject(newValue, this.get('ownerForm'), this) ;
|
|
200
|
-
}
|
|
201
|
-
return this.setFieldValue(newValue) ;
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
_getFieldValue: function() {
|
|
205
|
-
var val = this.getFieldValue() ;
|
|
206
|
-
if (this._validator) {
|
|
207
|
-
val = this._validator.objectForFieldValue(val, this.get('ownerForm'), this) ;
|
|
208
|
-
}
|
|
209
|
-
return val ;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}) ;
|
|
213
|
-
|
|
214
|
-
|