Permalink
Browse files

Squash merge okito/collection work

  • Loading branch information...
Charles Jolley
Charles Jolley committed May 15, 2009
1 parent 7e0036b commit c8a287ab8b2518f19addf67053704ae1f95aef79
Showing with 10,070 additions and 2,741 deletions.
  1. +1 −0 Buildfile
  2. +4,848 −0 design/CollectionView State Charts.graffle
  3. +21 −4 frameworks/datastore/system/store.js
  4. +145 −0 frameworks/desktop/mixins/collection_content_delegate.js
  5. +0 −22 frameworks/desktop/mixins/collection_item.js
  6. +61 −0 frameworks/desktop/mixins/collection_row_delegate.js
  7. +73 −30 frameworks/desktop/mixins/collection_view_delegate.js
  8. +168 −0 frameworks/desktop/private/tree_array.js
  9. +269 −0 frameworks/desktop/tests/views/collection/content.js
  10. +82 −0 frameworks/desktop/tests/views/collection/deleteSelection.js
  11. +199 −0 frameworks/desktop/tests/views/collection/deselect.js
  12. +240 −0 frameworks/desktop/tests/views/collection/itemViewForContentIndex.js
  13. +65 −0 frameworks/desktop/tests/views/collection/layerIdFor.js
  14. +88 −0 frameworks/desktop/tests/views/collection/length.js
  15. +163 −0 frameworks/desktop/tests/views/collection/mouse.js
  16. +121 −0 frameworks/desktop/tests/views/collection/nowShowing.js
  17. +177 −0 frameworks/desktop/tests/views/collection/reload.js
  18. +240 −0 frameworks/desktop/tests/views/collection/select.js
  19. +191 −0 frameworks/desktop/tests/views/collection/selectNextItem.js
  20. +197 −39 frameworks/desktop/tests/views/collection/selectPreviousItem.js
  21. +141 −0 frameworks/desktop/tests/views/collection/selection.js
  22. +182 −0 frameworks/desktop/tests/views/collection/ui_diagram.js
  23. +0 −10 frameworks/desktop/tests/views/list/methods.js
  24. +183 −0 frameworks/desktop/tests/views/list/rowDelegate.js
  25. +0 −110 frameworks/desktop/tests/views/list/ui.js
  26. +167 −0 frameworks/desktop/tests/views/list/ui_row_heights.js
  27. +127 −0 frameworks/desktop/tests/views/list/ui_simple.js
  28. +231 −0 frameworks/desktop/tests/views/stacked/ui_comments.js
  29. +1,240 −809 frameworks/desktop/views/collection.js
  30. +272 −590 frameworks/desktop/views/list.js
  31. +2 −4 frameworks/desktop/views/list_item.js
  32. +11 −5 frameworks/desktop/views/scroller.js
  33. +14 −1,090 frameworks/desktop/views/source_list.js
  34. +101 −0 frameworks/desktop/views/stacked.js
  35. +14 −2 frameworks/foundation/debug/control_test_pane.js
  36. +2 −0 frameworks/foundation/mixins/selection_support.js
  37. +2 −2 frameworks/foundation/system/event.js
  38. +0 −2 frameworks/foundation/views/view.js
  39. +10 −9 frameworks/runtime/core.js
  40. +3 −3 frameworks/runtime/mixins/observable.js
  41. +3 −3 frameworks/runtime/system/binding.js
  42. +0 −2 frameworks/runtime/system/index_set.js
  43. +2 −0 frameworks/runtime/system/range_observer.js
  44. +13 −4 frameworks/runtime/system/run_loop.js
  45. +1 −1 frameworks/runtime/system/set.js
