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,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('views/view') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('views/view') ;
@@ -32,8 +32,9 @@ SC.PopupView = SC.PanelView.extend({
32
32
  }),
33
33
 
34
34
  locationFor: function(view,ev) {
35
- var x = (ev) ? (Event.pointerX(ev) - 20) : 100 ;
36
- var y = (ev) ? Event.pointerY(ev) : 100 ;
35
+ var loc = Event.pointerLocation(ev) ;
36
+ var x = (ev) ? (loc.x - 20) : 100 ;
37
+ var y = (ev) ? lox.y : 100 ;
37
38
  var dim = view.get('size') ;
38
39
  var screenSize = Element.getDimensions(this) ;
39
40
 
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('Core') ;
@@ -26,6 +26,18 @@ SC.window = SC.PaneView.extend({
26
26
  // Window Size/Resizing
27
27
  //
28
28
 
29
+ innerFrame: function() {
30
+ return this.frame();
31
+ }.property('frame'),
32
+
33
+ clippingFrame: function() {
34
+ return this.frame();
35
+ }.property('frame'),
36
+
37
+ scrollFrame: function() {
38
+ return this.frame();
39
+ }.property('frame'),
40
+
29
41
  frame: function() {
30
42
  var size = this.get('size') ;
31
43
  return { x: 0, y: 0, width: size.width, height: size.height } ;
@@ -161,6 +173,10 @@ SC.window = SC.PaneView.extend({
161
173
 
162
174
  _onmousedown: function(evt)
163
175
  {
176
+ // make sure the view gets focus no matter what. FF is inconsistant
177
+ // about this.
178
+ this._onfocus();
179
+
164
180
  // first, save the click count. Click count resets if your down is
165
181
  // more than 125msec after you last click up.
166
182
  this._clickCount = this._clickCount + 1 ;
@@ -243,6 +259,11 @@ SC.window = SC.PaneView.extend({
243
259
  // trigger calls to mouseDragged.
244
260
  //
245
261
  _onmousemove: function(evt) {
262
+
263
+ // make sure the view gets focus no matter what. FF is inconsistant
264
+ // about this.
265
+ this._onfocus();
266
+
246
267
  var lh = this._lastHovered || [] ;
247
268
  var nh = [] ;
248
269
  var view = this.firstViewForEvent(evt) ;
@@ -288,13 +309,30 @@ SC.window = SC.PaneView.extend({
288
309
  });
289
310
  },
290
311
 
291
- _EVTS: ['mousedown', 'mouseup', 'click', 'dblclick', 'keydown', 'keyup', 'keypress', 'mouseover', 'mouseout', 'mousemove', 'resize', 'unload'],
312
+ _onfocus: function() {
313
+ if (!this._hasFocus) {
314
+ this._hasFocus = YES ;
315
+ this.addClassName('focus') ;
316
+ this.removeClassName('blur') ;
317
+ }
318
+ },
319
+
320
+ _onblur: function() {
321
+ if (this._hasFocus) {
322
+ this._hasFocus = NO ;
323
+ this.removeClassName('focus') ;
324
+ this.addClassName('blur');
325
+ }
326
+ },
327
+
328
+ _hasFocus: NO,
329
+
330
+ _EVTS: ['mousedown', 'mouseup', 'click', 'dblclick', 'keydown', 'keyup', 'keypress', 'mouseover', 'mouseout', 'mousemove', 'resize', 'unload', 'focus', 'blur'],
292
331
 
293
332
  _listenerCache: [],
294
333
 
295
334
  setup: function() {
296
- console.log('setup') ;
297
-
335
+
298
336
  // setup event listeners for window.
299
337
  var win = this ;
300
338
  win._EVTS.each(function(e) {
@@ -308,6 +346,8 @@ SC.window = SC.PaneView.extend({
308
346
  });
309
347
 
310
348
  this.get('size') ; // fetch the size from the window and save it.
349
+ this.set('isVisibleInWindow', true) ;
350
+ this._onfocus() ;
311
351
  }
312
352
  }).viewFor($tag('body')) ;
313
353
 
@@ -0,0 +1,328 @@
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_helpers 'core_views'
10
+
11
+ # This is the core button_view helper. Most other helpers in this file
12
+ # descend from this helper. If a helper is not provided that already
13
+ # builds the button you want, you can probably use this helper to
14
+ # construct it yourself.
15
+ #
16
+ # :enabled (bindable) =>
17
+ # If set to true, the button will be enabled.
18
+ #
19
+ # :selected (bindable) =>
20
+ # Set to true, false or :mixed. This will determine if the button
21
+ # appears selected. You can bind to this option but more often you will
22
+ # want to bind to :value.
23
+ #
24
+ # :default (bindable) =>
25
+ # Set to true to make this button the default button triggered when
26
+ # you press return while focused in a panel or form.
27
+ #
28
+ # :cancel (bindable) =>
29
+ # Set to true to make this button the one triggered when you press
30
+ # return while focused on a panel or form.
31
+ #
32
+ # :theme => :regular | :back | :checkbox | :radio | :square |
33
+ # (your own theme)
34
+ # Use this to set the theme appearance of the button. The SC theme
35
+ # comes with built-in support for the ones listed above or you can
36
+ # name your own. a CSS class name will be assigned to the button with
37
+ # this theme name.
38
+ #
39
+ # :behavior => :push, :toggle, :on, :off
40
+ # Specify the behavior of the button when pressed. The default is
41
+ # :push.
42
+ #
43
+ # :tag =>
44
+ # The tag name to use for the button. Defaults to 'a'. If the tag is
45
+ # 'a', an href="javascript:;" will be added automatically unless you
46
+ # specify an alternate.
47
+ #
48
+ # :href =>
49
+ # optional href to pass. Generall you don't want to pass this.
50
+ #
51
+ # :label =>
52
+ # The value of the label placed inside the button. You can alternately
53
+ # specify inner_html which will be used a the label. Note that the
54
+ # button_view generator automatically wraps your inner_html with a
55
+ # standard button structure unless you pass :label => false
56
+ #
57
+ # :image =>
58
+ # Renders an image tag on the outside of the label span. If this is
59
+ # set, then the wrapping tag will also have 'image' css class applied.
60
+ #
61
+ # :sprite => [resource_url, x-ofset, y-offset]
62
+ # Render an image sprite! The expected size of the sprite depends on
63
+ # the class name of the view. If the x-offset or y-offset are numbers
64
+ # they will be converted to "px". If this is set, then the wrapping
65
+ # tag will also have 'sprite' css class applied.
66
+ #
67
+ # Alternatively, name the CSS class you want assigned to the img for
68
+ # the sprite.
69
+ #
70
+ view_helper :button_view do
71
+ # JavaScript
72
+ property :enabled, :key => 'isEnabled'
73
+
74
+ property :action
75
+ property :target
76
+
77
+ #property(:action) { |v| "function(ev) { return #{v}(this, ev); }" }
78
+ property :default, :key => 'isDefault'
79
+ property :cancel, :key => 'isCancel'
80
+ property :value
81
+ property :theme
82
+ property :size
83
+ property :behavior, :key => 'buttonBehavior'
84
+ property :toggle_on_value
85
+ property :toggle_off_value
86
+
87
+ property :key_equivalent, :key => :keyEquivalent
88
+
89
+
90
+ property(:selected, :key => 'isSelected') do |x|
91
+ (x == :mixed) ? 'SC.MIXED_STATE' : x
92
+ end
93
+
94
+ view 'SC.ButtonView'
95
+
96
+ # HTML
97
+ var :title
98
+ var :label, @title || @inner_html || 'Submit'
99
+ var :tag, 'a'
100
+ var :theme, :regular
101
+ var :size, :normal
102
+
103
+ attribute(:href) { |x| (x.nil? && (@tag.downcase.to_s == 'a')) ? 'javascript:;' : nil }
104
+
105
+ # Add the theme to the CSS class.
106
+ css_class_names << 'sc-button-view'
107
+ css_class_names << @theme unless @theme.nil? || @theme == false
108
+ css_class_names << @size unless @size.nil? || @size == false
109
+
110
+ var :image
111
+ var :sprite
112
+
113
+ if @image
114
+ @image = %(<img src="#{@image}" />)
115
+ css_class_names << 'image'
116
+
117
+ elsif @sprite
118
+ img_url = self.blank_url
119
+
120
+ if @sprite.instance_of?(Array)
121
+ xoff = @sprite[1]
122
+ xoff = "#{xoff}px" if xoff.kind_of?(Numeric)
123
+
124
+ yoff = @sprite[2]
125
+ yoff = "#{yoff}px" if yoff.kind_of?(Numeric)
126
+
127
+ # render image part
128
+ @image = %(<img class="sprite" style="background: url(#{@sprite[0]}) no-repeat #{xoff} #{yoff};" src="#{img_url}" />)
129
+
130
+ else
131
+ @image = %(<img class="#{@sprite} sprite" src="#{img_url}" />)
132
+ end
133
+
134
+ end
135
+
136
+ # Generate some standard HTML for unless :label => false.
137
+ unless @label == false
138
+ # Button Width properties must be set on the inner label. To deal
139
+ # with this remove any width style properties from the parent element
140
+ # and append them to the inner label.
141
+ @label_style = []
142
+ css_styles.flatten!
143
+ css_styles.reject! do | part |
144
+ if part =~ /width:/
145
+ @label_style << part
146
+ true
147
+ else
148
+ false
149
+ end
150
+ end
151
+ if @label_style.size > 0
152
+ @label_style = %(style="#{@label_style * ' '}" )
153
+ else
154
+ @label_style = ''
155
+ end
156
+
157
+ # Avoid doing the normal thing for anchor tags.
158
+ @inner_html = %(<span class="button-inner">#{@image}<span #{@label_style}class="label">#{@label}</span></span>)
159
+
160
+ else
161
+ @inner_html = [@image,@inner_html] * ''
162
+ end
163
+
164
+ end
165
+
166
+
167
+
168
+ view_helper :popup_button_view, :wraps => :button_view do
169
+ parent_helper
170
+ property :menu, :key => :menuName
171
+ view 'SC.PopupButtonView'
172
+ end
173
+
174
+
175
+ # Renders a disclosure triangle.
176
+ view_helper :disclosure_view, :wraps => :button_view do
177
+ opts = { :theme => :disclosure }
178
+ opts[:label] = false if options[:label].nil?
179
+ parent_helper(opts)
180
+
181
+ view 'SC.DisclosureView'
182
+ @inner_html = [%(<img class="button" src="#{blank_url}" />)]
183
+ @inner_html << %(<span #{@label_style}class="label">#{@label}</span>) if @label
184
+ @inner_html = @inner_html.join('')
185
+
186
+ css_class_names << 'sc-disclosure-view'
187
+ end
188
+
189
+
190
+ # Renders a checkbox. If you pass a label this will render the label
191
+ # text next to the checkbox. Unlike button_view, passing no :label is
192
+ # the same as passing :label => false.
193
+ view_helper :checkbox_view, :wraps => :button_view do
194
+ opts = { :theme => :checkbox }
195
+ opts[:label] = false if options[:label].nil?
196
+ parent_helper(opts)
197
+
198
+ # provide some defaults to the JavaScript.
199
+ view 'SC.CheckboxView'
200
+
201
+ # render checkbox HTML.
202
+ css_class_names << 'sc-checkbox-view'
203
+
204
+ img_url = self.blank_url
205
+ @inner_html = [%(<img class="button" src="#{img_url}" />)]
206
+ @inner_html << %(<span #{@label_style}class="label">#{@label}</span>) if @label
207
+ @inner_html = @inner_html.join ''
208
+ end
209
+
210
+ # Renders a radio buton. If you pass a label this will render the label
211
+ # text next to the checkbox. Unlike button_view, passing no :label is
212
+ # the same as passing :label => false.
213
+ view_helper :radio_view, :wraps => :button_view do
214
+ opts = { :theme => :radio }
215
+ opts[:label] = false if options[:label].nil?
216
+ parent_helper(opts)
217
+
218
+ view 'SC.RadioView'
219
+
220
+ css_class_names << 'sc-radio-button-view'
221
+
222
+ # render checkbox HTML.
223
+ img_url = self.blank_url
224
+ @inner_html = [%(<img class="button" src="#{img_url}" />)]
225
+ @inner_html << %(<span #{@label_style}class="label">#{@label}</span>) if @label
226
+ @inner_html = @inner_html.join ''
227
+ end
228
+
229
+ # This renders a group of radio buttons. The buttons are controlled by
230
+ # a RadioGroupView that will map the value to a set of selection states.
231
+ #
232
+ # :values => [REQ]
233
+ # Set this to the values you want displayed in the radio buttons. You
234
+ # can pass an array here of strings or symbols, in which case these will
235
+ # be used as the values for the buttons and the names will be created
236
+ # from them. Or you can pass an array of arrays. The first items is
237
+ # the key value, the second item is the human readable value.
238
+ # Alternatively, you can set the inner_html of your view to include
239
+ # radio buttons as outlets. In this case, you must name the outlets
240
+ # :key_button.
241
+ #
242
+ # :layout => :horizontal | :vertical
243
+ # This will write out horizontal or vertical to the CSS class names so
244
+ # you can control the layout of your radio buttons.
245
+ #
246
+ # :width =>
247
+ # This will set the width of each item in the view.
248
+ #
249
+ # BINDABLE OPTIONS
250
+ #
251
+ # :value =>
252
+ # The current value of the radio buttons.
253
+ #
254
+ view_helper :radio_group_view do
255
+
256
+ #JavaScript
257
+ property :value
258
+ view 'SC.RadioGroupView'
259
+
260
+ # HTML
261
+
262
+ # get the layout mode.
263
+ var :layout, :vertical
264
+ css_class_names << 'sc-radio-group-view'
265
+ css_class_names << @layout if @layout
266
+
267
+ var :tag, 'span'
268
+
269
+ # If a set of values was passed, build the button views automatically.
270
+ var :values
271
+ if @values
272
+ # Get the width styles out of the main style to put into the
273
+ # individual radio items.
274
+ css_styles.flatten!
275
+ @label_styles = css_styles.reject { |p| !(p =~ /width:/) }
276
+ css_styles.reject! { |p| @label_styles.include?(p) }
277
+
278
+ if @label_styles.size > 0
279
+ @label_styles = %( style="#{@label_styles * ' '}" )
280
+ else
281
+ @label_styles = ''
282
+ end
283
+
284
+ # save off client_builder. The context this is run in later will
285
+ # not retain the client_builder
286
+ current_client_builder = self.client_builder
287
+ html = @values.map do | v |
288
+ v = [v].flatten
289
+ key = v.first
290
+ label = (v.size > 1) ? v[1] : key.to_s.humanize
291
+ render_source.radio_view(:outlet => true, :label => label, :style => @label_styles, :toggle_on_value => key, :toggle_off_value => nil, :client => self.client_builder)
292
+ end
293
+
294
+ @inner_html = html * "\n"
295
+ end
296
+ end
297
+
298
+ # Renders a slider view.
299
+ view_helper :slider_view do
300
+
301
+ property :minimum
302
+ property :maximum
303
+ property :step
304
+ view 'SC.SliderView'
305
+
306
+ css_class_names << 'sc-slider-view'
307
+
308
+ @label_style = []
309
+ css_styles.flatten!
310
+ css_styles.reject! do | part |
311
+ if part =~ /width:/
312
+ @label_style << part
313
+ true
314
+ else
315
+ false
316
+ end
317
+ end
318
+ if @label_style.size > 0
319
+ # subtract the extra space required
320
+ @label_style = @label_style.map { |x| x.gsub(/[0-9]+/,($1.to_i-48).to_s)}
321
+ @label_style = %(style="#{@label_style * ' '}" )
322
+ else
323
+ @label_style = ''
324
+ end
325
+
326
+ @inner_html = %(<span class="outer"><span #{@label_style} class="inner"></span><img src="#{self.blank_url}" class="sc-handle" /></span>)
327
+
328
+ end
@@ -0,0 +1,80 @@
1
+ ############################################################
2
+ # COLLECTION VIEW HELPERS
3
+ #
4
+ # Collection views render groups of views such as lists, tables, source lists,
5
+ # grids and so on. The view helpers here will make that easy.
6
+ #
7
+ #
8
+
9
+ require_helpers 'core_views'
10
+
11
+ # Base Helper for a collection view. Many times you will need
12
+ # your collection view to actually appear inside of a scroll_view. If
13
+ # this is the case, just pass :use_scroll_view => true.
14
+ #
15
+ # Note that many of the default views will set this to true by default.
16
+ #
17
+ view_helper :collection_view do
18
+ property :content
19
+ property :selection
20
+ property :toggle, :key => 'useToggleSelection'
21
+ property :selectable, :key => 'isSelectable'
22
+ property :enabled, :key => 'isEnabled'
23
+ property :act_on_select
24
+ property(:example_view) { |v| v }
25
+ property(:example_group_view) { |v| v }
26
+ property :content_value_key
27
+ property :group_visible_key
28
+ property :group_title_key
29
+ property :accepts_first_responder, true
30
+ property :can_reorder_content
31
+
32
+ property :content_icon_key
33
+
34
+ # Unless the developer passes something specific, automatically enable
35
+ # has_content_icon if either icon property is specified.
36
+ var :content_icon_key
37
+ property :has_content_icon, !!@content_icon_key
38
+
39
+ # Unless the developer passes something specific, automatically enable
40
+ # content branc if content_is_branch_property is defined.
41
+ var :content_is_branch_key
42
+ property :content_is_branch_key
43
+ property :has_content_branch, !!@content_is_branch_key
44
+
45
+ property :content_unread_count_key
46
+ property :content_action_key
47
+
48
+ property(:group, :key => 'groupBy') do |v|
49
+ "['#{Array(v) * "','" }']"
50
+ end
51
+
52
+ property(:action) { |v| "function(ev) { return #{v}(this, ev); }" }
53
+ view 'SC.CollectionView'
54
+
55
+ css_class_names << 'sc-collection-view'
56
+ end
57
+
58
+ view_helper :list_view, :extends => :collection_view do
59
+ property :row_height
60
+ view 'SC.ListView'
61
+ css_class_names << 'sc-list-view'
62
+ end
63
+
64
+ view_helper :grid_view, :extends => :collection_view do
65
+ property :row_height
66
+ property :column_width
67
+ view 'SC.GridView'
68
+ css_class_names << 'sc-grid-view'
69
+ end
70
+
71
+ view_helper :source_list_view, :extends => :collection_view do
72
+ view 'SC.SourceListView'
73
+ css_class_names << 'sc-source-list-view'
74
+ end
75
+
76
+ view_helper :table_view, :extends => :collection_view do
77
+ view 'SC.TableView'
78
+ css_class_names << 'sc-table-view'
79
+ end
80
+