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.
Files changed (208) hide show
  1. data/History.txt +233 -0
  2. data/Manifest.txt +67 -34
  3. data/bin/sc-build +12 -1
  4. data/bin/sc-gen +1 -1
  5. data/bin/sproutcore +14 -0
  6. data/clients/sc_docs/controllers/docs.js +38 -8
  7. data/clients/sc_docs/english.lproj/body.css +80 -127
  8. data/clients/sc_docs/english.lproj/body.rhtml +43 -23
  9. data/clients/sc_docs/english.lproj/no_docs.rhtml +2 -1
  10. data/clients/sc_docs/english.lproj/tabs.rhtml +16 -0
  11. data/clients/sc_docs/main.js +14 -9
  12. data/clients/sc_docs/models/doc.js +1 -1
  13. data/clients/sc_docs/tests/controllers/docs.rhtml +1 -2
  14. data/clients/sc_docs/tests/models/doc.rhtml +1 -2
  15. data/clients/sc_docs/tests/views/doc_frame.rhtml +1 -2
  16. data/clients/sc_docs/tests/views/doc_label_view.rhtml +1 -2
  17. data/clients/sc_docs/views/doc_frame.js +1 -1
  18. data/clients/sc_test_runner/controllers/runner.js +31 -8
  19. data/clients/sc_test_runner/english.lproj/body.css +62 -122
  20. data/clients/sc_test_runner/english.lproj/body.rhtml +62 -26
  21. data/clients/sc_test_runner/main.js +1 -6
  22. data/clients/sc_test_runner/models/test.js +14 -1
  23. data/clients/sc_test_runner/views/runner_frame.js +4 -2
  24. data/clients/view_builder/builders/builder.js +339 -0
  25. data/clients/view_builder/builders/button.js +81 -0
  26. data/clients/view_builder/controllers/document.js +21 -0
  27. data/clients/view_builder/core.js +19 -0
  28. data/clients/view_builder/english.lproj/body.css +77 -0
  29. data/clients/view_builder/english.lproj/body.rhtml +41 -0
  30. data/clients/{sc_docs → view_builder}/english.lproj/controls.css +0 -0
  31. data/clients/view_builder/english.lproj/strings.js +14 -0
  32. data/clients/view_builder/main.js +38 -0
  33. data/clients/view_builder/tests/controllers/document.rhtml +20 -0
  34. data/clients/view_builder/tests/views/builder.rhtml +20 -0
  35. data/clients/view_builder/views/builder.js +23 -0
  36. data/frameworks/prototype/prototype.js +1 -1
  37. data/frameworks/sproutcore/Core.js +32 -7
  38. data/frameworks/sproutcore/README +1 -1
  39. data/frameworks/sproutcore/animation/animation.js +411 -0
  40. data/frameworks/sproutcore/controllers/array.js +17 -9
  41. data/frameworks/sproutcore/controllers/collection.js +9 -110
  42. data/frameworks/sproutcore/controllers/controller.js +1 -1
  43. data/frameworks/sproutcore/controllers/object.js +2 -1
  44. data/frameworks/sproutcore/drag/drag.js +267 -56
  45. data/frameworks/sproutcore/drag/drag_data_source.js +24 -16
  46. data/frameworks/sproutcore/drag/drag_source.js +53 -42
  47. data/frameworks/sproutcore/drag/drop_target.js +2 -2
  48. data/frameworks/sproutcore/english.lproj/buttons.css +337 -236
  49. data/frameworks/sproutcore/english.lproj/core.css +115 -0
  50. data/frameworks/sproutcore/english.lproj/icons.css +227 -0
  51. data/{clients/sc_docs → frameworks/sproutcore}/english.lproj/images/indicator.gif +0 -0
  52. data/frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png +0 -0
  53. data/frameworks/sproutcore/english.lproj/images/sc-theme-ysprite.png +0 -0
  54. data/frameworks/sproutcore/english.lproj/images/shared-icons.png +0 -0
  55. data/frameworks/sproutcore/english.lproj/menu.css +1 -1
  56. data/frameworks/sproutcore/english.lproj/strings.js +1 -1
  57. data/frameworks/sproutcore/english.lproj/theme.css +405 -31
  58. data/frameworks/sproutcore/foundation/application.js +15 -11
  59. data/frameworks/sproutcore/foundation/benchmark.js +1 -1
  60. data/frameworks/sproutcore/foundation/binding.js +2 -2
  61. data/frameworks/sproutcore/foundation/date.js +1 -1
  62. data/frameworks/sproutcore/foundation/error.js +1 -1
  63. data/frameworks/sproutcore/foundation/input_manager.js +32 -21
  64. data/frameworks/sproutcore/foundation/mock.js +1 -1
  65. data/frameworks/sproutcore/foundation/node_descriptor.js +9 -6
  66. data/frameworks/sproutcore/foundation/object.js +249 -177
  67. data/frameworks/sproutcore/foundation/page.js +5 -2
  68. data/frameworks/sproutcore/foundation/path_module.js +11 -10
  69. data/frameworks/sproutcore/foundation/responder.js +5 -2
  70. data/frameworks/sproutcore/foundation/routes.js +17 -13
  71. data/frameworks/sproutcore/foundation/run_loop.js +249 -11
  72. data/frameworks/sproutcore/foundation/server.js +1 -1
  73. data/frameworks/sproutcore/foundation/set.js +3 -3
  74. data/frameworks/sproutcore/foundation/string.js +5 -3
  75. data/frameworks/sproutcore/foundation/timer.js +371 -0
  76. data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
  77. data/frameworks/sproutcore/foundation/unittest.js +3 -3
  78. data/frameworks/sproutcore/foundation/utils.js +161 -2
  79. data/frameworks/sproutcore/globals/panels.js +1 -1
  80. data/frameworks/sproutcore/globals/popups.js +4 -3
  81. data/frameworks/sproutcore/globals/window.js +44 -4
  82. data/frameworks/sproutcore/lib/button_views.rb +328 -0
  83. data/frameworks/sproutcore/lib/collection_view.rb +80 -0
  84. data/frameworks/sproutcore/lib/core_views.rb +281 -0
  85. data/frameworks/sproutcore/lib/form_views.rb +253 -0
  86. data/frameworks/sproutcore/lib/index.rhtml +2 -0
  87. data/frameworks/sproutcore/lib/menu_views.rb +88 -0
  88. data/frameworks/sproutcore/{foundation → mixins}/array.js +60 -29
  89. data/frameworks/sproutcore/mixins/control.js +265 -0
  90. data/frameworks/sproutcore/mixins/delegate_support.js +66 -0
  91. data/frameworks/sproutcore/{foundation → mixins}/observable.js +176 -6
  92. data/frameworks/sproutcore/mixins/scrollable.js +245 -0
  93. data/frameworks/sproutcore/mixins/selection_support.js +148 -0
  94. data/frameworks/sproutcore/mixins/validatable.js +152 -0
  95. data/frameworks/sproutcore/models/collection.js +5 -5
  96. data/frameworks/sproutcore/models/record.js +1 -1
  97. data/frameworks/sproutcore/models/store.js +1 -1
  98. data/frameworks/sproutcore/panes/dialog.js +1 -1
  99. data/frameworks/sproutcore/panes/manager.js +1 -1
  100. data/frameworks/sproutcore/panes/menu.js +1 -1
  101. data/frameworks/sproutcore/panes/overlay.js +2 -2
  102. data/frameworks/sproutcore/panes/panel.js +1 -1
  103. data/frameworks/sproutcore/panes/picker.js +1 -1
  104. data/frameworks/sproutcore/tests/controllers/array.rhtml +44 -4
  105. data/frameworks/sproutcore/tests/foundation/timer/invalidate.rhtml +33 -0
  106. data/frameworks/sproutcore/tests/foundation/timer/invokeLater.rhtml +145 -0
  107. data/frameworks/sproutcore/tests/foundation/timer/isPaused.rhtml +70 -0
  108. data/frameworks/sproutcore/tests/foundation/timer/schedule.rhtml +145 -0
  109. data/frameworks/sproutcore/tests/views/{scroll.rhtml → checkbox.rhtml} +3 -3
  110. data/frameworks/sproutcore/tests/views/{collection.rhtml → collection/base.rhtml} +33 -32
  111. data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +260 -0
  112. data/frameworks/sproutcore/tests/views/image_cell.rhtml +19 -0
  113. data/frameworks/sproutcore/tests/views/label_item.rhtml +2 -4
  114. data/frameworks/sproutcore/tests/views/list.rhtml +2 -3
  115. data/frameworks/sproutcore/tests/views/list_item.rhtml +20 -0
  116. data/frameworks/sproutcore/tests/views/slider.rhtml +20 -0
  117. data/frameworks/sproutcore/tests/views/text_cell.rhtml +19 -0
  118. data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +395 -0
  119. data/frameworks/sproutcore/tests/views/view/frame.rhtml +353 -0
  120. data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +347 -0
  121. data/frameworks/sproutcore/tests/views/view/isVisibleInWindow.rhtml +148 -0
  122. data/frameworks/sproutcore/tests/views/view/scrollFrame.rhtml +468 -0
  123. data/frameworks/sproutcore/validators/credit_card.js +33 -13
  124. data/frameworks/sproutcore/validators/date.js +26 -6
  125. data/frameworks/sproutcore/validators/email.js +21 -3
  126. data/frameworks/sproutcore/validators/not_empty.js +11 -1
  127. data/frameworks/sproutcore/validators/number.js +18 -4
  128. data/frameworks/sproutcore/validators/password.js +12 -1
  129. data/frameworks/sproutcore/validators/validator.js +204 -194
  130. data/frameworks/sproutcore/views/{button.js → button/button.js} +96 -94
  131. data/frameworks/sproutcore/views/button/checkbox.js +29 -0
  132. data/frameworks/sproutcore/views/button/disclosure.js +42 -0
  133. data/frameworks/sproutcore/views/button/radio.js +29 -0
  134. data/frameworks/sproutcore/views/{collection.js → collection/collection.js} +1373 -1024
  135. data/frameworks/sproutcore/views/collection/grid.js +124 -46
  136. data/frameworks/sproutcore/views/collection/image_cell.js +17 -46
  137. data/frameworks/sproutcore/views/collection/list.js +45 -35
  138. data/frameworks/sproutcore/views/collection/source_list.js +386 -0
  139. data/frameworks/sproutcore/views/collection/table.js +118 -0
  140. data/frameworks/sproutcore/views/container.js +7 -2
  141. data/frameworks/sproutcore/views/error_explanation.js +23 -10
  142. data/frameworks/sproutcore/views/{checkbox_field.js → field/checkbox_field.js} +16 -6
  143. data/frameworks/sproutcore/views/field/field.js +219 -0
  144. data/frameworks/sproutcore/views/{radio_field.js → field/radio_field.js} +27 -12
  145. data/frameworks/sproutcore/views/{select_field.js → field/select_field.js} +116 -90
  146. data/frameworks/sproutcore/views/{text_field.js → field/text_field.js} +57 -8
  147. data/frameworks/sproutcore/views/{textarea_field.js → field/textarea_field.js} +13 -3
  148. data/frameworks/sproutcore/views/filter_button.js +2 -2
  149. data/frameworks/sproutcore/views/form.js +3 -3
  150. data/frameworks/sproutcore/views/image.js +128 -21
  151. data/frameworks/sproutcore/views/inline_text_editor.js +1 -1
  152. data/frameworks/sproutcore/views/label.js +149 -92
  153. data/frameworks/sproutcore/views/list_item.js +225 -0
  154. data/frameworks/sproutcore/views/menu_item.js +10 -4
  155. data/frameworks/sproutcore/views/pagination.js +11 -4
  156. data/frameworks/sproutcore/views/popup_button.js +25 -21
  157. data/frameworks/sproutcore/views/popup_menu.js +10 -4
  158. data/frameworks/sproutcore/views/progress.js +29 -16
  159. data/frameworks/sproutcore/views/radio_group.js +1 -1
  160. data/frameworks/sproutcore/views/scroll.js +60 -20
  161. data/frameworks/sproutcore/views/segmented.js +1 -1
  162. data/frameworks/sproutcore/views/slider.js +132 -0
  163. data/frameworks/sproutcore/views/source_list_group.js +130 -0
  164. data/frameworks/sproutcore/views/spinner.js +1 -1
  165. data/frameworks/sproutcore/views/split.js +292 -0
  166. data/frameworks/sproutcore/views/split_divider.js +109 -0
  167. data/frameworks/sproutcore/views/tab.js +1 -1
  168. data/frameworks/sproutcore/views/toolbar.js +1 -1
  169. data/frameworks/sproutcore/views/view.js +1272 -591
  170. data/generators/client/templates/english.lproj/body.css +1 -1
  171. data/generators/controller/controller_generator.rb +1 -1
  172. data/generators/controller/templates/test.rhtml +2 -1
  173. data/generators/model/templates/test.rhtml +1 -1
  174. data/generators/test/templates/test.rhtml +1 -1
  175. data/generators/view/templates/test.rhtml +1 -1
  176. data/jsdoc/templates/sproutcore/class.tmpl +241 -338
  177. data/jsdoc/templates/sproutcore/default.css +105 -155
  178. data/jsdoc/templates/sproutcore/index.tmpl +43 -8
  179. data/jsdoc/templates/sproutcore/publish.js +9 -4
  180. data/lib/sproutcore/build_tools/html_builder.rb +29 -13
  181. data/lib/sproutcore/build_tools/resource_builder.rb +1 -1
  182. data/lib/sproutcore/bundle.rb +86 -25
  183. data/lib/sproutcore/jsdoc.rb +2 -0
  184. data/lib/sproutcore/version.rb +1 -1
  185. data/lib/sproutcore/view_helpers.rb +36 -3
  186. data/tasks/deployment.rake +1 -1
  187. metadata +69 -36
  188. data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
  189. data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
  190. data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
  191. data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
  192. data/clients/sc_docs/english.lproj/warning.rhtml +0 -6
  193. data/clients/sc_test_runner/english.lproj/warning.rhtml +0 -6
  194. data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
  195. data/frameworks/sproutcore/english.lproj/collections.css +0 -82
  196. data/frameworks/sproutcore/english.lproj/images/buttons-sprite.png +0 -0
  197. data/frameworks/sproutcore/views/collection/collection_item.js +0 -36
  198. data/frameworks/sproutcore/views/collection/text_cell.js +0 -128
  199. data/frameworks/sproutcore/views/field.js +0 -214
  200. data/frameworks/sproutcore/views/workspace.js +0 -170
  201. data/generators/client/templates/english.lproj/controls.css +0 -0
  202. data/generators/framework/templates/english.lproj/body.css +0 -0
  203. data/generators/framework/templates/english.lproj/body.rhtml +0 -3
  204. data/generators/framework/templates/english.lproj/controls.css +0 -0
  205. data/lib/sproutcore/view_helpers/button_views.rb +0 -302
  206. data/lib/sproutcore/view_helpers/core_views.rb +0 -292
  207. data/lib/sproutcore/view_helpers/form_views.rb +0 -258
  208. data/lib/sproutcore/view_helpers/menu_views.rb +0 -94
