From dd5444a11bb27c36618fc44ff6067f46f2380128 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Mon, 22 Oct 2012 10:59:42 +0300 Subject: [PATCH] Backbone fixes --- Definitions/backbone-0.9.d.ts | 2 ++ Tests/backbone-tests.ts | 46 +++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Definitions/backbone-0.9.d.ts b/Definitions/backbone-0.9.d.ts index e640351ce2..64a9fe8e3b 100644 --- a/Definitions/backbone-0.9.d.ts +++ b/Definitions/backbone-0.9.d.ts @@ -142,6 +142,8 @@ declare module Backbone { navigate(fragment, options? ); } + export var history: History; + export class History { start(options? ); } diff --git a/Tests/backbone-tests.ts b/Tests/backbone-tests.ts index f66f6de44f..171cd4cefe 100644 --- a/Tests/backbone-tests.ts +++ b/Tests/backbone-tests.ts @@ -24,33 +24,33 @@ object.off(); ////////////////////////////////////////////////////// var Sidebar = Backbone.Model.extend({ - promptColor: function() { - var cssColor = prompt("Please enter a CSS color:"); - this.set({color: cssColor}); - } + promptColor: function () { + var cssColor = prompt("Please enter a CSS color:"); + this.set({ color: cssColor }); + } }); var sidebar = new Sidebar(); -sidebar.on('change:color', (model, color) => $('#sidebar').css({background: color})); -sidebar.set({color: 'white'}); +sidebar.on('change:color', (model, color) => $('#sidebar').css({ background: color })); +sidebar.set({ color: 'white' }); sidebar.promptColor(); //////// var Note = Backbone.Model.extend({ - initialize: () => { }, - author: () => { }, - coordinates: () => { }, - allowedToEdit: (account) => { - return true; - } + initialize: () => { }, + author: () => { }, + coordinates: () => { }, + allowedToEdit: (account) => { + return true; + } }); var PrivateNote = Note.extend({ - allowedToEdit: function(account) { - return account.owns(this); - } + allowedToEdit: function (account) { + return account.owns(this); + } }); @@ -58,14 +58,14 @@ var PrivateNote = Note.extend({ ////////// var note = Backbone.Model.extend({ - set: function(attributes, options) { - Backbone.Model.prototype.set.call(this, attributes, options); - } + set: function (attributes, options) { + Backbone.Model.prototype.set.call(this, attributes, options); + } }); note.get("title") -note.set({title: "March 20", content: "In his eyes she eclipses..."}); +note.set({ title: "March 20", content: "In his eyes she eclipses..." }); note.set("title", "A Scandal in Bohemia"); @@ -85,5 +85,9 @@ class EmployeeCollection extends Backbone.Collection { url: string = "../api/employees"; model = Employee; - findByName(key) {} -} \ No newline at end of file + findByName(key) { } +} + +////////// + +Backbone.history.start(); \ No newline at end of file