sproutcore 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +269 -0
- data/README.txt +67 -0
- data/Rakefile +4 -0
- data/app_generators/sproutcore/USAGE +5 -0
- data/app_generators/sproutcore/sproutcore_generator.rb +66 -0
- data/app_generators/sproutcore/templates/README +77 -0
- data/app_generators/sproutcore/templates/environment.yml +4 -0
- data/bin/sc-build +145 -0
- data/bin/sc-gen +24 -0
- data/bin/sc-server +63 -0
- data/bin/sproutcore +21 -0
- data/clients/sc_docs/controllers/docs.js +118 -0
- data/clients/sc_docs/core.js +19 -0
- data/clients/sc_docs/english.lproj/body.css +159 -0
- data/clients/sc_docs/english.lproj/body.rhtml +33 -0
- data/clients/sc_docs/english.lproj/controls.css +0 -0
- 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/indicator.gif +0 -0
- data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_docs/english.lproj/no_docs.rhtml +7 -0
- data/clients/sc_docs/english.lproj/strings.js +14 -0
- data/clients/sc_docs/english.lproj/warning.rhtml +6 -0
- data/clients/sc_docs/fixtures/doc.js +11 -0
- data/clients/sc_docs/main.js +21 -0
- data/clients/sc_docs/models/doc.js +9 -0
- data/clients/sc_docs/tests/controllers/docs.rhtml +21 -0
- data/clients/sc_docs/tests/models/doc.rhtml +21 -0
- data/clients/sc_docs/tests/views/doc_frame.rhtml +21 -0
- data/clients/sc_docs/tests/views/doc_label_view.rhtml +21 -0
- data/clients/sc_docs/views/doc_frame.js +33 -0
- data/clients/sc_docs/views/doc_label.js +20 -0
- data/clients/sc_test_runner/controllers/runner.js +175 -0
- data/clients/sc_test_runner/core.js +19 -0
- data/clients/sc_test_runner/english.lproj/body.css +151 -0
- data/clients/sc_test_runner/english.lproj/body.rhtml +35 -0
- data/clients/sc_test_runner/english.lproj/controls.css +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_test_runner/english.lproj/images/gradients.png +0 -0
- data/clients/sc_test_runner/english.lproj/images/indicator.gif +0 -0
- data/clients/sc_test_runner/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_test_runner/english.lproj/no_tests.rhtml +6 -0
- data/clients/sc_test_runner/english.lproj/strings.js +14 -0
- data/clients/sc_test_runner/english.lproj/warning.rhtml +6 -0
- data/clients/sc_test_runner/fixtures/test.js +12 -0
- data/clients/sc_test_runner/main.js +26 -0
- data/clients/sc_test_runner/models/test.js +11 -0
- data/clients/sc_test_runner/views/runner_frame.js +72 -0
- data/clients/sc_test_runner/views/test_label.js +20 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/environment.yml +9 -0
- data/frameworks/prototype/prototype.js +4186 -0
- data/frameworks/sproutcore/Core.js +378 -0
- data/frameworks/sproutcore/README +3 -0
- data/frameworks/sproutcore/controllers/array.js +236 -0
- data/frameworks/sproutcore/controllers/collection.js +305 -0
- data/frameworks/sproutcore/controllers/controller.js +323 -0
- data/frameworks/sproutcore/controllers/object.js +372 -0
- data/frameworks/sproutcore/drag/drag.js +549 -0
- data/frameworks/sproutcore/drag/drag_data_source.js +32 -0
- data/frameworks/sproutcore/drag/drag_source.js +64 -0
- data/frameworks/sproutcore/drag/drop_target.js +153 -0
- data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/english.lproj/buttons.css +589 -0
- data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
- data/frameworks/sproutcore/english.lproj/inline_text_editor.css +21 -0
- data/frameworks/sproutcore/english.lproj/menu.css +121 -0
- data/frameworks/sproutcore/english.lproj/panels/background-fat.jpg +0 -0
- data/frameworks/sproutcore/english.lproj/panels/background-thin.jpg +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-left-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-right-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/left-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/overlay.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/right-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-left-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-right-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panes.css +155 -0
- data/frameworks/sproutcore/english.lproj/picker.css +22 -0
- data/frameworks/sproutcore/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/english.lproj/tab.css +23 -0
- data/frameworks/sproutcore/english.lproj/tests.css +67 -0
- data/frameworks/sproutcore/english.lproj/theme.css +77 -0
- data/frameworks/sproutcore/foundation/animator.js +670 -0
- data/frameworks/sproutcore/foundation/application.js +199 -0
- data/frameworks/sproutcore/foundation/array.js +348 -0
- data/frameworks/sproutcore/foundation/benchmark.js +211 -0
- data/frameworks/sproutcore/foundation/binding.js +384 -0
- data/frameworks/sproutcore/foundation/date.js +357 -0
- data/frameworks/sproutcore/foundation/error.js +39 -0
- data/frameworks/sproutcore/foundation/input_manager.js +153 -0
- data/frameworks/sproutcore/foundation/json.js +296 -0
- data/frameworks/sproutcore/foundation/mock.js +42 -0
- data/frameworks/sproutcore/foundation/node_descriptor.js +56 -0
- data/frameworks/sproutcore/foundation/object.js +777 -0
- data/frameworks/sproutcore/foundation/observable.js +451 -0
- data/frameworks/sproutcore/foundation/page.js +63 -0
- data/frameworks/sproutcore/foundation/path_module.js +413 -0
- data/frameworks/sproutcore/foundation/responder.js +310 -0
- data/frameworks/sproutcore/foundation/routes.js +371 -0
- data/frameworks/sproutcore/foundation/run_loop.js +21 -0
- data/frameworks/sproutcore/foundation/server.js +491 -0
- data/frameworks/sproutcore/foundation/set.js +96 -0
- data/frameworks/sproutcore/foundation/string.js +149 -0
- data/frameworks/sproutcore/foundation/undo_manager.js +186 -0
- data/frameworks/sproutcore/foundation/unittest.js +622 -0
- data/frameworks/sproutcore/foundation/utils.js +61 -0
- data/frameworks/sproutcore/globals/panels.js +182 -0
- data/frameworks/sproutcore/globals/popups.js +60 -0
- data/frameworks/sproutcore/globals/window.js +381 -0
- data/frameworks/sproutcore/lib/index.rhtml +66 -0
- data/frameworks/sproutcore/models/collection.js +395 -0
- data/frameworks/sproutcore/models/record.js +622 -0
- data/frameworks/sproutcore/models/store.js +295 -0
- data/frameworks/sproutcore/panes/dialog.js +16 -0
- data/frameworks/sproutcore/panes/manager.js +164 -0
- data/frameworks/sproutcore/panes/menu.js +45 -0
- data/frameworks/sproutcore/panes/overlay.js +231 -0
- data/frameworks/sproutcore/panes/pane.js +90 -0
- data/frameworks/sproutcore/panes/panel.js +19 -0
- data/frameworks/sproutcore/panes/picker.js +45 -0
- data/frameworks/sproutcore/tests/controllers/array.rhtml +86 -0
- data/frameworks/sproutcore/tests/controllers/controller.rhtml +273 -0
- data/frameworks/sproutcore/tests/controllers/object.rhtml +327 -0
- data/frameworks/sproutcore/tests/foundation/application.rhtml +125 -0
- data/frameworks/sproutcore/tests/foundation/array.rhtml +221 -0
- data/frameworks/sproutcore/tests/foundation/object.rhtml +69 -0
- data/frameworks/sproutcore/tests/globals/window.rhtml +45 -0
- data/frameworks/sproutcore/tests/panes/pane.rhtml +88 -0
- data/frameworks/sproutcore/tests/views/collection.rhtml +137 -0
- data/frameworks/sproutcore/tests/views/popup_button.rhtml +115 -0
- data/frameworks/sproutcore/tests/views/text_field.rhtml +37 -0
- data/frameworks/sproutcore/validators/credit_card.js +92 -0
- data/frameworks/sproutcore/validators/date.js +36 -0
- data/frameworks/sproutcore/validators/email.js +29 -0
- data/frameworks/sproutcore/validators/not_empty.js +24 -0
- data/frameworks/sproutcore/validators/number.js +55 -0
- data/frameworks/sproutcore/validators/password.js +78 -0
- data/frameworks/sproutcore/validators/validator.js +304 -0
- data/frameworks/sproutcore/views/button.js +425 -0
- data/frameworks/sproutcore/views/checkbox_field.js +30 -0
- data/frameworks/sproutcore/views/collection.js +1521 -0
- data/frameworks/sproutcore/views/container.js +62 -0
- data/frameworks/sproutcore/views/error_explanation.js +45 -0
- data/frameworks/sproutcore/views/field.js +214 -0
- data/frameworks/sproutcore/views/filter_button.js +29 -0
- data/frameworks/sproutcore/views/form.js +591 -0
- data/frameworks/sproutcore/views/image.js +141 -0
- data/frameworks/sproutcore/views/inline_text_editor.js +96 -0
- data/frameworks/sproutcore/views/label.js +176 -0
- data/frameworks/sproutcore/views/menu_item.js +90 -0
- data/frameworks/sproutcore/views/pagination.js +54 -0
- data/frameworks/sproutcore/views/popup_button.js +86 -0
- data/frameworks/sproutcore/views/popup_menu.js +137 -0
- data/frameworks/sproutcore/views/progress.js +100 -0
- data/frameworks/sproutcore/views/radio_field.js +107 -0
- data/frameworks/sproutcore/views/radio_group.js +48 -0
- data/frameworks/sproutcore/views/segmented.js +80 -0
- data/frameworks/sproutcore/views/select_field.js +272 -0
- data/frameworks/sproutcore/views/spinner.js +11 -0
- data/frameworks/sproutcore/views/tab.js +126 -0
- data/frameworks/sproutcore/views/text_field.js +179 -0
- data/frameworks/sproutcore/views/textarea_field.js +14 -0
- data/frameworks/sproutcore/views/toolbar.js +29 -0
- data/frameworks/sproutcore/views/view.js +1389 -0
- data/frameworks/sproutcore/views/workspace.js +170 -0
- data/generators/client/README +3 -0
- data/generators/client/USAGE +12 -0
- data/generators/client/client_generator.rb +53 -0
- data/generators/client/templates/core.js +19 -0
- data/generators/client/templates/english.lproj/body.css +0 -0
- data/generators/client/templates/english.lproj/body.rhtml +3 -0
- data/generators/client/templates/english.lproj/controls.css +0 -0
- data/generators/client/templates/english.lproj/strings.js +14 -0
- data/generators/client/templates/main.js +37 -0
- data/generators/controller/USAGE +16 -0
- data/generators/controller/controller_generator.rb +51 -0
- data/generators/controller/templates/controller.js +21 -0
- data/generators/controller/templates/test.rhtml +21 -0
- data/generators/framework/README +7 -0
- data/generators/framework/USAGE +12 -0
- data/generators/framework/framework_generator.rb +53 -0
- data/generators/framework/templates/core.js +20 -0
- data/generators/framework/templates/english.lproj/body.css +0 -0
- data/generators/framework/templates/english.lproj/body.rhtml +3 -0
- data/generators/framework/templates/english.lproj/controls.css +0 -0
- data/generators/framework/templates/english.lproj/strings.js +14 -0
- data/generators/language/USAGE +16 -0
- data/generators/language/language_generator.rb +47 -0
- data/generators/language/templates/strings.js +10 -0
- data/generators/model/USAGE +24 -0
- data/generators/model/model_generator.rb +55 -0
- data/generators/model/templates/fixture.js +11 -0
- data/generators/model/templates/model.js +20 -0
- data/generators/model/templates/test.rhtml +21 -0
- data/generators/test/USAGE +16 -0
- data/generators/test/templates/test.rhtml +21 -0
- data/generators/test/test_generator.rb +47 -0
- data/generators/view/USAGE +16 -0
- data/generators/view/templates/test.rhtml +21 -0
- data/generators/view/templates/view.js +20 -0
- data/generators/view/view_generator.rb +51 -0
- data/jsdoc/README.txt +119 -0
- data/jsdoc/app/DocFile.js +137 -0
- data/jsdoc/app/DocTag.js +110 -0
- data/jsdoc/app/Doclet.js +63 -0
- data/jsdoc/app/Dumper.js +143 -0
- data/jsdoc/app/JsDoc.js +103 -0
- data/jsdoc/app/JsHilite.js +45 -0
- data/jsdoc/app/JsIO.js +163 -0
- data/jsdoc/app/JsParse.js +385 -0
- data/jsdoc/app/JsPlate.js +130 -0
- data/jsdoc/app/JsTestrun.js +129 -0
- data/jsdoc/app/JsToke.js +564 -0
- data/jsdoc/app/Symbol.js +298 -0
- data/jsdoc/app/Transformer.js +14 -0
- data/jsdoc/app/Util.js +97 -0
- data/jsdoc/app/js.jar +0 -0
- data/jsdoc/app/run.js +144 -0
- data/jsdoc/plugins/min.js +316 -0
- data/jsdoc/plugins/strip.js +20 -0
- data/jsdoc/templates/sproutcore/class.tmpl +438 -0
- data/jsdoc/templates/sproutcore/default.css +241 -0
- data/jsdoc/templates/sproutcore/index.html +13 -0
- data/jsdoc/templates/sproutcore/index.tmpl +21 -0
- data/jsdoc/templates/sproutcore/prototype.js +4186 -0
- data/jsdoc/templates/sproutcore/publish.js +236 -0
- data/jsdoc/templates/sproutcore/splash.html +7 -0
- data/lib/sproutcore/build_tools/html_builder.rb +88 -0
- data/lib/sproutcore/build_tools/resource_builder.rb +194 -0
- data/lib/sproutcore/build_tools.rb +44 -0
- data/lib/sproutcore/bundle.rb +517 -0
- data/lib/sproutcore/bundle_manifest.rb +397 -0
- data/lib/sproutcore/generator_helper.rb +170 -0
- data/lib/sproutcore/helpers/capture_helper.rb +42 -0
- data/lib/sproutcore/helpers/static_helper.rb +80 -0
- data/lib/sproutcore/helpers/tag_helper.rb +110 -0
- data/lib/sproutcore/helpers/text_helper.rb +336 -0
- data/lib/sproutcore/helpers.rb +3 -0
- data/lib/sproutcore/jsdoc.rb +40 -0
- data/lib/sproutcore/jsmin.rb +247 -0
- data/lib/sproutcore/library.rb +258 -0
- data/lib/sproutcore/merb/bundle_controller.rb +179 -0
- data/lib/sproutcore/merb/router.rb +43 -0
- data/lib/sproutcore/merb.rb +27 -0
- data/lib/sproutcore/version.rb +9 -0
- data/lib/sproutcore/view_helpers/button_views.rb +302 -0
- data/lib/sproutcore/view_helpers/core_views.rb +284 -0
- data/lib/sproutcore/view_helpers/form_views.rb +258 -0
- data/lib/sproutcore/view_helpers/menu_views.rb +94 -0
- data/lib/sproutcore/view_helpers.rb +628 -0
- data/lib/sproutcore.rb +30 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/sproutcore_spec.rb +11 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- metadata +365 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
// ========================================================================
|
2
|
+
// SproutCore
|
3
|
+
// copyright 2006-2007 Sprout Systems, Inc.
|
4
|
+
// ========================================================================
|
5
|
+
|
6
|
+
require('panes/pane') ;
|
7
|
+
require('views/container') ;
|
8
|
+
|
9
|
+
// Panes are views that appear over the top of your regular content such as
|
10
|
+
// dialogs boxes and pop-up menus. This class provides the basic support for
|
11
|
+
// these functions.
|
12
|
+
//
|
13
|
+
// SproutCore provides built-in support for four different types of panes, but
|
14
|
+
// you can also create your own types of panes yourself. The pane view
|
15
|
+
// automatically groups all panes of a similar type together.
|
16
|
+
//
|
17
|
+
// To create your own type of pane, create a subclass of SC.PaneView and then
|
18
|
+
// register it with the SC.PaneManager:
|
19
|
+
//
|
20
|
+
// SC.PaneManager.registerPane('paneType', SC.PaneView);
|
21
|
+
//
|
22
|
+
// You can then make views show in the panes by settings the paneType
|
23
|
+
// property on the view and set 'isVisible' to true.
|
24
|
+
//
|
25
|
+
// Note that PaneView instances are reused by the pane manager. You should
|
26
|
+
// design your view be reused in this way.
|
27
|
+
//
|
28
|
+
SC.OverlayPaneView = SC.PaneView.extend({
|
29
|
+
|
30
|
+
// This property will be set to the content view when you are asked to
|
31
|
+
// display it.
|
32
|
+
content: null,
|
33
|
+
|
34
|
+
// Set this to a value that indicates where you want your view to appear
|
35
|
+
// compare to other types of panes in the system. the PaneManagers groups
|
36
|
+
// all panes of the same type together, with the most recently opened one
|
37
|
+
// appearing on top.
|
38
|
+
layer: 0,
|
39
|
+
|
40
|
+
// This property will be set to the view that triggered your pane to show
|
41
|
+
// if relevant. You can use this to properly size and position your pane.
|
42
|
+
anchorView: null,
|
43
|
+
|
44
|
+
// This property will be set to the event that triggered your pane to show
|
45
|
+
// if relevant. You can use this to properly size and position your pane.
|
46
|
+
triggerEvent: null,
|
47
|
+
|
48
|
+
// if true, this pane will be modal. Clicks outside of the containerView
|
49
|
+
// will be ignored. If false, this pane is semi-modal: it will
|
50
|
+
// hide if you click outside of the containerView.
|
51
|
+
isModal: true,
|
52
|
+
|
53
|
+
// override to position your pane on view.
|
54
|
+
positionPane: function() {
|
55
|
+
},
|
56
|
+
|
57
|
+
// This method will do its best to position your pane on screen in relation
|
58
|
+
// to the anchor view passed.
|
59
|
+
fitPositionToScreen: function(preferredPosition, paneView, anchor) {
|
60
|
+
|
61
|
+
// first build up the frame and convert to window...
|
62
|
+
var f = paneView.get('frame') ;
|
63
|
+
f.x = preferredPosition.x ; f.y = preferredPosition.y ;
|
64
|
+
f = paneView.convertFrameToView(f, null) ;
|
65
|
+
|
66
|
+
// get useful other frame limits.
|
67
|
+
var aframe = anchor.convertFrameToView(anchor.get('frame'), null) ;
|
68
|
+
var wframe = SC.window.get('frame') ;
|
69
|
+
|
70
|
+
// make sure the right edge fits on the screen. If not, anchor to
|
71
|
+
// right edge of anchor or right edge of window, whichever is closer.
|
72
|
+
if (SC.maxX(f) > wframe.width) {
|
73
|
+
var mx = Math.max(SC.maxX(aframe), f.width) ;
|
74
|
+
f.x = Math.min(mx, wframe.width) - f.width ;
|
75
|
+
}
|
76
|
+
|
77
|
+
// if the left edge is off of the screen, try to position at left edge
|
78
|
+
// of anchor. If that pushes right edge off screen, shift back until
|
79
|
+
// right is on screen or left = 0
|
80
|
+
if (SC.minX(f) < 0) {
|
81
|
+
f.x = SC.minX(Math.max(aframe,0)) ;
|
82
|
+
if (SC.maxX(f) > wframe.width) {
|
83
|
+
f.x = Math.max(0, wframe.width - f.width);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
// make sure bottom edge fits on screen. If not, try to anchor to top
|
88
|
+
// of anchor or bottom edge of screen.
|
89
|
+
if (SC.maxY(f) > wframe.height) {
|
90
|
+
var mx = Math.max((aframe.y - f.height), 0) ;
|
91
|
+
if (mx > wframe.height) {
|
92
|
+
f.y = Math.max(0, wframe.height - f.height) ;
|
93
|
+
} else f.y = mx ;
|
94
|
+
}
|
95
|
+
|
96
|
+
// if Top edge is off screen, try to anchor to bottom of anchor. If that
|
97
|
+
// pushes off bottom edge, shift up until it is back on screen or top =0
|
98
|
+
if (SC.minY(f) < 0) {
|
99
|
+
var mx = Math.min(SC.maxY(aframe), (wframe.height - aframe.height)) ;
|
100
|
+
f.y = Math.max(mx, 0) ;
|
101
|
+
}
|
102
|
+
|
103
|
+
return f ;
|
104
|
+
|
105
|
+
},
|
106
|
+
|
107
|
+
resizeWithOldParentSize: function(oldSize) {
|
108
|
+
this.positionPane() ;
|
109
|
+
},
|
110
|
+
|
111
|
+
// ...........................................
|
112
|
+
// KEYBOARD SUPPORT
|
113
|
+
//
|
114
|
+
acceptsFirstResponder: true,
|
115
|
+
|
116
|
+
keyDown: function(evt) {
|
117
|
+
if (!this.interpretKeyEvents(evt)) {
|
118
|
+
return arguments.callee.base.apply(this,arguments);
|
119
|
+
}
|
120
|
+
},
|
121
|
+
|
122
|
+
// when you hit return from within a dialog or panel, look for a child
|
123
|
+
// view with isDefault => true
|
124
|
+
insertNewline: function(sender, evt) {
|
125
|
+
var button = this._findViewWithKeyIn('isDefault', SC.ButtonView, this) ;
|
126
|
+
if (button) {
|
127
|
+
button.triggerAction(evt) ;
|
128
|
+
return true ;
|
129
|
+
} else return false ;
|
130
|
+
},
|
131
|
+
|
132
|
+
cancel: function(sender, evt) {
|
133
|
+
var button = this._findViewWithKeyIn('isDefault', SC.ButtonView, this) ;
|
134
|
+
if (button) {
|
135
|
+
button.triggerAction(evt) ;
|
136
|
+
return true ;
|
137
|
+
} else return false ;
|
138
|
+
},
|
139
|
+
|
140
|
+
_findViewWithKeyIn: function(keyName, rootClass, rootView, ignoreRoot) {
|
141
|
+
if (!ignoreRoot) {
|
142
|
+
if ((rootView instanceof rootClass) && rootView.get(keyName)) {
|
143
|
+
return rootView ;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
var child = rootView.get('firstChild') ;
|
148
|
+
while(child) {
|
149
|
+
var ret = this._findViewWithKeyIn(keyName, rootClass, child) ;
|
150
|
+
if (ret) return ret ;
|
151
|
+
child = child.get('nextSibling') ;
|
152
|
+
}
|
153
|
+
return null ;
|
154
|
+
},
|
155
|
+
|
156
|
+
focusFirstKeyView: function() {
|
157
|
+
var fr = this._findViewWithKeyIn('acceptsFirstResponder', SC.Responder, this, true) ;
|
158
|
+
if (!fr) fr = this;
|
159
|
+
fr.becomeFirstResponder() ;
|
160
|
+
},
|
161
|
+
|
162
|
+
click: function(evt) {
|
163
|
+
if (!this.get('isModal')) {
|
164
|
+
var content = this.containerView.get('content') ;
|
165
|
+
if (content) content.set('isVisible', false) ;
|
166
|
+
}
|
167
|
+
return true ;
|
168
|
+
},
|
169
|
+
|
170
|
+
// ...........................................
|
171
|
+
// PRIVATE METHODS
|
172
|
+
//
|
173
|
+
_contentDidChange: function() {
|
174
|
+
var containerView = this.get('containerView') ;
|
175
|
+
if (containerView) containerView.set('content',this.get('content')) ;
|
176
|
+
}.observes('content'),
|
177
|
+
|
178
|
+
outlets: ['containerView'],
|
179
|
+
containerView: SC.ContainerView.extend({
|
180
|
+
outlets: ['rootView'],
|
181
|
+
|
182
|
+
rootView: SC.View.extend({
|
183
|
+
// absorb all clicks so the pane will not hide.
|
184
|
+
click: function() { return true; }
|
185
|
+
}).outletFor('.pane-root?'),
|
186
|
+
|
187
|
+
_fixWidth: function() {
|
188
|
+
var content = this.get('content') ;
|
189
|
+
if (content) {
|
190
|
+
content.resizeWithOldParentSize(this.get('size')) ;
|
191
|
+
|
192
|
+
// compute padding we need to add.
|
193
|
+
var padding = this.get('size').width - this.get('innerSize').width;
|
194
|
+
this.set('size', { width: (content.get('size').width + padding) });
|
195
|
+
this.owner.positionPane() ;
|
196
|
+
this.owner.setStyle({ visibility: 'visible' }) ;
|
197
|
+
}
|
198
|
+
if (this.get('isVisibleInWindow'))
|
199
|
+
{
|
200
|
+
this.owner.focusFirstKeyView();
|
201
|
+
}
|
202
|
+
}.observes('content'),
|
203
|
+
|
204
|
+
init: function() {
|
205
|
+
arguments.callee.base.apply(this,arguments) ;
|
206
|
+
|
207
|
+
// only Safari does well enough with animations to handle this dainty
|
208
|
+
// guy.
|
209
|
+
if (SC.isSafari()) {
|
210
|
+
this.visibleAnimation = {
|
211
|
+
visible: 'opacity: 1.0', hidden: 'opacity: 0.0', duration: 100
|
212
|
+
} ;
|
213
|
+
}
|
214
|
+
},
|
215
|
+
|
216
|
+
// allow click through outside of the rootView.
|
217
|
+
click: function(evt) {
|
218
|
+
return false ;
|
219
|
+
}
|
220
|
+
|
221
|
+
}).outletFor('.pane-wrapper?'),
|
222
|
+
|
223
|
+
// just before the view becomes visible, set the width of the container
|
224
|
+
// view to match its content
|
225
|
+
show: function() {
|
226
|
+
this.containerView._fixWidth();
|
227
|
+
arguments.callee.base.apply(this,arguments);
|
228
|
+
//this.focusFirstKeyView() ;
|
229
|
+
}
|
230
|
+
|
231
|
+
});
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require('views/view');
|
2
|
+
|
3
|
+
SC.KEYVIEW_SELECTING_NONE = 0;
|
4
|
+
SC.KEYVIEW_SELECTING_NEXT = 1;
|
5
|
+
SC.KEYVIEW_SELECTING_PREVIOUS = 2;
|
6
|
+
|
7
|
+
SC.PaneView = SC.View.extend({
|
8
|
+
|
9
|
+
// panes do not belong to other panes...
|
10
|
+
pane: null,
|
11
|
+
|
12
|
+
isPane: true,
|
13
|
+
isModal: false,
|
14
|
+
|
15
|
+
canBecomeKeyPane: true,
|
16
|
+
isKeyPane: false,
|
17
|
+
makeKeyPane: function()
|
18
|
+
{
|
19
|
+
if (!this.get('canBecomeKeyPane')) return false;
|
20
|
+
if (this.get('isKeyPane')) return false;
|
21
|
+
SC.app.set('keyPane', this);
|
22
|
+
return true;
|
23
|
+
},
|
24
|
+
didBecomeKeyPane: function() {},
|
25
|
+
willResignKeyPane: function() {},
|
26
|
+
|
27
|
+
canBecomeMainPane: true,
|
28
|
+
isMainPane: false,
|
29
|
+
makeMainPane: function()
|
30
|
+
{
|
31
|
+
if (!this.get('canBecomeMainPane')) return false;
|
32
|
+
if (this.get('isMainPane')) return false;
|
33
|
+
SC.app.set('mainPane', this);
|
34
|
+
return true;
|
35
|
+
},
|
36
|
+
didBecomeMainPane: function() {},
|
37
|
+
willResignMainPane: function() {},
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
performKeyInterfaceControl: function( keystring, evt )
|
42
|
+
{
|
43
|
+
// TODO!
|
44
|
+
return false;
|
45
|
+
},
|
46
|
+
|
47
|
+
keyViewSelectionDirection: SC.KEYVIEW_SELECTING_NONE,
|
48
|
+
|
49
|
+
selectPreviousKeyView: function() {},
|
50
|
+
selectNextKeyView: function() {},
|
51
|
+
|
52
|
+
autorecalculatesKeyViewLoop: false,
|
53
|
+
recalculateKeyViewLoop: function() {},
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
nextResponder: null,
|
58
|
+
|
59
|
+
// This property points to the responder (usually a view) that should be
|
60
|
+
// the first to receive keyboard events. Usually you set this by calling
|
61
|
+
// becomeFirstResponder on the view itself.
|
62
|
+
_firstResponder: null,
|
63
|
+
firstResponder: function(key,value)
|
64
|
+
{
|
65
|
+
if (value !== undefined) {
|
66
|
+
if (this._firstResponder) {
|
67
|
+
this._firstResponder.willLoseFirstResponder();
|
68
|
+
}
|
69
|
+
if (this._firstResponder) {
|
70
|
+
this._firstResponder.set('isFirstResponder',false) ;
|
71
|
+
}
|
72
|
+
|
73
|
+
this._firstResponder = value ;
|
74
|
+
|
75
|
+
if (this._firstResponder) {
|
76
|
+
this._firstResponder.set('isFirstResponder',true) ;
|
77
|
+
}
|
78
|
+
if (this._firstResponder) {
|
79
|
+
this._firstResponder.didBecomeFirstResponder() ;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return this._firstResponder; //TODO: shouldn't we return the defaultResponder if !this._firstResponder
|
83
|
+
}.property(),
|
84
|
+
|
85
|
+
// This property can be set to point to a default responder that should
|
86
|
+
// handle keyboard events if no responders in the normal chain decide to
|
87
|
+
// take it.
|
88
|
+
defaultResponder: null
|
89
|
+
|
90
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// ========================================================================
|
2
|
+
// SproutCore
|
3
|
+
// copyright 2006-2007 Sprout Systems, Inc.
|
4
|
+
// ========================================================================
|
5
|
+
|
6
|
+
require('panes/overlay') ;
|
7
|
+
|
8
|
+
// A panel should be used for long-term modal interfaces. For example, you
|
9
|
+
// might use a panel for preferences or configuration settings. These are
|
10
|
+
// mini-parts of the application.
|
11
|
+
SC.PANEL_PANE = 'panel';
|
12
|
+
SC.PanelPaneView = SC.OverlayPaneView.extend({
|
13
|
+
|
14
|
+
emptyElement: '<div class="pane panel-pane"><div class="shadow pane-wrapper"><div class="pane-root"></div><div class="top-left-edge"></div><div class="top-edge"></div><div class="top-right-edge"></div><div class="right-edge"></div><div class="bottom-right-edge"></div><div class="bottom-edge"></div><div class="bottom-left-edge"></div><div class="left-edge"></div></div></div>',
|
15
|
+
|
16
|
+
layer: 100
|
17
|
+
|
18
|
+
}) ;
|
19
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// ========================================================================
|
2
|
+
// SproutCore
|
3
|
+
// copyright 2006-2007 Sprout Systems, Inc.
|
4
|
+
// ========================================================================
|
5
|
+
|
6
|
+
require('panes/overlay') ;
|
7
|
+
|
8
|
+
SC.PICKER_PANE = 'picker';
|
9
|
+
SC.PickerPaneView = SC.OverlayPaneView.extend({
|
10
|
+
|
11
|
+
emptyElement: '<div class="pane picker-pane"><div class="shadow pane-wrapper picker-pane-wrapper"><div class="pane-root"></div><div class="top-left-edge"></div><div class="top-edge"></div><div class="top-right-edge"></div><div class="right-edge"></div><div class="bottom-right-edge"></div><div class="bottom-edge"></div><div class="bottom-left-edge"></div><div class="left-edge"></div></div></div>',
|
12
|
+
|
13
|
+
layer: 300,
|
14
|
+
|
15
|
+
isModal: false,
|
16
|
+
|
17
|
+
// The ideal position for a picker pane is just below the anchor that
|
18
|
+
// triggered it. Find that ideal position, then call adjustPosition.
|
19
|
+
positionPane: function() {
|
20
|
+
var anchor = this.anchorView ;
|
21
|
+
var picker = this.containerView ;
|
22
|
+
var origin ;
|
23
|
+
|
24
|
+
// usually an anchorView will be passed. The ideal position to appear is
|
25
|
+
// just below the anchorView. If that is not possible, fitToScreen will
|
26
|
+
// take care of that.
|
27
|
+
if (anchor) {
|
28
|
+
origin = picker.convertFrameFromView(anchor.get('frame'), anchor) ;
|
29
|
+
origin.y += origin.height ;
|
30
|
+
origin = this.fitPositionToScreen(origin, picker, anchor) ;
|
31
|
+
|
32
|
+
// if no anchor view has been set for some reason, just center.
|
33
|
+
} else {
|
34
|
+
var wsize = SC.window.get('size') ;
|
35
|
+
var psize = picker.get('size') ;
|
36
|
+
origin.x = (wsize.width - psize.width) / 2 ;
|
37
|
+
origin.y = (wsize.height - psize.height) / 2 ;
|
38
|
+
}
|
39
|
+
|
40
|
+
picker.set('origin',origin) ;
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
}) ;
|
45
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<% content_for('final') do %>
|
2
|
+
|
3
|
+
<script type="text/javascript" charset="utf-8">
|
4
|
+
|
5
|
+
Test.context("SC.ArrayController", {
|
6
|
+
|
7
|
+
"Should act like an empty array if it has non array-like content": function()
|
8
|
+
{
|
9
|
+
var items = [null, false, "FOOBAR!", 12, {}];
|
10
|
+
for (var i=0, n=items.length; i < n; i++)
|
11
|
+
{
|
12
|
+
this.c.set('content', items[i]);
|
13
|
+
this.c.get('content').isEqual([]).shouldEqual(true);
|
14
|
+
this.c.get('length').shouldEqual(0);
|
15
|
+
(this.c.objectAt(0) == undefined).shouldEqual(true);
|
16
|
+
}
|
17
|
+
},
|
18
|
+
|
19
|
+
"Should act like a clone of whatever array was set as it's content": function()
|
20
|
+
{
|
21
|
+
this.c.set('content', this.multiple_a );
|
22
|
+
this.c.get('length').shouldEqual(2);
|
23
|
+
this.c.objectAt(0).get('test').shouldEqual('NAME0');
|
24
|
+
this.c.objectAt(1).get('test').shouldEqual('NAME1');
|
25
|
+
(this.c.objectAt(2) == undefined).shouldEqual(true);
|
26
|
+
},
|
27
|
+
|
28
|
+
"Should not clone it's content until a change has been made": function()
|
29
|
+
{
|
30
|
+
// note that we're not directly requesting the public 'contentClone' property, because
|
31
|
+
// doing so would cause the clone to be created.
|
32
|
+
(this.c._contentClone == undefined).shouldEqual(true);
|
33
|
+
this.c.set('content', this.multiple_a );
|
34
|
+
(this.c._contentClone == undefined).shouldEqual(true);
|
35
|
+
this.c.popObject();
|
36
|
+
(this.c._contentClone == undefined).shouldEqual(false);
|
37
|
+
},
|
38
|
+
"Should modify it's managed content when making changes": function()
|
39
|
+
{
|
40
|
+
this.c.set('content', this.multiple_a );
|
41
|
+
this.c.get('content').get('length').shouldEqual(2);
|
42
|
+
this.c.popObject();
|
43
|
+
this.c.get('content').get('length').shouldEqual(2);
|
44
|
+
this.c.get('contentClone').get('length').shouldEqual(1);
|
45
|
+
},
|
46
|
+
"Should flag itself as dirty when adding an item to the array": function()
|
47
|
+
{
|
48
|
+
this.c.set('content', this.multiple_a );
|
49
|
+
this.c.get('hasChanges').shouldEqual(false);
|
50
|
+
this.c.pushObject( SC.Object.create({ test: 'NAME2' }) );
|
51
|
+
this.c.get('hasChanges').shouldEqual(true);
|
52
|
+
},
|
53
|
+
|
54
|
+
setup: function()
|
55
|
+
{
|
56
|
+
this.c = SC.ArrayController.create();
|
57
|
+
|
58
|
+
this.multiple_a = [
|
59
|
+
SC.Object.create({ test: 'NAME0', value: 0, flag: YES, array: [0,0,0] }),
|
60
|
+
SC.Object.create({ test: 'NAME1', value: 1, flag: NO, array: [1,1,1] })
|
61
|
+
];
|
62
|
+
|
63
|
+
this.single_a = [
|
64
|
+
SC.Object.create({ test: 'NAME0', value: 0, flag: YES, array: [0,0,0] })
|
65
|
+
];
|
66
|
+
|
67
|
+
this.empty_a = [];
|
68
|
+
|
69
|
+
this.dummy_a = SC.Object.create(SC.Array, {
|
70
|
+
length: 2,
|
71
|
+
replace: function(idx, amt, objects) {
|
72
|
+
this._items.replace(idx,amt,objects) ;
|
73
|
+
this.set('length', this._items.length) ;
|
74
|
+
},
|
75
|
+
objectAt: function(idx) {
|
76
|
+
return this._items.objectAt(idx) ;
|
77
|
+
},
|
78
|
+
_items: this.multiple_a
|
79
|
+
});
|
80
|
+
}
|
81
|
+
|
82
|
+
});
|
83
|
+
|
84
|
+
</script>
|
85
|
+
|
86
|
+
<% end %>
|