Move all packages to a types directory

This commit is contained in:
Andy Hanson
2017-03-24 14:27:52 -07:00
parent f9869dc191
commit 354cec620d
13846 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import * as Backbone from 'backbone';
// Example code.
class DisplayView extends Backbone.View<Backbone.Model> {
constructor(options?: Backbone.ViewOptions<Backbone.Model>) {
super(options);
this.manage = true;
this.template = "#display";
}
manage: boolean;
template: string;
}
// Create a View to be used with the Layout below.
class View extends Backbone.Layout<Backbone.Model> {
constructor(options?: Backbone.LayoutOptions<Backbone.Model>) {
super(options);
this.template = "#view";
// When you click the View contents, it will wrap them in a bold tag.
this.events = <any>{
"click": "wrapElement",
"mouseenter": "insertElement",
"mouseleave": "removeElement"
}
}
wrapElement(): void {
this.$el.wrap("<b>");
}
insertElement(): void {
this.insertView(new DisplayView()).render();
}
removeElement(): void {
// Removes the inserted DisplayView.
this.removeView("");
}
}
// Create a new Layout.
var layout = new Backbone.Layout<Backbone.Model>({
// Attach the Layout to the main container.
el: ".main",
// Use the previous defined template.
template: "#layout",
// Declaratively bind a nested View to the Layout.
views: {
"p": new View()
}
});
// Render the Layout.
layout.render();

56
types/backbone.layoutmanager/index.d.ts vendored Normal file
View File

@@ -0,0 +1,56 @@
// Type definitions for Backbone.LayoutManager 0.9.5
// Project: http://layoutmanager.org/
// Definitions by: He Jiang <https://github.com/hejiang2000/>
// Definitions: https://github.com/hejiang2000/DefinitelyTyped
/// <reference types="jquery" />
import * as Backbone from 'backbone';
declare module 'backbone' {
interface LayoutOptions<TModel extends Model> extends ViewOptions<TModel> {
template?: string;
views?: { [viewName: string]: View<TModel> };
}
interface LayoutManagerOptions {
manage?: boolean;
el?: boolean;
}
class Layout<TModel extends Model> extends View<TModel> {
template: string;
constructor(options?: LayoutOptions<TModel>);
beforeRender(): void;
afterRender(): void;
cleanup(): void;
fetchTemplate(path: string): (context:any)=>string;
async():(compiled:(context:any)=>void)=>void;
promise(): JQueryPromise<any>;
getAllOptions(): LayoutOptions<TModel>;
getView(fn?:any): any;
getViews(fn?:any): any[];
insertView(selector:any, view?:any): any; // return view;
insertViews(views:any): Layout<TModel>; // return this;
remove(): Layout<TModel>;
removeView(fn:any): Layout<TModel>;
render(): Layout<TModel>; // return this
renderViews(): Layout<TModel>; // return this
setView<U>(name: any, view: U, insert?:boolean): U; // return view
setViews(views:any): Layout<TModel>; // return this
then(fn:()=>void):void;
static cache(path: string, contents?: any): any;
static cleanViews(views: any): void;
static configure(options: LayoutManagerOptions): void;
static setupView(views: any, options?: LayoutOptions<Model>): void;
}
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"backbone.layoutmanager-tests.ts"
]
}