1 // ==========================================================================
  2 // Project:   Showcase
  3 // Copyright: ©2012 7x7 Software, Inc.
  4 // License:   Licensed under MIT license
  5 // ==========================================================================
  6 /*globals Showcase */
  7 
  8 
  9 /**
 10 
 11   The Showcase application is used to highlight the many components of
 12   SproutCore.  You can visit the live site at http://showcase.sproutcore.com.
 13 
 14   @extends SC.Application
 15 */
 16 Showcase = SC.Application.create(
 17   /** @scope Showcase.prototype */ {
 18 
 19   NAMESPACE: 'Showcase',
 20 
 21   VERSION: '0.1.0',
 22 
 23   // Used by the List and Grid view examples.
 24   collectionItems: function() {
 25     var collectionItems = [],
 26         icons = ['sc-icon-alert-24', 'sc-icon-bookmark-24', 'sc-icon-cancel-24', 'sc-icon-document-24', 'sc-icon-down-24', 'sc-icon-favorite-24', 'sc-icon-folder-24', 'sc-icon-group-24', 'sc-icon-help-24', 'sc-icon-info-24', 'sc-icon-left-24', 'sc-icon-options-24', 'sc-icon-redo-24', 'sc-icon-right-24', 'sc-icon-tools-24', 'sc-icon-trash-24', 'sc-icon-undo-24', 'sc-icon-up-24', 'sc-icon-user-24' ];
 27 
 28     for (var i = 0, len = icons.length; i < len; i++) {
 29       var icon = icons[i];
 30       collectionItems.push(SC.Object.create({
 31         icon: icon, title: icon, isSelected: false, rightIcon: 'sc-icon-help-16'
 32       }));
 33     }
 34 
 35     return collectionItems;
 36   }.property().cacheable(),
 37 
 38   collectionItemSelection: null,
 39 
 40   editableCollectionItems: function() {
 41     var collectionItems = this.get('collectionItems');
 42 
 43     return SC.copy(collectionItems, true);
 44   }.property().cacheable(),
 45 
 46   // Used by the SourceList view example.
 47   sourceListTree: function() {
 48     var sourceListTree;
 49 
 50     sourceListTree = SC.TreeItemObserver.create({
 51       delegate: this,
 52       item: SC.Object.create({
 53         treeItemIsExpanded: true,
 54         treeItemChildren: [
 55           SC.Object.create({
 56             treeItemIsExpanded: true,
 57             group: true,
 58             groupName: "Mission Control",
 59             treeItemChildren: [
 60               SC.Object.create({
 61                 name: 'Warnings',
 62                 icon: 'sc-icon-alert-16',
 63                 count: 2
 64               }),
 65               SC.Object.create({
 66                 name: 'Notices',
 67                 icon: 'sc-icon-info-16',
 68                 count: 15
 69               })
 70             ]
 71           }),
 72           SC.Object.create({
 73             treeItemIsExpanded: false,
 74             group: true,
 75             groupName: "Administration",
 76             treeItemChildren: [
 77               SC.Object.create({
 78                 name: 'Tag Management',
 79                 icon: 'sc-icon-bookmark-16'
 80               }),
 81               SC.Object.create({
 82                 name: 'Users',
 83                 icon: 'sc-icon-user-16'
 84               }),
 85               SC.Object.create({
 86                 name: 'CRM Default Options'
 87               }),
 88               SC.Object.create({
 89                 name: 'Document Settings',
 90                 icon: 'sc-icon-document-16'
 91               }),
 92               SC.Object.create({
 93                 name: 'Directory Structure',
 94                 icon: 'sc-icon-folder-16'
 95               })
 96             ]
 97           }),
 98           SC.Object.create({
 99             treeItemIsExpanded: true,
100             group: true,
101             groupName: "Games",
102             treeItemChildren: [
103               SC.Object.create({
104                 name: 'Tunnel of Like',
105                 icon: 'sc-icon-favorite-16'
106               }),
107               SC.Object.create({
108                 name: 'Squirbo!',
109                 icon: 'sc-icon-group-16'
110               }),
111               SC.Object.create({
112                 treeItemIsExpanded: true,
113                 group: true,
114                 name: "Puzzles",
115                 treeItemChildren: [
116                    SC.Object.create({
117                     name: 'Flashpoint'
118                   }),
119                    SC.Object.create({
120                     name: 'Weezaxo 3'
121                   })
122                 ]
123               }),
124               SC.Object.create({
125                 name: 'Trasholis',
126                 icon: 'sc-icon-trash-16'
127               })
128             ]
129           }),
130           SC.Object.create({
131             name: 'Help',
132             icon: 'sc-icon-help-16'
133           })
134         ]
135       })
136     });
137 
138     return sourceListTree;
139   }.property().cacheable(),
140 
141   treeItemIsExpandedKey: "treeItemIsExpanded",
142 
143   treeItemChildrenKey: "treeItemChildren",
144 
145   treeItemIsGrouped: true,
146 
147   // Used by the Tab views.
148   blueTabView: SC.LabelView.extend({  classNames:['blue-tab-view', 'tab-view'],  value: 'Blue View'  }),
149   greenTabView: SC.LabelView.extend({  classNames:['green-tab-view', 'tab-view'],  value: 'Green View'  }),
150   pinkTabView: SC.LabelView.extend({  classNames:['pink-tab-view', 'tab-view'],  value: 'Pink View'  }),
151   grayTabView: SC.LabelView.extend({  classNames:['gray-tab-view', 'tab-view'],  value: 'Gray View'  }),
152   orangeTabView: SC.LabelView.extend({  classNames:['orange-tab-view', 'tab-view'],  value: 'Orange View'  }),
153   purpleTabView: SC.LabelView.extend({  classNames:['purple-tab-view', 'tab-view'],  value: 'Purple View'  }),
154   redTabView: SC.LabelView.extend({  classNames:['red-tab-view', 'tab-view'],  value: 'Red View'  }),
155 
156   store: SC.Store.create().from(SC.Record.fixtures),
157 
158   /**
159     Our simple route handler.  This will be called whenever the URL changes
160     directly or on reload.
161    */
162   route: function(route) {
163     var object,
164       section;
165 
166     section = Showcase.sources.get('treeItemChildren').findProperty('subpath', route.section);
167     object = section.get('treeItemChildren').findProperty('name', route.key);
168 
169     Showcase.sourceTreeController.selectObject(object);
170   }
171 
172 });
173