Skip to content

Instantly share code, notes, and snippets.

View mauritslamers's full-sized avatar

Maurits Lamers mauritslamers

  • Den Haag, Netherlands
View GitHub Profile
// Init
App = SC.Application.create({
store: SC.Store.create().from(SC.Record.fixtures)
});
App.Contact = SC.Record.extend({
firstName: SC.Record.attr(String, { key: 'first_name' }),
lastName: SC.Record.attr(String, { key: 'last_name' }),
age: SC.Record.attr(Number),
ageSlow: function() {

SproutCore - Build Tools

SproutCore is a platform for building native look-and-feel applications on the web. This Node JS library includes a copy of the SproutCore JavaScript framework as well as a Node JS-based build system called Build Tools.

Build Tools is a build system for creating static web content. You can supply the Build Tools with a collection of JavaScript, HTML, CSS and image files and it will combine the files into a bundle that are optimized for efficient, cached deliver directly from your server or using a CDN.

Some of the benefits of using the Build Tools versus assembling your own content include:

  • Easy maintenance. Organize your source content in a way that is useful for
<html>
<head>
<title>AudioPlayground</title>
<style>* {box-sizing: border-box;}</style>
</head>
<body>
<h3>AudioPlayground</h3>
<p>If you're happy and you know it, clap your hands!</p>
<script>
var Recording = function(cb){
// somewhere in your data source:
someMethod: function () {
SC.Request.getUrl('http://your.url.here').json().notify(this, this._myCallbackMethod).send();
},
_myCallbackMethod: function (result) {
if (SC.ok(result)){
// successfully retrieved
var myData = result.get('body');
// need to add destroy of internal cache on destroy...
SC.ManyArray.reopen({
// Set up observers.
contentDidChange: function() {
var observedRecords = this._observedRecords;
if (!observedRecords) observedRecords = this._observedRecords = [];
var record, i, len;
// If any items in observedRecords are not in content, stop observing them.
GX.itemController = SC.ObjectController.create({
invoiceVatBinding: 'GX.invoiceForItemController.hasVAT',
hasVAT: function(){
return this.get('invoiceVat');
}.property('invoiceVat')
});
GX.invoiceForItemController = SC.ObjectController.create({
contentBinding: "GX.itemController.invoice"
App.Choice = SC.Record.extend({
label: SC.Record.attr(String, { isRequired: YES }),
question: SC.Record.toOne("App.Question", { isMaster: NO })
});
App.Question = SC.Record.extend({
question: SC.Record.attr(String, { isRequired: YES }),
quiz: SC.Record.toOne("App.Quiz", { isMaster: NO }),
choices: SC.Record.toMany("App.Choice"),
correctAnswers: SC.Record.toMany("App.Choice")
My.coreStateChart = SC.Statechart.create({
rootState: SC.State.design({
initialSubstate: 'checkingState',
checkingState: SC.State.design({
enterState: function(){
return SC.Async.perform('isLoggedInCheck');
},
exitState: function() {
@mauritslamers
mauritslamers / main_page.js
Created May 18, 2011 11:22
rentalUnitController
ScHerestay.rentalUnitController = SC.ObjectController.create({
contentBinding: SC.Binding.single('ScHerestay.rentalUnitsController.selection')
});
Arrayobservers = SC.Application.create({
NAMESPACE: 'Arrayobservers',
VERSION: '0.1.0',
store: SC.Store.create().from(SC.Record.fixtures)
});