Skip to content

Instantly share code, notes, and snippets.

@publickeating
publickeating / basic_form.js
Created November 18, 2014 15:05
Basic SproutCore Form
myForm: SC.View.extend({
childViews: ['nameLabel', 'givenNameField', 'familyNameField', 'imageField', 'phoneLabel', 'phoneField', // ... etc. ],
// To save us the trouble of offsetting each view independently, we use a child layout plugin that stacks them vertically.
childViewLayout: SC.View.VERTICAL_STACK,
childViewLayoutOptions: { paddingBefore: 35, paddingAfter: 35, spacing: 14 },
nameLabel: SC.LabelView.extend({
classNames: ['form-label'],
layout: { left: 20, height: 20 },
@publickeating
publickeating / CustomItemView.js
Last active August 29, 2015 14:01
This is an example of a custom item view that contains childViews.
// Note: by mixing in SC.ContentDisplay, we get `content` added as a displayProperty
MyApp.CustomItemView = SC.View.extend(SC.ContentDisplay, {
// ---------------------------------------------------------------------------
// Properties
//
classNames: ['custom-item-view'],
content: null,
@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');
}
# 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 / 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
*/
MyApp.SectionState = SC.State.extend({
initialSubstate: 'noCategory',
noCategory: SC.State.extend({
representRoute: 'sections/:section_id',
enterState: function (context) {
var section = context.section;
MyApp.Group = SC.Record.extend({
name: SC.Record.attr(String),
people: function () {
var query,
ret;
query = SC.Query.local(MyApp.Person, {
conditions: 'group = {self}',
@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
@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
// ...
/**
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?