Skip to content

Instantly share code, notes, and snippets.

View ColinCampbell's full-sized avatar

Colin Campbell ColinCampbell

View GitHub Profile
var query = SC.Query.local(MyApp.Record);
var data = MyApp.store.find(query);
// old way
var f = function() {
if (data.get('status') & SC.Record.READY) {
data.removeObserver('status', this, f);
// ...
}
};
// apps/test/controllers/display.js
Test.displayController = SC.ObjectController.extend({
nowShowing: 'Test.mainPage.displayView',
showDisplayView: function() {
this.set('nowShowing', 'Test.mainPage.displayView');
},
showCodeView: function() {
addFiniteObserver: function(key, target, method, context){
// normalize. if a function is passed to target, make it the method.
if (method === undefined) {
method = target; target = this ;
}
if (!target) target = this ;
if (typeof method === "string") method = target[method] ;
if (!method) throw "You must pass a method to addObserver()" ;
// setting up an observer
var query = SC.Query.local(MyApp.Record);
var data = MyApp.store.find(query);
var f = function(data) {
if (data.get('status') & SC.Record.READY) {
// data is ready
return YES;
}
volumeCount: SC.FormView.row(SC.LabelView, {
layout: {height: 18, width: 50},
label: 'RANDOM'
})
// this gets passed through to:
row: function(label, fieldType, ext)
{
if (label.isClass) {
ext = fieldType;
project/
apps/
project/
Buildfile
frameworks/
table/
config :all, :required => ['sproutcore', 'table']
var stagger = 0;
var top = 25;
layer.append('<div class="markingLabel" style="width:125px;height:auto;position:absolute;left:' + Number(offset.left - 62.5) + 'px;top:' + Number(top+stagger) + 'px;color:#000000;">'+label+'</div>');
MyApp.MyObject = SC.Object.extend({
property: value;
computedProperty: function(){
return this.get('property') === "foo";
}.property('property'),
setProperty: function(value){
this.set('property',value);
extend: function(ext) {
var ret = SC.mixin(SC.beget(this), ext),
key, value, cur;
for(key in ret) {
value = ret[key];
if (value instanceof Function && !value.superclass && (value !== (cur=this[key]))) {
value.superclass = value.base = cur;
}
}
lessed.each_line {|line|
final += line.gsub(/url\('data:image\/(gif|png);base64,(.*?)'\)/) do |match|
"url('data:image/" + $1 + ";base64," + $2.gsub(" ", "+") + "')"
end
}