View
@@ -61,3 +61,4 @@ config :standard_theme,
%w(tests docs).each do |app_target|
config app_target, :required => [:desktop], :theme => :standard_theme
end
+

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -95,12 +95,17 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
store.commitChanges().destroy();
}}}
+ @param {Hash} attrs optional attributes to set on new store
@returns {SC.NestedStore} new nested store chained to receiver
*/
- chain: function() {
- var ret = SC.NestedStore.create({ parentStore: this }) ;
- var nested = this.nestedStores;
- if (!nested) nested =this.nestedStores = [];
+ chain: function(attrs) {
+ if (!attrs) attrs = {};
+ attrs.parentStore = this;
+
+ var ret = SC.NestedStore.create(attrs),
+ nested = this.nestedStores;
+
+ if (!nested) nested = this.nestedStores = [];
nested.push(ret);
return ret ;
},
@@ -119,6 +124,18 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
return this ;
},
+ /**
+ Used to determine if a nested store belongs directly or indirectly to the
+ receiver.
+
+ @param {SC.Store} store store instance
+ @returns {Boolean} YES if belongs
+ */
+ hasNestedStore: function(store) {
+ while(store && (store !== this)) store = store.get('parentStore');
+ return store === this ;
+ },
+
// ..........................................................
// SHARED DATA STRUCTURES
//
@@ -0,0 +1,145 @@
+// ==========================================================================
+// Project: SproutCore - JavaScript Application Framework
+// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
+// Portions ©2008-2009 Apple, Inc. All rights reserved.
+// License: Licened under MIT license (see license.js)
+// ==========================================================================
+
+
+/**
+ Used for contentIndexDisclosureState(). Indicates open branch node.
+*/
+SC.BRANCH_OPEN = 0x0011;
+
+/**
+ Used for contentIndexDisclosureState(). Indicates closed branch node.
+*/
+SC.BRANCH_CLOSED = 0x0012;
+
+/**
+ Used for contentIndexDisclosureState(). Indicates leaf node.
+*/
+SC.LEAF_NODE = 0x0020;
+
+/**
+ @namespace
+
+ This mixin provides standard methods used by a CollectionView to provide
+ additional meta-data about content in a collection view such as selection
+ or enabled state.
+
+ You can apply this mixin to a class that you set as a delegate or to the
+ object you set as content. SC.ArrayControllers automatically implement
+ this mixin.
+
+ @since SproutCore 1.0
+*/
+SC.CollectionContentDelegate = {
+
+ /**
+ Used to detect the mixin by SC.CollectionView
+ */
+ isCollectionContent: YES,
+
+ /**
+ Return YES if the content index should be selected. Default behavior
+ looks at the selection property on the view.
+
+ @param {SC.CollectionView} view the collection view
+ @param {SC.Array} content the content object
+ @param {Number} idx the content index
+ @returns {Boolean} YES, NO, or SC.MIXED_STATE
+ */
+ contentIndexIsSelected: function(view, content, idx) {
+ var sel = view.get('selection');
+ return sel ? sel.contains(content, idx) : NO ;
+ },
+
+ /**
+ Returns YES if the content index should be enabled. Default looks at the
+ isEnabled state of the collection view.
+ looks at the selection property on the view.
+
+ @param {SC.CollectionView} view the collection view
+ @param {SC.Array} content the content object
+ @param {Number} idx the content index
+ @returns {Boolean} YES, NO, or SC.MIXED_STATE
+ */
+ contentIndexIsEnabled: function(view, content, idx) {
+ return view.get('isEnabled');
+ },
+
+ // ..........................................................
+ // GROUPING
+ //
+
+ /**
+ Optionally return an index set containing the indexes that may be group
+ views. For each group view, the delegate will actually be asked to
+ confirm the view is a group using the contentIndexIsGroup() method.
+
+ If grouping is not enabled, return null.
+
+ @param {SC.CollectionView} view the calling view
+ @param {SC.Array} content the content object
+ @return {SC.IndexSet}
+ */
+ contentGroupIndexes: function(view, content) {
+ return null;
+ },
+
+ /**
+ Returns YES if the item at the specified content index should be rendered
+ using the groupExampleView instead of the regular exampleView. Note that
+ a group view is different from a branch/leaf view. Group views often
+ appear with different layout and a different look and feel.
+
+ Default always returns NO.
+
+ @param {SC.CollectionView} view the collection view
+ @param {SC.Array} content the content object
+ @param {Number} idx the content index
+ @returns {Boolean} YES, NO, or SC.MIXED_STATE
+ */
+ contentIndexIsGroup: function(view, content, idx) {
+ return NO ;
+ },
+
+ // ..........................................................
+ // OUTLINE VIEWS
+ //
+
+ /**
+ Returns the outline level for the item at the specified index. Can be
+ used to display hierarchical lists.
+
+ Default always returns 0 (top level).
+
+ @param {SC.CollectionView} view the collection view
+ @param {SC.Array} content the content object
+ @param {Number} idx the content index
+ @returns {Boolean} YES, NO, or SC.MIXED_STATE
+ */
+ contentIndexOutlineLevel: function(view, content, idx) {
+ return 0;
+ },
+
+ /**
+ Returns a constant indicating the disclosure state of the item. Must be
+ one of SC.BRANCH_OPEN, SC.BRANCH_CLOSED, SC.LEAF_NODE. If you return one
+ of the BRANCH options then the item may be rendered with a disclosure
+ triangle open or closed. If you return SC.LEAF_NODe then the item will
+ be rendered as a leaf node.
+
+ Default returns SC.LEAF_NODE.
+
+ @param {SC.CollectionView} view the collection view
+ @param {SC.Array} content the content object
+ @param {Number} idx the content index
+ @returns {Boolean} YES, NO, or SC.MIXED_STATE
+ */
+ contentIndexDisclosureState: function(view, content, idx) {
+ return SC.LEAF_NODE;
+ }
+
+};
@@ -1,22 +0,0 @@
-// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
-// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
-// Portions ©2008-2009 Apple, Inc. All rights reserved.
-// License: Licened under MIT license (see license.js)
-// ==========================================================================
-
-/**
- @namespace
-
- TODO: Add full description of SC.CollectionItem
-
- Any view you want to use as an item view in a collection must include this
- mixin.
-
- @since SproutCore 1.0
-*/
-SC.CollectionItem = {
-
- classNames: ['sc-collection-item']
-
-};
@@ -0,0 +1,61 @@
+// ==========================================================================
+// Project: SproutCore - JavaScript Application Framework
+// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
+// Portions ©2008-2009 Apple, Inc. All rights reserved.
+// License: Licened under MIT license (see license.js)
+// ==========================================================================
+
+
+
+/**
+ @namespace
+
+ CollectionRowDelegates are consulted by SC.ListView and SC.TableView to
+ control the height of rows, including specifying custom heights for
+ specific rows.
+
+ You can implement a custom row height in one of two ways.
+
+*/
+SC.CollectionRowDelegate = {
+
+ /** walk like a duck */
+ isCollectionRowDelegate: YES,
+
+ /**
+ Default row height. Unless you implement some custom row height
+ support, this row height will be used for all items.
+
+ @property
+ @type Number
+ */
+ rowHeight: 18,
+
+ /**
+ Index set of rows that should have a custom row height. If you need
+ certains rows to have a custom row height, then set this property to a
+ non-null value. Otherwise leave it blank to disable custom row heights.
+
+ @property
+ @type SC.IndexSet
+ */
+ customRowHeightIndexes: null,
+
+ /**
+ Called for each index in the customRowHeightIndexes set to get the
+ actual row height for the index. This method should return the default
+ rowHeight if you don't want the row to have a custom height.
+
+ The default implementation just returns the default rowHeight.
+
+ @param {SC.CollectionView} view the calling view
+ @param {Object} content the content array
+ @param {Number} contentIndex the index
+ @returns {Number} row height
+ */
+ contentIndexRowHeight: function(view, content, contentIndex) {
+ return this.get('rowHeight');
+ }
+
+
+};
Oops, something went wrong.

0 comments on commit c8a287a

Please sign in to comment.