mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-20 12:20:37 +08:00
Initial ember.js declarations and tests
This commit is contained in:
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for Ember.js 1.0
|
||||
// Project: http://emberjs.com/
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
module Em {
|
||||
|
||||
// $;
|
||||
export function A(arr?: any[]): NativeArray;
|
||||
export function addListener(obj: any, eventName: string, targetOrMethod: any, method: any): void;
|
||||
export function alias(methodName: Descriptor): Alias;
|
||||
export function assert(desc: string, test: bool): void;
|
||||
export function beforeObserver(func: Function, propertyNames: string): Function;
|
||||
export function bind(obj: any, to: string, from: string): Binding;
|
||||
export function cacheFor(obj: any, key: string): void;
|
||||
|
||||
|
||||
export interface Alias {
|
||||
}
|
||||
|
||||
class Application {
|
||||
static create(): Application;
|
||||
MyView: View;
|
||||
}
|
||||
|
||||
export interface ArrayController {
|
||||
}
|
||||
|
||||
export interface Binding {
|
||||
}
|
||||
|
||||
export interface Descriptor {
|
||||
}
|
||||
|
||||
export interface NativeArray {
|
||||
activate(): void;
|
||||
}
|
||||
|
||||
export interface Object {
|
||||
}
|
||||
|
||||
export class View {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/// <reference path="../Definitions/ember-1.0.d.ts" />
|
||||
|
||||
var App;
|
||||
|
||||
App = Em.Application.create();
|
||||
|
||||
App.MyView = Em.View.extend({
|
||||
mouseDown: function() {
|
||||
window.alert("hello world!");
|
||||
});
|
||||
|
||||
class MyView extends Em.View {
|
||||
mouseDown() {
|
||||
window.alert("hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
App.Person = DS.Model.extend({
|
||||
firstName: DS.attr('string'),
|
||||
lastName: DS.attr('string'),
|
||||
fullName: function() {
|
||||
return this.get('firstName') +
|
||||
" " + this.get('lastName');
|
||||
}.property('firstName', 'lastName')
|
||||
});
|
||||
App.peopleController = Em.ArrayController.create({
|
||||
content: App.Person.findAll()
|
||||
});
|
||||
|
||||
App.president = Ember.Object.create({
|
||||
name: "Barack Obama"
|
||||
});
|
||||
App.country = Ember.Object.create({
|
||||
presidentNameBinding: 'App.president.name'
|
||||
});
|
||||
App.country.get('presidentName');
|
||||
|
||||
App.president = Ember.Object.create({
|
||||
firstName: "Barack",
|
||||
lastName: "Obama",
|
||||
fullName: function() {
|
||||
return this.get('firstName') + ' ' + this.get('lastName');
|
||||
}.property()
|
||||
});
|
||||
App.president.get('fullName');
|
||||
|
||||
App.president = Ember.Object.create({
|
||||
firstName: "Barack",
|
||||
lastName: "Obama",
|
||||
fullName: function() {
|
||||
return this.get('firstName') + ' ' + this.get('lastName');
|
||||
}.property('firstName', 'lastName')
|
||||
});
|
||||
|
||||
App.PaintSample = Ember.Object.extend({
|
||||
color: 'red',
|
||||
colour: Ember.alias('color'),
|
||||
name: function () {
|
||||
return "Zed";
|
||||
},
|
||||
moniker: Ember.alias("name")
|
||||
});
|
||||
var paintSample = App.PaintSample.create();
|
||||
paintSample.get('colour');
|
||||
paintSample.moniker();
|
||||
|
||||
Ember.assert('Must pass a valid object', obj);
|
||||
Ember.assert('This code path should never be run');
|
||||
Reference in New Issue
Block a user