Skip to content

Instantly share code, notes, and snippets.

// ==========================================================================
// Project: Currencyconverter.converterController
// Copyright: ©2009 My Company, Inc.
// ==========================================================================
/*globals Currencyconverter */
/** @class
Converts one form of currency to another.
// dynamically apply a mixin specified in an object property
var MyClass = SC.Object.extend({
extraMixin: null,
foo: "bar",
init: function() {
this.mixin(this.extraMixin);
arguments.callee.base.apply(this, arguments);
},
@tomdale
tomdale / gist:938930
Created April 23, 2011 20:12
How to override a label view render delegate
labelView: SC.LabelView.design({
layout: { centerX: 0, centerY: 0, width: 200, height: 18 },
textAlign: SC.ALIGN_CENTER,
tagName: "h1",
value: "Welcome to SproutCore!",
// Adds 'didClick' as a display property
displayProperties: ['didClick'],
didClick: NO,
contentView: SC.SourceListView.design({
contentBinding: 'Authoring.reportTemplatesArrayController.content',
selectionBinding: 'Authoring.reportTemplatesArrayController.selection',
exampleView: SC.View.design({
classNames: 'sc-list-item-view'.w(),
childViews: 'nameLabel'.w(),
/**
Add 'sel' class in render method.
*/
render: function(context) {
MyApp.MyObj = SC.Object.extend({
type: "isString",
isString: function() {
return this.get('type') === 'isString';
}.property('type')
});
{{#collection "App.FieldsView" tagName="ul"}}
{{#with content}}
testBoth('should fire observer that contains a path', function(get, set) {
var CarMixin = SC.Mixin.create({
acceleration: 0
});
var car = SC.mixin({}, CarMixin);
var tireAcceleration;
var TireMixin = SC.Mixin.create({
@tomdale
tomdale / gist:1134558
Created August 9, 2011 16:53
Load remote Handlebars templates
jQuery.get('/templates/foo.handlebars', function(data) {
var template = SC.Handlebars.compile(data);
SC.TEMPLATES['foo'] = template;
})
SC.Object.extend
name: SC.attr 'string', { option: 'foo' }
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
PROMPT='
%{$fg[green]%}%c \
$(git_prompt_info)\
%{$fg[red]%}%(!.#.»)%{$reset_color%} '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} '
@tomdale
tomdale / example.html
Created December 27, 2011 18:16 — forked from tdreyno/example.html
Live collection example in Ember
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Collection Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>