Skip to content

Instantly share code, notes, and snippets.

@tim-evans
tim-evans / gist:1059059
Created July 1, 2011 17:48
RecordArray + ArrayController = :(
MyApp = {};
MyApp.store = SC.Store.create();
MyApp.Thing = SC.Record.extend({
primaryKey: 'name',
name: SC.Record.attr(String)
});
MyApp.thingController = SC.ArrayController.create({
@tim-evans
tim-evans / selectable_field.js
Created September 21, 2011 18:58
isSelected Binding
MO.SelectableFieldView = SC.View.extend({
content: null,
// ..........................................................
// VALIDATION
//
requiredFields: ['name'],
@tim-evans
tim-evans / gist:1320341
Created October 27, 2011 18:12
SC.CollectionView doesn't update layout when length changes
diff --git a/frameworks/desktop/views/collection.js b/frameworks/desktop/views/collection.js
index 4a1bd23..d8aff63 100644
--- a/frameworks/desktop/views/collection.js
+++ b/frameworks/desktop/views/collection.js
@@ -759,6 +759,7 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate, SC.CollectionConte
contentLengthDidChange: function() {
var content = this.get('content');
this.set('length', content ? content.get('length') : 0);
+ this.computeLayout();
},
@tim-evans
tim-evans / gist:1419818
Created December 1, 2011 20:59
hashFor & guidFor optimizations
diff --git a/frameworks/runtime/core.js b/frameworks/runtime/core.js
index 2d12957..4b553f4 100644
--- a/frameworks/runtime/core.js
+++ b/frameworks/runtime/core.js
@@ -316,8 +316,6 @@ SC.mixin(/** @scope window.SC.prototype */ {
guidKey: "SproutCore" + ( SC.VERSION + Math.random() ).replace( /\D/g, "" ),
// Used for guid generation...
- _guidPrefixes: {"number": "nu", "string": "st"},
- _guidCaches: {"number": {}, "string": {}},
@tim-evans
tim-evans / xmpp_data_source.js
Created December 21, 2011 19:13
SC.MultiplexedDataSource
XMPP = {};
// ...............................................
// Models
//
XMPP.BOSHConnection = SC.Record.extend({
primaryKey: 'jid',
jid: SC.Record.attr(String),
password: SC.Record.attr(String),
var B = {
foo: function () {
console.log("Foo B");
}
};
var A = SC.Object.extend(B, {
foo: function (original) {
console.log("Foo A");
original();
@tim-evans
tim-evans / xmpp_cascade_data_source.js
Created December 22, 2011 16:45
Cascade XMPP Data Source
XMPP = {};
// ...............................................
// Models
//
XMPP.BOSHConnection = SC.Record.extend({
primaryKey: 'jid',
jid: SC.Record.attr(String),
password: SC.Record.attr(String),
@tim-evans
tim-evans / range_start.js
Created January 6, 2012 15:26
IndexSet hinting bug
var hintSize = SC.IndexSet.HINT_SIZE,
start, set;
set = SC.IndexSet.create();
set.add(1);
set.add(hintSize + 1);
// Before adding 2,
// the internal data structure looks like:
@tim-evans
tim-evans / gist:1924750
Created February 27, 2012 15:38
SC Getting Started
getting_started
|`---- master [App just created using sc-init]
|`---- adding_states [App after adding states to the application]
.
.
.
|`---- add_a_data_source [App after adding a data source]
`---- backend_todos [App with statechart additions to make it talk to the backend]
@tim-evans
tim-evans / deploy.sh
Created February 27, 2012 17:08
SC Todos deploy script
#!/bin/sh
#
# Deploy script for hosting tagged versions of the todos app on github.
#
# Simply run ./deploy and it will checkout gh-pages, update it's references
# and create a directory (and built app) for each tag.
#
git checkout gh-pages
git reset --hard origin/master