Skip to content

Instantly share code, notes, and snippets.

@tim-evans
tim-evans / gist:1942816
Created February 29, 2012 17:37
Separating views
commit b9dc87d66c0606908b3199e08ce261e2425d1ef6
Author: Tim Evans <tim.evans@junctionnetworks.com>
Date: Wed Feb 29 12:36:06 2012 -0500
separated views into their own files for reuse
diff --git a/apps/todos_two/resources/main_page.js b/apps/todos_two/resources/main_page.js
index e5d620b..c17be8d 100644
--- a/apps/todos_two/resources/main_page.js
+++ b/apps/todos_two/resources/main_page.js
@tim-evans
tim-evans / starting.js
Created February 29, 2012 17:50
starting state
TodosThree.STARTING = SC.State.extend({
enterState: function () {
if (SC.instanceOf(TodosTwo.store.dataSource, SC.FixturesDataSource)) {
this.gotoState('LOADING_DATA');
} else {
this.gotoState('LOGGING_IN');
}
},
@tim-evans
tim-evans / tween.js
Created March 9, 2012 13:52
CSS3 Transitions shim
var getStyle = function (el, name) {
var style;
if (el.currentStyle) {
style = el.currentStyle[name];
} else if (window.getComputedStyle) {
style = document.defaultView.getComputedStyle(el, null).getPropertyValue(name);
}
return style;
};
@tim-evans
tim-evans / gist:2695836
Created May 14, 2012 19:21
SC.ObjectController example
MyApp = {};
MyApp.myController = SC.ObjectController.create({
content: SC.Object.create({
proxiedName: 'Bruce Wayne',
maskedName: 'Bats'
}),
maskedName: 'Batman'
});
@tim-evans
tim-evans / autoscroll_text_support.js
Created July 16, 2012 16:46
Text selection scrolling in SC.ScrollView
SC.AutoScrollTextSupport = {
scrollView: function () {
var view = this.get('parentView');
while (view && !view.isScrollable) {
view = view.get('parentView');
}
return view;
@tim-evans
tim-evans / scheduler.js
Created July 18, 2012 19:41
SC animation scheduler
SC._animationBuffer = [];
/**
If you try to animate a view that was previously
`isVisible`: `NO`, you have to set the view to be
`isVisible`: `YES`, then at the *next* run loop,
try to animate the view, but only after forcing
the browser to repaint the view.
This function does all that for you, albeit
@tim-evans
tim-evans / autosave.js
Created June 14, 2013 16:03
Autosave pattern for Ember with Ember Data
(function () {
// Implement debounce until backburner implements a proper debounce
var debouncees = [],
pop = Array.prototype.pop;
var debounce = function (target, method /*, args, wait */) {
var self = Ember.run.backburner,
args = arguments,
wait = pop.call(args),
@tim-evans
tim-evans / t.js
Last active December 19, 2015 18:58
/**
The `{{t}}` helper renders a localized string using `I18n.t`.
```handlebars
{{t "app.hello_world"}}
```
```html
Hello, World!
```
/**
The `{{l}}` helper renders a localized string using `I18n.l`.
```handlebars
{{l "percentage" value=123.45}}
```
```html
123.450%
```
<a href="/inventory" id="inventory">Inventory</a>
{{#dropdown-menu for="inventory"}}
<a {{action "addArtwork"}} tabindex="0">Add Artwork</a>
{{/dropdown-menu}}