diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts
new file mode 100644
index 000000000..4e40687a8
--- /dev/null
+++ b/backbone/backbone-global.d.ts
@@ -0,0 +1,375 @@
+// Type definitions for Backbone 1.0.0
+// Project: http://backbonejs.org/
+// Definitions by: Boris Yankov , Natan Vivo
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module Backbone {
+
+ interface AddOptions extends Silenceable {
+ at?: number;
+ }
+
+ interface HistoryOptions extends Silenceable {
+ pushState?: boolean;
+ root?: string;
+ }
+
+ interface NavigateOptions {
+ trigger?: boolean;
+ replace?: boolean;
+ }
+
+ interface RouterOptions {
+ routes: any;
+ }
+
+ interface Silenceable {
+ silent?: boolean;
+ }
+
+ interface Validable {
+ validate?: boolean;
+ }
+
+ interface Waitable {
+ wait?: boolean;
+ }
+
+ interface Parseable {
+ parse?: any;
+ }
+
+ interface PersistenceOptions {
+ url?: string;
+ beforeSend?: (jqxhr: JQueryXHR) => void;
+ success?: (modelOrCollection?: any, response?: any, options?: any) => void;
+ error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
+ }
+
+ interface ModelSetOptions extends Silenceable, Validable {
+ }
+
+ interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable {
+ }
+
+ interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions {
+ patch?: boolean;
+ }
+
+ interface ModelDestroyOptions extends Waitable, PersistenceOptions {
+ }
+
+ interface CollectionFetchOptions extends PersistenceOptions, Parseable {
+ reset?: boolean;
+ }
+
+ class Events {
+ on(eventName: string, callback?: Function, context?: any): any;
+ off(eventName?: string, callback?: Function, context?: any): any;
+ trigger(eventName: string, ...args: any[]): any;
+ bind(eventName: string, callback: Function, context?: any): any;
+ unbind(eventName?: string, callback?: Function, context?: any): any;
+
+ once(events: string, callback: Function, context?: any): any;
+ listenTo(object: any, events: string, callback: Function): any;
+ listenToOnce(object: any, events: string, callback: Function): any;
+ stopListening(object?: any, events?: string, callback?: Function): any;
+ }
+
+ class ModelBase extends Events {
+ url: any;
+ parse(response: any, options?: any): any;
+ toJSON(options?: any): any;
+ sync(...arg: any[]): JQueryXHR;
+ }
+
+ class Model extends ModelBase {
+
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
+
+ attributes: any;
+ changed: any[];
+ cid: string;
+ collection: Collection;
+
+ /**
+ * Default attributes for the model. It can be an object hash or a method returning an object hash.
+ * For assigning an object hash, do it like this: this.defaults = { attribute: value, ... };
+ * That works only if you set it in the constructor or the initialize method.
+ **/
+ defaults(): any;
+ id: any;
+ idAttribute: string;
+ validationError: any;
+ urlRoot: any;
+
+ constructor(attributes?: any, options?: any);
+ initialize(attributes?: any, options?: any): void;
+
+ fetch(options?: ModelFetchOptions): JQueryXHR;
+
+ /**
+ * For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
+ * @example
+ * get name(): string {
+ * return super.get("name");
+ * }
+ **/
+ /*private*/ get(attributeName: string): any;
+
+ /**
+ * For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
+ * @example
+ * set name(value: string) {
+ * super.set("name", value);
+ * }
+ **/
+ /*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
+ set(obj: any, options?: ModelSetOptions): Model;
+
+ change(): any;
+ changedAttributes(attributes?: any): any[];
+ clear(options?: Silenceable): any;
+ clone(): Model;
+ destroy(options?: ModelDestroyOptions): any;
+ escape(attribute: string): string;
+ has(attribute: string): boolean;
+ hasChanged(attribute?: string): boolean;
+ isNew(): boolean;
+ isValid(options?:any): boolean;
+ previous(attribute: string): any;
+ previousAttributes(): any[];
+ save(attributes?: any, options?: ModelSaveOptions): any;
+ unset(attribute: string, options?: Silenceable): Model;
+ validate(attributes: any, options?: any): any;
+
+ private _validate(attributes: any, options: any): boolean;
+
+ // mixins from underscore
+
+ keys(): string[];
+ values(): any[];
+ pairs(): any[];
+ invert(): any;
+ pick(keys: string[]): any;
+ pick(...keys: string[]): any;
+ omit(keys: string[]): any;
+ omit(...keys: string[]): any;
+ }
+
+ class Collection extends ModelBase {
+
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
+
+ model: new (...args:any[]) => TModel;
+ models: TModel[];
+ length: number;
+
+ constructor(models?: TModel[] | Object[], options?: any);
+ initialize(models?: TModel[] | Object[], options?: any): void;
+
+ fetch(options?: CollectionFetchOptions): JQueryXHR;
+
+ comparator(element: TModel): number;
+ comparator(compare: TModel, to?: TModel): number;
+
+ add(model: {}|TModel, options?: AddOptions): TModel;
+ add(models: ({}|TModel)[], options?: AddOptions): TModel[];
+ at(index: number): TModel;
+ /**
+ * Get a model from a collection, specified by an id, a cid, or by passing in a model.
+ **/
+ get(id: number|string|Model): TModel;
+ create(attributes: any, options?: ModelSaveOptions): TModel;
+ pluck(attribute: string): any[];
+ push(model: TModel, options?: AddOptions): TModel;
+ pop(options?: Silenceable): TModel;
+ remove(model: TModel, options?: Silenceable): TModel;
+ remove(models: TModel[], options?: Silenceable): TModel[];
+ reset(models?: TModel[], options?: Silenceable): TModel[];
+ set(models?: TModel[], options?: Silenceable): TModel[];
+ shift(options?: Silenceable): TModel;
+ sort(options?: Silenceable): Collection;
+ unshift(model: TModel, options?: AddOptions): TModel;
+ where(properties: any): TModel[];
+ findWhere(properties: any): TModel;
+
+ private _prepareModel(attributes?: any, options?: any): any;
+ private _removeReference(model: TModel): void;
+ private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void;
+
+ // mixins from underscore
+
+ all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
+ chain(): any;
+ contains(value: any): boolean;
+ countBy(iterator: (element: TModel, index: number) => any): _.Dictionary;
+ countBy(attribute: string): _.Dictionary;
+ detect(iterator: (item: any) => boolean, context?: any): any; // ???
+ drop(): TModel;
+ drop(n: number): TModel[];
+ each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
+ every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
+ find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel;
+ first(): TModel;
+ first(n: number): TModel[];
+ foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
+ forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
+ groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary;
+ groupBy(attribute: string, context?: any): _.Dictionary;
+ include(value: any): boolean;
+ indexOf(element: TModel, isSorted?: boolean): number;
+ initial(): TModel;
+ initial(n: number): TModel[];
+ inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
+ isEmpty(object: any): boolean;
+ invoke(methodName: string, args?: any[]): any;
+ last(): TModel;
+ last(n: number): TModel[];
+ lastIndexOf(element: TModel, fromIndex?: number): number;
+ map(iterator: (element: TModel, index: number, context?: any) => any, context?: any): any[];
+ max(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
+ min(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
+ reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
+ select(iterator: any, context?: any): any[];
+ size(): number;
+ shuffle(): any[];
+ slice(min: number, max?: number): TModel[];
+ some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
+ sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[];
+ sortBy(attribute: string, context?: any): TModel[];
+ sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number;
+ reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[];
+ reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
+ rest(): TModel;
+ rest(n: number): TModel[];
+ tail(): TModel;
+ tail(n: number): TModel[];
+ toArray(): any[];
+ without(...values: any[]): TModel[];
+ }
+
+ class Router extends Events {
+
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
+
+ /**
+ * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router.
+ * For assigning routes as object hash, do it like this: this.routes = { "route": callback, ... };
+ * That works only if you set it in the constructor or the initialize method.
+ **/
+ routes: any;
+
+ constructor(options?: RouterOptions);
+ initialize(options?: RouterOptions): void;
+ route(route: string|RegExp, name: string, callback?: Function): Router;
+ navigate(fragment: string, options?: NavigateOptions): Router;
+ navigate(fragment: string, trigger?: boolean): Router;
+
+ private _bindRoutes(): void;
+ private _routeToRegExp(route: string): RegExp;
+ private _extractParameters(route: RegExp, fragment: string): string[];
+ }
+
+ var history: History;
+
+ class History extends Events {
+
+ handlers: any[];
+ interval: number;
+
+ start(options?: HistoryOptions): boolean;
+
+ getHash(window?: Window): string;
+ getFragment(fragment?: string, forcePushState?: boolean): string;
+ stop(): void;
+ route(route: string, callback: Function): number;
+ checkUrl(e?: any): void;
+ loadUrl(fragmentOverride: string): boolean;
+ navigate(fragment: string, options?: any): boolean;
+ started: boolean;
+ options: any;
+
+ private _updateHash(location: Location, fragment: string, replace: boolean): void;
+ }
+
+ interface ViewOptions {
+ model?: TModel;
+ // TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
+ collection?: Backbone.Collection;
+ el?: any;
+ id?: string;
+ className?: string;
+ tagName?: string;
+ attributes?: {[id: string]: any};
+ }
+
+ class View extends Events {
+
+ /**
+ * Do not use, prefer TypeScript's extend functionality.
+ **/
+ private static extend(properties: any, classProperties?: any): any;
+
+ constructor(options?: ViewOptions);
+ initialize(options?: ViewOptions): void;
+
+ /**
+ * Events hash or a method returning the events hash that maps events/selectors to methods on your View.
+ * For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... };
+ * That works only if you set it in the constructor or the initialize method.
+ **/
+ events(): any;
+
+ $(selector: string): JQuery;
+ model: TModel;
+ collection: Collection;
+ //template: (json, options?) => string;
+ setElement(element: HTMLElement|JQuery, delegate?: boolean): View;
+ id: string;
+ cid: string;
+ className: string;
+ tagName: string;
+
+ el: any;
+ $el: JQuery;
+ setElement(element: any): View;
+ attributes: any;
+ $(selector: any): JQuery;
+ render(): View;
+ remove(): View;
+ make(tagName: any, attributes?: any, content?: any): any;
+ delegateEvents(events?: any): any;
+ undelegateEvents(): any;
+
+ _ensureElement(): void;
+ }
+
+ // SYNC
+ function sync(method: string, model: Model, options?: JQueryAjaxSettings): any;
+ function ajax(options?: JQueryAjaxSettings): JQueryXHR;
+ var emulateHTTP: boolean;
+ var emulateJSON: boolean;
+
+ // Utility
+ function noConflict(): typeof Backbone;
+ var $: JQueryStatic;
+}
+
+declare module "backbone" {
+ export = Backbone;
+}
diff --git a/backbone/backbone-with-lodash-tests.ts b/backbone/backbone-with-lodash-tests.ts
new file mode 100644
index 000000000..c4f5fdf4d
--- /dev/null
+++ b/backbone/backbone-with-lodash-tests.ts
@@ -0,0 +1,314 @@
+///
+///
+///
+
+function test_events() {
+
+ var object = new Backbone.Events();
+ object.on("alert", (eventName: string) => alert("Triggered " + eventName));
+
+ object.trigger("alert", "an event");
+
+ var onChange = () => alert('whatever');
+ var context: any;
+
+ object.off("change", onChange);
+ object.off("change");
+ object.off(null, onChange);
+ object.off(null, null, context);
+ object.off();
+}
+
+class SettingDefaults extends Backbone.Model {
+
+ // 'defaults' could be set in one of the following ways:
+
+ defaults() {
+ return {
+ name: "Joe"
+ }
+ }
+
+ constructor(attributes?: any, options?: any) {
+ this.defaults = {
+ name: "Joe"
+ }
+ // super has to come last
+ super(attributes, options);
+ }
+
+ // or set it like this
+ initialize() {
+ this.defaults = {
+ name: "Joe"
+ }
+
+ }
+
+ // same patterns could be used for setting 'Router.routes' and 'View.events'
+}
+
+class Sidebar extends Backbone.Model {
+
+ promptColor() {
+ var cssColor = prompt("Please enter a CSS color:");
+ this.set({ color: cssColor });
+ }
+}
+
+class Note extends Backbone.Model {
+ initialize() { }
+ author() { }
+ coordinates() { }
+ allowedToEdit(account: any) {
+ return true;
+ }
+}
+
+class PrivateNote extends Note {
+ allowedToEdit(account: any) {
+ return account.owns(this);
+ }
+
+ set(attributes: any, options?: any): Backbone.Model {
+ return Backbone.Model.prototype.set.call(this, attributes, options);
+ }
+}
+
+function test_models() {
+
+ var sidebar = new Sidebar();
+ sidebar.on('change:color', (model: {}, color: string) => $('#sidebar').css({ background: color }));
+ sidebar.set({ color: 'white' });
+ sidebar.promptColor();
+
+ //////////
+
+ var note = new PrivateNote();
+
+ note.get("title");
+
+ note.set({ title: "March 20", content: "In his eyes she eclipses..." });
+
+ note.set("title", "A Scandal in Bohemia");
+}
+
+class Employee extends Backbone.Model {
+ reports: EmployeeCollection;
+
+ constructor(attributes?: any, options?: any) {
+ super(options);
+ this.reports = new EmployeeCollection();
+ this.reports.url = '../api/employees/' + this.id + '/reports';
+ }
+
+ more() {
+ this.reports.reset();
+ }
+}
+
+class EmployeeCollection extends Backbone.Collection {
+ findByName(key: any) { }
+}
+
+class Book extends Backbone.Model {
+ title: string;
+ author: string;
+ published: boolean;
+}
+
+class Library extends Backbone.Collection {
+ // This model definition is here only to test type compatibility of the model, but it
+ // is not necessary in working code as it is automatically inferred through generics.
+ model: typeof Book;
+}
+
+class Books extends Backbone.Collection { }
+
+function test_collection() {
+
+ var books = new Books();
+
+ var book1: Book = new Book({ title: "Title 1", author: "Mike" });
+ books.add(book1);
+
+ // Objects can be added to collection by casting to model type.
+ // Compiler will check if object properties are valid for the cast.
+ // This gives better type checking than declaring an `any` overload.
+ books.add({ title: "Title 2", author: "Mikey" });
+
+ var model: Book = book1.collection.first();
+ if (model !== book1) {
+ throw new Error("Error");
+ }
+
+ books.each(book =>
+ book.get("title"));
+
+ var titles = books.map(book =>
+ book.get("title"));
+
+ var publishedBooks = books.filter(book =>
+ book.get("published") === true);
+
+ var alphabetical = books.sortBy((book: Book): number => null);
+}
+
+//////////
+
+Backbone.history.start();
+
+module v1Changes {
+ module events {
+ function test_once() {
+ var model = new Employee;
+ model.once('invalid', () => { }, this);
+ model.once('invalid', () => { });
+ }
+
+ function test_listenTo() {
+ var model = new Employee;
+ var view = new Backbone.View();
+ view.listenTo(model, 'invalid', () => { });
+ }
+
+ function test_listenToOnce() {
+ var model = new Employee;
+ var view = new Backbone.View();
+ view.listenToOnce(model, 'invalid', () => { });
+ }
+
+ function test_stopListening() {
+ var model = new Employee;
+ var view = new Backbone.View();
+ view.stopListening(model, 'invalid', () => { });
+ view.stopListening(model, 'invalid');
+ view.stopListening(model);
+ }
+ }
+
+ module ModelAndCollection {
+ function test_url() {
+ Employee.prototype.url = () => '/employees';
+ EmployeeCollection.prototype.url = () => '/employees';
+ }
+
+ function test_parse() {
+ var model = new Employee();
+ model.parse('{}', {});
+ var collection = new EmployeeCollection;
+ collection.parse('{}', {});
+ }
+
+ function test_toJSON() {
+ var model = new Employee();
+ model.toJSON({});
+ var collection = new EmployeeCollection;
+ collection.toJSON({});
+ }
+
+ function test_sync() {
+ var model = new Employee();
+ model.sync();
+ var collection = new EmployeeCollection;
+ collection.sync();
+ }
+ }
+
+ module Model {
+ function test_validationError() {
+ var model = new Employee;
+ if (model.validationError) {
+ console.log('has validation errors');
+ }
+ }
+
+ function test_fetch() {
+ var model = new Employee({ id: 1 });
+ model.fetch({
+ success: () => { },
+ error: () => { }
+ });
+ }
+
+ function test_set() {
+ var model = new Employee;
+ model.set({ name: 'JoeDoe', age: 21 }, { validate: false });
+ model.set('name', 'JoeDoes', { validate: false });
+ }
+
+ function test_destroy() {
+ var model = new Employee;
+ model.destroy({
+ wait: true,
+ success: (m?, response?, options?) => { },
+ error: (m?, jqxhr?, options?) => { }
+ });
+
+ model.destroy({
+ success: (m?, response?, options?) => { },
+ error: (m?, jqxhr?) => { }
+ });
+
+ model.destroy({
+ success: () => { },
+ error: (m?, jqxhr?) => { }
+ });
+ }
+
+ function test_save() {
+ var model = new Employee;
+
+ model.save({
+ name: 'Joe Doe',
+ age: 21
+ },
+ {
+ wait: true,
+ validate: false,
+ success: (m?, response?, options?) => { },
+ error: (m?, jqxhr?, options?) => { }
+ });
+
+ model.save({
+ name: 'Joe Doe',
+ age: 21
+ },
+ {
+ success: () => { },
+ error: (m?, jqxhr?) => { }
+ });
+ }
+
+ function test_validate() {
+ var model = new Employee;
+
+ model.validate({ name: 'JoeDoe', age: 21 }, { validateAge: false })
+ }
+ }
+
+ module Collection {
+ function test_fetch() {
+ var collection = new EmployeeCollection;
+ collection.fetch({ reset: true });
+ }
+
+ function test_create() {
+ var collection = new EmployeeCollection;
+ var model = new Employee;
+
+ collection.create(model, {
+ validate: false
+ });
+ }
+ }
+
+ module Router {
+ function test_navigate() {
+ var router = new Backbone.Router;
+
+ router.navigate('/employees', { trigger: true });
+ router.navigate('/employees', true);
+ }
+ }
+}
diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts
index f7c5945ad..3b777e581 100644
--- a/backbone/backbone.d.ts
+++ b/backbone/backbone.d.ts
@@ -3,374 +3,5 @@
// Definitions by: Boris Yankov , Natan Vivo
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-///
///
-
-declare module Backbone {
-
- interface AddOptions extends Silenceable {
- at?: number;
- }
-
- interface HistoryOptions extends Silenceable {
- pushState?: boolean;
- root?: string;
- }
-
- interface NavigateOptions {
- trigger?: boolean;
- replace?: boolean;
- }
-
- interface RouterOptions {
- routes: any;
- }
-
- interface Silenceable {
- silent?: boolean;
- }
-
- interface Validable {
- validate?: boolean;
- }
-
- interface Waitable {
- wait?: boolean;
- }
-
- interface Parseable {
- parse?: any;
- }
-
- interface PersistenceOptions {
- url?: string;
- beforeSend?: (jqxhr: JQueryXHR) => void;
- success?: (modelOrCollection?: any, response?: any, options?: any) => void;
- error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
- }
-
- interface ModelSetOptions extends Silenceable, Validable {
- }
-
- interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable {
- }
-
- interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions {
- patch?: boolean;
- }
-
- interface ModelDestroyOptions extends Waitable, PersistenceOptions {
- }
-
- interface CollectionFetchOptions extends PersistenceOptions, Parseable {
- reset?: boolean;
- }
-
- class Events {
- on(eventName: string, callback?: Function, context?: any): any;
- off(eventName?: string, callback?: Function, context?: any): any;
- trigger(eventName: string, ...args: any[]): any;
- bind(eventName: string, callback: Function, context?: any): any;
- unbind(eventName?: string, callback?: Function, context?: any): any;
-
- once(events: string, callback: Function, context?: any): any;
- listenTo(object: any, events: string, callback: Function): any;
- listenToOnce(object: any, events: string, callback: Function): any;
- stopListening(object?: any, events?: string, callback?: Function): any;
- }
-
- class ModelBase extends Events {
- url: any;
- parse(response: any, options?: any): any;
- toJSON(options?: any): any;
- sync(...arg: any[]): JQueryXHR;
- }
-
- class Model extends ModelBase {
-
- /**
- * Do not use, prefer TypeScript's extend functionality.
- **/
- private static extend(properties: any, classProperties?: any): any;
-
- attributes: any;
- changed: any[];
- cid: string;
- collection: Collection;
-
- /**
- * Default attributes for the model. It can be an object hash or a method returning an object hash.
- * For assigning an object hash, do it like this: this.defaults = { attribute: value, ... };
- * That works only if you set it in the constructor or the initialize method.
- **/
- defaults(): any;
- id: any;
- idAttribute: string;
- validationError: any;
- urlRoot: any;
-
- constructor(attributes?: any, options?: any);
- initialize(attributes?: any, options?: any): void;
-
- fetch(options?: ModelFetchOptions): JQueryXHR;
-
- /**
- * For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
- * @example
- * get name(): string {
- * return super.get("name");
- * }
- **/
- /*private*/ get(attributeName: string): any;
-
- /**
- * For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
- * @example
- * set name(value: string) {
- * super.set("name", value);
- * }
- **/
- /*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
- set(obj: any, options?: ModelSetOptions): Model;
-
- change(): any;
- changedAttributes(attributes?: any): any[];
- clear(options?: Silenceable): any;
- clone(): Model;
- destroy(options?: ModelDestroyOptions): any;
- escape(attribute: string): string;
- has(attribute: string): boolean;
- hasChanged(attribute?: string): boolean;
- isNew(): boolean;
- isValid(options?:any): boolean;
- previous(attribute: string): any;
- previousAttributes(): any[];
- save(attributes?: any, options?: ModelSaveOptions): any;
- unset(attribute: string, options?: Silenceable): Model;
- validate(attributes: any, options?: any): any;
-
- private _validate(attributes: any, options: any): boolean;
-
- // mixins from underscore
-
- keys(): string[];
- values(): any[];
- pairs(): any[];
- invert(): any;
- pick(keys: string[]): any;
- pick(...keys: string[]): any;
- omit(keys: string[]): any;
- omit(...keys: string[]): any;
- }
-
- class Collection extends ModelBase {
-
- /**
- * Do not use, prefer TypeScript's extend functionality.
- **/
- private static extend(properties: any, classProperties?: any): any;
-
- model: new (...args:any[]) => TModel;
- models: TModel[];
- length: number;
-
- constructor(models?: TModel[] | Object[], options?: any);
- initialize(models?: TModel[] | Object[], options?: any): void;
-
- fetch(options?: CollectionFetchOptions): JQueryXHR;
-
- comparator(element: TModel): number;
- comparator(compare: TModel, to?: TModel): number;
-
- add(model: {}|TModel, options?: AddOptions): TModel;
- add(models: ({}|TModel)[], options?: AddOptions): TModel[];
- at(index: number): TModel;
- /**
- * Get a model from a collection, specified by an id, a cid, or by passing in a model.
- **/
- get(id: number|string|Model): TModel;
- create(attributes: any, options?: ModelSaveOptions): TModel;
- pluck(attribute: string): any[];
- push(model: TModel, options?: AddOptions): TModel;
- pop(options?: Silenceable): TModel;
- remove(model: TModel, options?: Silenceable): TModel;
- remove(models: TModel[], options?: Silenceable): TModel[];
- reset(models?: TModel[], options?: Silenceable): TModel[];
- set(models?: TModel[], options?: Silenceable): TModel[];
- shift(options?: Silenceable): TModel;
- sort(options?: Silenceable): Collection;
- unshift(model: TModel, options?: AddOptions): TModel;
- where(properties: any): TModel[];
- findWhere(properties: any): TModel;
-
- private _prepareModel(attributes?: any, options?: any): any;
- private _removeReference(model: TModel): void;
- private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void;
-
- // mixins from underscore
-
- all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
- any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
- collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
- chain(): any;
- contains(value: any): boolean;
- countBy(iterator: (element: TModel, index: number) => any): _.Dictionary;
- countBy(attribute: string): _.Dictionary;
- detect(iterator: (item: any) => boolean, context?: any): any; // ???
- drop(): TModel;
- drop(n: number): TModel[];
- each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
- every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
- filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
- find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel;
- first(): TModel;
- first(n: number): TModel[];
- foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
- forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
- groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary;
- groupBy(attribute: string, context?: any): _.Dictionary;
- include(value: any): boolean;
- indexOf(element: TModel, isSorted?: boolean): number;
- initial(): TModel;
- initial(n: number): TModel[];
- inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
- isEmpty(object: any): boolean;
- invoke(methodName: string, args?: any[]): any;
- last(): TModel;
- last(n: number): TModel[];
- lastIndexOf(element: TModel, fromIndex?: number): number;
- map(iterator: (element: TModel, index: number, context?: any) => any, context?: any): any[];
- max(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
- min(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
- reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
- select(iterator: any, context?: any): any[];
- size(): number;
- shuffle(): any[];
- slice(min: number, max?: number): TModel[];
- some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
- sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[];
- sortBy(attribute: string, context?: any): TModel[];
- sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number;
- reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[];
- reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
- rest(): TModel;
- rest(n: number): TModel[];
- tail(): TModel;
- tail(n: number): TModel[];
- toArray(): any[];
- without(...values: any[]): TModel[];
- }
-
- class Router extends Events {
-
- /**
- * Do not use, prefer TypeScript's extend functionality.
- **/
- private static extend(properties: any, classProperties?: any): any;
-
- /**
- * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router.
- * For assigning routes as object hash, do it like this: this.routes = { "route": callback, ... };
- * That works only if you set it in the constructor or the initialize method.
- **/
- routes: any;
-
- constructor(options?: RouterOptions);
- initialize(options?: RouterOptions): void;
- route(route: string|RegExp, name: string, callback?: Function): Router;
- navigate(fragment: string, options?: NavigateOptions): Router;
- navigate(fragment: string, trigger?: boolean): Router;
-
- private _bindRoutes(): void;
- private _routeToRegExp(route: string): RegExp;
- private _extractParameters(route: RegExp, fragment: string): string[];
- }
-
- var history: History;
-
- class History extends Events {
-
- handlers: any[];
- interval: number;
-
- start(options?: HistoryOptions): boolean;
-
- getHash(window?: Window): string;
- getFragment(fragment?: string, forcePushState?: boolean): string;
- stop(): void;
- route(route: string, callback: Function): number;
- checkUrl(e?: any): void;
- loadUrl(fragmentOverride: string): boolean;
- navigate(fragment: string, options?: any): boolean;
- started: boolean;
- options: any;
-
- private _updateHash(location: Location, fragment: string, replace: boolean): void;
- }
-
- interface ViewOptions {
- model?: TModel;
- // TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
- collection?: Backbone.Collection;
- el?: any;
- id?: string;
- className?: string;
- tagName?: string;
- attributes?: {[id: string]: any};
- }
-
- class View extends Events {
-
- /**
- * Do not use, prefer TypeScript's extend functionality.
- **/
- private static extend(properties: any, classProperties?: any): any;
-
- constructor(options?: ViewOptions);
- initialize(options?: ViewOptions): void;
-
- /**
- * Events hash or a method returning the events hash that maps events/selectors to methods on your View.
- * For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... };
- * That works only if you set it in the constructor or the initialize method.
- **/
- events(): any;
-
- $(selector: string): JQuery;
- model: TModel;
- collection: Collection;
- //template: (json, options?) => string;
- setElement(element: HTMLElement|JQuery, delegate?: boolean): View;
- id: string;
- cid: string;
- className: string;
- tagName: string;
-
- el: any;
- $el: JQuery;
- setElement(element: any): View;
- attributes: any;
- $(selector: any): JQuery;
- render(): View;
- remove(): View;
- make(tagName: any, attributes?: any, content?: any): any;
- delegateEvents(events?: any): any;
- undelegateEvents(): any;
-
- _ensureElement(): void;
- }
-
- // SYNC
- function sync(method: string, model: Model, options?: JQueryAjaxSettings): any;
- function ajax(options?: JQueryAjaxSettings): JQueryXHR;
- var emulateHTTP: boolean;
- var emulateJSON: boolean;
-
- // Utility
- function noConflict(): typeof Backbone;
- var $: JQueryStatic;
-}
-
-declare module "backbone" {
- export = Backbone;
-}
+///