Skip to content

Instantly share code, notes, and snippets.

/**
* Imagine if you will that the content of this controller is set to a bunch of MyApp.Person records. For whatever reason
* we don't want to pass those records as is to the controller or view using peopleController objects.
*/
MyApp.peopleController = SC.ArrayController.create({
// Override to provide the proper object for our consumer of peopleController objects.
objectAt: function (idx) {
var content = this.get('content'),
person,
@publickeating
publickeating / collection_column_delegate.js
Last active December 16, 2015 20:59
NOTE: This is depecrated. A much better solution has been implemented directly in SC.ListView using `layoutDirection: SC.LAYOUT_HORIZONTAL`.
// ==========================================================================
// Project: SC.CollectionColumnDelegate
// Copyright: ©2009 My Company, Inc.
// ==========================================================================
/*globals SC */
/**
@namespace
CollectionColumnDelegates are consulted by SC.HorizontalListView to
// ...
/**
A list of any attributes that are expected to be empty when the record
is initially loaded.
This property is very useful for working with partially loaded records in
order to efficiently bring in the full data only when necessary.
# What is a partially loaded record?
@publickeating
publickeating / app_statechart.js
Last active December 17, 2015 11:28
How I would design a SproutCore application statechart and how I would lock actions/events down to the current state. Remember, there is only ever one effective state in the entire application! The effective state is formed from the current chain of substates starting at the root state. Other than the root state alone, no single substate can be …
MyApp.statechart = SC.Statechart.create({
// Root state
rootState: SC.State.design({
// Properties
initialSubstate: 'loggedOutState',
// Actions & Events
@publickeating
publickeating / anchor_view.js
Created May 23, 2013 19:24
A proposed SC.AnchorView addition.
// ==========================================================================
// Project: SproutCore
// Copyright: ©2012 7x7 Software, Inc.
// License: Licensed under MIT license
// ==========================================================================
/**
@class
MyApp.Group = SC.Record.extend({
name: SC.Record.attr(String),
people: function () {
var query,
ret;
query = SC.Query.local(MyApp.Person, {
conditions: 'group = {self}',
MyApp.SectionState = SC.State.extend({
initialSubstate: 'noCategory',
noCategory: SC.State.extend({
representRoute: 'sections/:section_id',
enterState: function (context) {
var section = context.section;
@publickeating
publickeating / file_input_view.js
Created April 11, 2014 13:23
A simple file input with options for multiple and accept attributes as well as drag & drop.
// ==========================================================================
// Project: SproutCore
// Copyright: ©2013 7x7 Software, Inc.
// License: Licensed under MIT license
// ==========================================================================
/*global SC */
/** @class
*/
# ruby phonegap-sc.rb -a alfresco -o ../output/path
require 'fileutils'
require 'pathname'
require 'optparse'
config = {}
argparser = OptionParser.new {|opts|
opts.on('-a', '--application-name [name]', "The application name (required)"){|name|
config[:app_name] = name
}
@publickeating
publickeating / gist:11295500
Created April 25, 2014 16:34
array_controller+proxy_items.js
SC.ArrayController.reopen({
proxyItem: null,
indexOf: function (object, startAt) {
var content = this._scac_observableContent();
if (this.proxyItem) {
object = object.get('content');
}