Skip to content

Instantly share code, notes, and snippets.

View johanvalcoog's full-sized avatar

Johan Valcoog johanvalcoog

  • PuurApps
  • Sweden
View GitHub Profile
uploadFile: function(file) {
var self = this,
vehicle = this.get('controller.content'),
photo = Case.VehiclePhoto.createRecord();
console.log(file.data);
photo.set('name', file.name);
photo.set('imageData', file.data);
photo.set('vehicleId', this.get('controller.content.id'));
@johanvalcoog
johanvalcoog / gist:3981496
Created October 30, 2012 16:53 — forked from tomdale/gist:3981133
Ember.js Router API v2

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
  <img src="masthead">
</header>

<footer>
@johanvalcoog
johanvalcoog / dev_view.coffee
Created October 15, 2012 05:57 — forked from charlesjolley/dev_view.coffee
Adding event locks to Ember
# example view implements a simple dragging for mouse events.
Wall.DevView = Ember.View.extend
mouseDown: (ev) ->
ev.dispatcher.lock @, 'mouseMove', 'mouseUp'
@_mouseDown = @$().offset()
@_mouseDown.pageX = ev.pageX
@_mouseDown.pageY = ev.pageY
@_mouseDown.dispatcher = ev.dispatcher
console.log 'mouseDown'
@johanvalcoog
johanvalcoog / dev_view.coffee
Created August 21, 2012 11:52 — forked from charlesjolley/dev_view.coffee
Adding event locks to Ember
# example view implements a simple dragging for mouse events.
Wall.DevView = Ember.View.extend
mouseDown: (ev) ->
ev.dispatcher.lock @, 'mouseMove', 'mouseUp'
@_mouseDown = @$().offset()
@_mouseDown.pageX = ev.pageX
@_mouseDown.pageY = ev.pageY
@_mouseDown.dispatcher = ev.dispatcher
console.log 'mouseDown'
@johanvalcoog
johanvalcoog / app.js
Created August 15, 2012 12:48 — forked from trek/app.js
EmberJS list control that can tell what was clicked
EvEditor = Em.Application.create({
main: { componentList:[{name:'a'},{name:'b'},{name:'c'}]
});
EvEditor.ApplicationController = Em.Controller.extend()
EvEditor.ApplicationView = Em.View.extend({
templateName: 'application'
});
EvEditor.ComponentListController = Ember.ArrayController.extend({
@johanvalcoog
johanvalcoog / mailapp.js
Created August 10, 2012 12:18
mail box example
Mail = Ember.Application.create();
// Let's pretend that Javascript can handle mutliline strings nicely:
Mail.ApplicationView = Ember.View.extend({
template: Ember.Handlebars.compile('
<!-- this gets replaced with content based on state when
connectOutlet is called on ApplicationController -->
{{outlet}}
')
@johanvalcoog
johanvalcoog / gist:2899699
Created June 9, 2012 05:59 — forked from sgharms/gist:2896428
Ember 0.9.8 and VIEW_PRESERVES_CONTEXT
The first time I dropped 0.9.8 in, I was immediately struck with the
thought: "HOLY ZEBULON PIKE ON A ZEBRA, NONE OF THE ITEMS IN Ember.CollectionViews
ARE SHOWING?!"
The change has to do with whether views render their templates using
themselves as the context, or whether it is inherited from the parent.
Alternatively said:
"it is trying to look up [...] properties on the view instead of the
parent context[TD]."
@johanvalcoog
johanvalcoog / gist:2781634
Created May 24, 2012 13:47 — forked from panayi/gist:2781592
Ember.js: Animating view with JQ.Animation mixin
JQ.Animate = Ember.Mixin.create({
cssProperties: ['background', 'backgroundAttachment', 'backgroundColor', 'backgroundImage', 'backgroundPosition',
'backgroundRepeat', 'border', 'borderBottom', 'borderBottomColor', 'borderBottomStyle', 'borderBottomWidth',
'borderColor', 'borderLeft', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRight', 'borderRightColor',
'borderRightStyle', 'borderRightWidth', 'borderStyle', 'borderTop', 'borderTopColor', 'borderTopStyle', 'borderTopWidth',
'borderWidth', 'clear', 'clip', 'color', 'cursor', 'display', 'filter', 'font', 'fontFamily', 'fontSize',
'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight', 'listStyle', 'listStyleImage',
'listStylePosition', 'listStyleType', 'margin', 'marginBottom', 'marginLeft', 'marginRight', 'marginTop', 'overflow',
'padding', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'pageBreakAfter', 'pageBreakBefore',
'position', 'styleFloat', 'textAlign', 'textDecoration'
@johanvalcoog
johanvalcoog / part1.md
Created May 18, 2012 04:33 — forked from practicingruby/part1.md
disciplined inheritance

Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.

Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi

{{#view Luh.Ui.TabMainView currentView="pane1"}}
{{#view Luh.Ui.TabPaneView id="pane1" class="content" viewName="pane1"}}
{{/view}}
{{#view Luh.Ui.TabPaneView id="pane2" class="content" viewName="pane2"}}
{{/view}}