@@ -1,170 +0,0 @@
1
- // ========================================================================
2
- // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
4
- // ========================================================================
5
-
6
- require('views/tab') ;
7
- require('foundation/routes') ;
8
- require('views/button') ;
9
-
10
- // A WorkspaceView is a type of tab view that looks for certain elements
11
- // inside the content object and then places those into similarly named
12
- // elements inside the receiver view. (You can extend this with more
13
- // element areas by overriding the areas property.)
14
- SC.WorkspaceView = SC.TabView.extend({
15
-
16
- // override this if you need with the areas you want it to look for. You
17
- // must have elements with the class '.detail.NAME' inside the receiver
18
- // view to match.
19
- areas: ['head','master','detail','dialog','tail'],
20
-
21
- // override this with the names of your standard workspaces. Any names
22
- // found here will be converted into code that looks like this:
23
- //
24
- // fooTab: NAMESPACE.fooWorkspace.outletFor('#foo-workspace'),
25
- // fooButton: SC.ButtonView.outletFor('#foo')
26
- //
27
- workspaces: [],
28
- namespace: null,
29
-
30
- // used internally to configure the workspace view when you create it.
31
- // be sure to add any tabs/buttons you want.
32
- elements: function() {
33
- var view = this ;
34
- var ret = [] ;
35
- this.areas.each(function(area) {
36
- var el = view.$C(area) ;
37
- if (el) {
38
- view[area + 'Element'] = SC.ContainerView.viewFor(el);
39
- ret.push(el) ;
40
- }
41
- }) ;
42
- return ret ;
43
- },
44
-
45
- replaceContent: function(newContent) {
46
- var view = this ;
47
- this.areas.each(function(area) {
48
- var key = area + 'Element' ;
49
- var newElement = newContent.get(key) ;
50
- var viewArea = view[key] ;
51
-
52
- // remove existing children
53
- if (viewArea) {
54
- viewArea.set('content',newElement) ;
55
- } else {
56
- console.log('WARNING: could not find view area: ' + key) ;
57
- }
58
- }) ;
59
-
60
- // if there was a prior content object, notify it that nowShowing has
61
- // changed.
62
- if (this._nowShowingContent) {
63
- this._nowShowingContent.set('nowShowing',null) ;
64
- }
65
- newContent.set('nowShowing',this.get('nowShowing')) ;
66
- this._nowShowingContent = newContent ;
67
- },
68
-
69
- init: function() {
70
- // before calling super, setup the automatically named workspaces.
71
- if (this.namespace && this.workspaces && this.workspaces.length > 0) {
72
- var view = this ; var ns = this.namespace ;
73
- this.workspaces.each(function(key) {
74
- key = key.toLowerCase() ;
75
- var tab = window[ns][key.capitalize() + 'Workspace'] ;
76
- if (tab && !(view[key + 'Tab'])) {
77
- tab = tab.viewFor(key + '-workspace') ;
78
- view[key + 'Tab'] = tab ;
79
- }
80
-
81
- var button = $(key) ;
82
- if (button) view[key + 'Button'] = SC._WorkspaceButton.viewFor(key,{
83
- workspace: view, workspaceId: key
84
- }) ;
85
- }) ;
86
- }
87
-
88
- // go ahead with the rest of this.
89
- arguments.callee.base.call(this) ;
90
-
91
- this.elements = this.elements() ;
92
-
93
- // register workspace route.
94
- SC.Routes.addRoute(':workspace',this._showWorkspace.bind(this)) ;
95
- },
96
-
97
- _showWorkspace: function(params) {
98
- if (this._tabs[params.workspace]) {
99
- this.beginPropertyChanges() ;
100
- this.set('nowShowing',params.workspace) ;
101
- this.set('options',params) ;
102
- this.endPropertyChanges() ;
103
- } else console.log('workspace not found: ' + params.workspace) ;
104
- }
105
-
106
- }) ;
107
-
108
- SC._WorkspaceButton = SC.ButtonView.extend({
109
- workspace: null, workspaceId: null,
110
- action: function() { SC.Routes.set('location',this.workspaceId); },
111
- isSelectedObserver: function() {
112
- var parent = this.parentNode ;
113
- if (parent) Element.setClassName($(parent),'sel',this.get('isSelected'));
114
- }.observes('isSelected')
115
- }),
116
-
117
- // Elements that you want to have swapped in and out can be subclassed from
118
- // this. Or, you can create your own object. Any elements you want swapped
119
- // in and out need to be configured as a property named 'somethingElement'.
120
- SC.WorkspaceTab = SC.View.extend({
121
-
122
- // ...................................
123
- // PROPERTIES
124
- // Override these with your own settings.
125
-
126
- // modify to include the areas you want loaded in this element.
127
- areas: ['head','master','detail','dialog','tail'],
128
-
129
- // the type of view you want your found elements converted into. If you
130
- // set this to null, the elements will not be converted.
131
- viewType: SC.View,
132
-
133
- // Set this to something non-null to show the title in the window.
134
- title: null,
135
-
136
- // this should be the portion of the location the user needs to put after
137
- // the hash to get this workspace to show again in this configuration.
138
- location: null,
139
-
140
- // this property will be set by the UI when the user types into the search
141
- // field. You can observe this property to update your content accordingly.
142
- filterString: null,
143
-
144
- // if this workspace is visible, then this property will be set to the
145
- // id used to show this workspace. It will be set back to null when
146
- // the workspace is hidden.
147
- nowShowing: null,
148
-
149
- // ...................................
150
- // PRIVATE
151
- //
152
- elements: function() {
153
- var view = this ;
154
- var ret = [] ;
155
- this.areas.each(function(area) {
156
- var el = view.$C(area,1) ;
157
- if (el) {
158
- if (this.viewType) el = this.viewType.viewFor(el) ;
159
- view[area + 'Element'] = el ; ret.push(el) ;
160
- }
161
- }) ;
162
- return ret ;
163
- },
164
-
165
- init: function() {
166
- arguments.callee.base.apply(this,arguments) ;
167
- this.elements = this.elements() ;
168
- }
169
-
170
- }) ;
@@ -1,3 +0,0 @@
1
- <% content_for('body') do %>
2
- <h1>Welcome to SproutCore</h1>
3
- <% end %>
@@ -1,302 +0,0 @@
1
- ############################################################
2
- # BUTTON VIEW HELPERS
3
- #
4
- # You can do a lot of different things with buttons: push buttons, switches,
5
- # checkboxes, radio buttons and more. This file contains the helpers you can
6
- # use to help you build these.
7
- #
8
-
9
- require 'sproutcore/view_helpers/core_views'
10
-
11
- module SproutCore
12
- module ViewHelpers
13
-
14
- # This is the core button_view helper. Most other helpers in this file
15
- # descend from this helper. If a helper is not provided that already
16
- # builds the button you want, you can probably use this helper to
17
- # construct it yourself.
18
- #
19
- # :enabled (bindable) =>
20
- # If set to true, the button will be enabled.
21
- #
22
- # :selected (bindable) =>
23
- # Set to true, false or :mixed. This will determine if the button
24
- # appears selected. You can bind to this option but more often you will
25
- # want to bind to :value.
26
- #
27
- # :default (bindable) =>
28
- # Set to true to make this button the default button triggered when
29
- # you press return while focused in a panel or form.
30
- #
31
- # :cancel (bindable) =>
32
- # Set to true to make this button the one triggered when you press
33
- # return while focused on a panel or form.
34
- #
35
- # :theme => :regular | :back | :checkbox | :radio | :square |
36
- # (your own theme)
37
- # Use this to set the theme appearance of the button. The SC theme
38
- # comes with built-in support for the ones listed above or you can
39
- # name your own. a CSS class name will be assigned to the button with
40
- # this theme name.
41
- #
42
- # :behavior => :push, :toggle, :on, :off
43
- # Specify the behavior of the button when pressed. The default is
44
- # :push.
45
- #
46
- # :tag =>
47
- # The tag name to use for the button. Defaults to 'a'. If the tag is
48
- # 'a', an href="javascript:;" will be added automatically unless you
49
- # specify an alternate.
50
- #
51
- # :href =>
52
- # optional href to pass. Generall you don't want to pass this.
53
- #
54
- # :label =>
55
- # The value of the label placed inside the button. You can alternately
56
- # specify inner_html which will be used a the label. Note that the
57
- # button_view generator automatically wraps your inner_html with a
58
- # standard button structure unless you pass :label => false
59
- #
60
- # :image =>
61
- # Renders an image tag on the outside of the label span. If this is
62
- # set, then the wrapping tag will also have 'image' css class applied.
63
- #
64
- # :sprite => [resource_url, x-ofset, y-offset]
65
- # Render an image sprite! The expected size of the sprite depends on
66
- # the class name of the view. If the x-offset or y-offset are numbers
67
- # they will be converted to "px". If this is set, then the wrapping
68
- # tag will also have 'sprite' css class applied.
69
- #
70
- # Alternatively, name the CSS class you want assigned to the img for
71
- # the sprite.
72
- #
73
- view_helper :button_view do
74
- # JavaScript
75
- property :enabled, :key => 'isEnabled'
76
-
77
- property :action
78
- property :target
79
-
80
- #property(:action) { |v| "function(ev) { return #{v}(this, ev); }" }
81
- property :default, :key => 'isDefault'
82
- property :cancel, :key => 'isCancel'
83
- property :value
84
- property :theme
85
- property :size
86
- property :behavior, :key => 'buttonBehavior'
87
- property :toggle_on_value
88
- property :toggle_off_value
89
-
90
- property :key_equivalent, :key => :keyEquivalent
91
-
92
-
93
- property(:selected, :key => 'isSelected') do |x|
94
- (x == :mixed) ? 'SC.MIXED_STATE' : x
95
- end
96
-
97
- view 'SC.ButtonView'
98
-
99
- # HTML
100
- var :label, @inner_html || 'Submit'
101
- var :tag, 'a'
102
- var :theme, :regular
103
- var :size, :normal
104
-
105
- attribute(:href) { |x| (x.nil? && (@tag.downcase.to_s == 'a')) ? 'javascript:;' : nil }
106
-
107
- # Add the theme to the CSS class.
108
- css_class_names << 'button'
109
- css_class_names << @theme unless @theme.nil? || @theme == false
110
- css_class_names << @size unless @size.nil? || @size == false
111
-
112
- var :image
113
- var :sprite
114
-
115
- if @image
116
- @image = %(<img src="#{@image}" />)
117
- css_class_names << 'image'
118
-
119
- elsif @sprite
120
- img_url = self.blank_url
121
-
122
- if @sprite.instance_of?(Array)
123
- xoff = @sprite[1]
124
- xoff = "#{xoff}px" if xoff.kind_of?(Numeric)
125
-
126
- yoff = @sprite[2]
127
- yoff = "#{yoff}px" if yoff.kind_of?(Numeric)
128
-
129
- # render image part
130
- @image = %(<img class="sprite" style="background: url(#{@sprite[0]}) no-repeat #{xoff} #{yoff};" src="#{img_url}" />)
131
-
132
- else
133
- @image = %(<img class="#{@sprite} sprite" src="#{img_url}" />)
134
- end
135
-
136
- end
137
-
138
- # Generate some standard HTML for unless :label => false.
139
- unless @label == false
140
- # Button Width properties must be set on the inner label. To deal
141
- # with this remove any width style properties from the parent element
142
- # and append them to the inner label.
143
- @label_style = []
144
- css_styles.flatten!
145
- css_styles.reject! do | part |
146
- if part =~ /width:/
147
- @label_style << part
148
- true
149
- else
150
- false
151
- end
152
- end
153
- if @label_style.size > 0
154
- @label_style = %(style="#{@label_style * ' '}" )
155
- else
156
- @label_style = ''
157
- end
158
-
159
- # Avoid doing the normal thing for anchor tags.
160
- @inner_html = %(<span class="button-inner">#{@image}<span #{@label_style}class="label">#{@label}</span></span>)
161
-
162
- else
163
- @inner_html = [@image,@inner_html] * ''
164
- end
165
-
166
- end
167
-
168
-
169
-
170
- view_helper :popup_button_view, :wraps => :button_view do
171
- parent_helper
172
- property :menu, :key => :menuName
173
- view 'SC.PopupButtonView'
174
- end
175
-
176
-
177
-
178
- # Renders a back button
179
- view_helper :back_button_view, :wraps => :button_view do
180
- parent_helper :theme => :back
181
- end
182
-
183
- # Renders a checkbox. If you pass a label this will render the label
184
- # text next to the checkbox. Unlike button_view, passing no :label is
185
- # the same as passing :label => false.
186
- view_helper :checkbox_view, :wraps => :button_view do
187
- opts = { :theme => :checkbox }
188
- opts[:label] = false if options[:label].nil?
189
- parent_helper(opts)
190
-
191
- # provide some defaults to the JavaScript.
192
- property :behavior, :toggle, :key => 'buttonBehavior'
193
-
194
- # render checkbox HTML.
195
-
196
- img_url = self.blank_url
197
- @inner_html = [%(<img class="button" src="#{img_url}" />)]
198
- @inner_html << %(<span #{@label_style}class="label">#{@label}</span>) if @label
199
- @inner_html = @inner_html.join ''
200
- end
201
-
202
- # Renders a radio buton. If you pass a label this will render the label
203
- # text next to the checkbox. Unlike button_view, passing no :label is
204
- # the same as passing :label => false.
205
- view_helper :radio_view, :wraps => :button_view do
206
- opts = { :theme => :radio }
207
- opts[:label] = false if options[:label].nil?
208
- parent_helper(opts)
209
-
210
- # provide some defaults to the JavaScript.
211
- property :behavior, :on, :key => 'buttonBehavior'
212
-
213
- # render checkbox HTML.
214
- img_url = self.blank_url
215
- @inner_html = [%(<img class="button" src="#{img_url}" />)]
216
- @inner_html << %(<span #{@label_style}class="label">#{@label}</span>) if @label
217
- @inner_html = @inner_html.join ''
218
- end
219
-
220
-
221
- # This renders a group of radio buttons. The buttons are controlled by
222
- # a RadioGroupView that will map the value to a set of selection states.
223
- #
224
- # :values => [REQ]
225
- # Set this to the values you want displayed in the radio buttons. You
226
- # can pass an array here of strings or symbols, in which case these will
227
- # be used as the values for the buttons and the names will be created
228
- # from them. Or you can pass an array of arrays. The first items is
229
- # the key value, the second item is the human readable value.
230
- # Alternatively, you can set the inner_html of your view to include
231
- # radio buttons as outlets. In this case, you must name the outlets
232
- # :key_button.
233
- #
234
- # :layout => :horizontal | :vertical
235
- # This will write out horizontal or vertical to the CSS class names so
236
- # you can control the layout of your radio buttons.
237
- #
238
- # :width =>
239
- # This will set the width of each item in the view.
240
- #
241
- # BINDABLE OPTIONS
242
- #
243
- # :value =>
244
- # The current value of the radio buttons.
245
- #
246
- view_helper :radio_group_view do
247
-
248
- #JavaScript
249
- property :value
250
- view 'SC.RadioGroupView'
251
-
252
- # HTML
253
-
254
- # get the layout mode.
255
- var :layout, :vertical
256
- css_class_names << 'radio' # default class
257
- css_class_names << @layout if @layout
258
-
259
- var :tag, 'span'
260
-
261
- # If a set of values was passed, build the button views automatically.
262
- var :values
263
- if @values
264
- # Get the width styles out of the main style to put into the
265
- # individual radio items.
266
- css_styles.flatten!
267
- @label_styles = css_styles.reject { |p| !(p =~ /width:/) }
268
- css_styles.reject! { |p| @label_styles.include?(p) }
269
-
270
- if @label_styles.size > 0
271
- @label_styles = %( style="#{@label_styles * ' '}" )
272
- else
273
- @label_styles = ''
274
- end
275
-
276
- # save off client_builder. The context this is run in later will
277
- # not retain the client_builder
278
- current_client_builder = self.client_builder
279
- html = @values.map do | v |
280
- v = [v].flatten
281
- key = v.first
282
- label = (v.size > 1) ? v[1] : key.to_s.humanize
283
- ViewHelpers::radio_view(:outlet => true, :label => label, :style => @label_styles, :toggle_on_value => key, :toggle_off_value => nil, :client => self.client_builder)
284
- end
285
-
286
- @inner_html = html * "\n"
287
- end
288
- end
289
-
290
- # def self.blank_url
291
- # cb = SproutCore::ClientBuilder.builder_for(:sproutcore)
292
- # if cb
293
- # img_url = cb.url_for('blank.gif')
294
- # else
295
- # # if the sproutcore client cannot be found, give it a shot anyway...
296
- # img_url = '/static/sproutcore/en/blank.gif'
297
- # end
298
- # img_url
299
- # end
300
-
301
- end
302
- end