Skip to content

Commit

Permalink
Rename Object.inherit to Base.inherit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavey committed Aug 24, 2012
1 parent 17ec094 commit 20cb35c
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion App/Client/AppFrame/AppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="~/Client/Shared/EventHub.js"/>
/// <reference path="~/Client/Shared/FlashMessage.js"/>

var AppFrame = Object.inherit({
var AppFrame = Base.inherit({

init: function (viewData) {
this.links = viewData.links;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Dashboard/DashboardViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="../Profile/ProfileForm.js" />
/// <reference path="../Vehicles/List/VehicleSummaryList.js" />

var DashboardViewModel = Object.inherit({
var DashboardViewModel = Base.inherit({

templateId: "Client/Dashboard/dashboard.htm",

Expand Down
2 changes: 1 addition & 1 deletion App/Client/Profile/ProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <reference path="~/Client/Shared/http.js"/>
/// <reference path="~/Client/Shared/validation/objectWithValidateableProperties.js" />

var ProfileForm = Object.inherit({
var ProfileForm = Base.inherit({

init: function (data) {
this.http = http;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// <reference path="../Vendor/jquery.js" />
/// <reference path="../Vendor/knockout.js" />

var Application = Object.inherit({
var Application = Base.inherit({
init: function() {
this.viewModelStack = ViewModelStack.create(this, http);
this.content = ko.observable({ templateId: "loading" });
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/Event.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="Object.js" />

var Event = Object.inherit({
var Event = Base.inherit({

init: function () {
this.handlers = [];
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/EventHub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var EventHub = Object.inherit({
var EventHub = Base.inherit({
init: function () {
this.handlers = { };
},
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/FlashMessage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="../Vendor/knockout.js" />
/// <reference path="Object.js" />

var FlashMessage = Object.inherit({
var FlashMessage = Base.inherit({

init: function () {
this.message = ko.observable();
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/IframeSubmission.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var IframeSubmission = Object.inherit({
var IframeSubmission = Base.inherit({

init: function (method, url, data, files, context) {
this.files = files;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Creating a Modal displays a modal dialog UI.
// The contents are rendered from a template, which is data bound to a view model.
var Modal = Object.inherit({
var Modal = Base.inherit({

init: function (viewModel, templateId) {
this.viewModel = viewModel;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Shared/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="../Vendor/knockout.js" />
/// <reference path="Object.js" />

var Navigation = Object.inherit({
var Navigation = Base.inherit({

init: function (app) {
this.app = app;
Expand Down
21 changes: 9 additions & 12 deletions App/Client/Shared/Object.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(function () {
var Base;

(function () {
"use strict";

var copyOwnProperties = function (from, to) {
Expand All @@ -9,25 +11,20 @@
}
};

var inherit = function (additionalProperties) {
var subclass = Object.create(this);
Base = {};
Base.inherit = function (additionalProperties) {
var prototype = Object.create(this);

subclass.create = function () {
// When calling `MyClass.create()` directly, `this` will be `MyClass` as expected.
// When passing `MyClass.create` to another function we lose the intended `this` (it's probably set to `window` or null)
// so explicitly use the `subclass` in that case.
var prototype = (this && this !== window) ? this : subclass;
prototype.create = function () {
var instance = Object.create(prototype);
if (typeof instance.init === "function") {
instance.init.apply(instance, arguments);
}
return instance;
};

copyOwnProperties(additionalProperties, subclass);
copyOwnProperties(additionalProperties, prototype);

return subclass;
return prototype;
};

Object.inherit = inherit;
} ());
2 changes: 1 addition & 1 deletion App/Client/Shared/UrlStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// and update the stack to be:
// [ "/application", "/vehicles/masterpage", "/vehicle/456/reminders" ]

var UrlStack = Object.inherit({
var UrlStack = Base.inherit({

init: function (download) {
/// <param name="download">Function that downloads a URL and returns a deferred object representing the download.</param>
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/Details/EditVehicleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="~/Client/Shared/validation/objectWithValidateableProperties.js"/>
/// <reference path="~/Client/Vendor/knockout.js"/>

var EditVehicleForm = Object.inherit({
var EditVehicleForm = Base.inherit({

templateId: "Client/Vehicles/Details/EditVehicleForm.htm",

Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/Details/Vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="~/Client/Shared/knockout-helpers.js"/>
/// <reference path="EditVehicleForm.js" />

var Vehicle = Object.inherit({
var Vehicle = Base.inherit({

init: function (viewData, app, eventHub, flashMessage) {
this.app = app;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/FillUps/AddFillUpForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// <reference path="~/Client/Shared/Modal.js" />
/// <reference path="~/Client/Shared/Object.js"/>

var AddFillUpForm = Object.inherit({
var AddFillUpForm = Base.inherit({

templateId: "Client/Vehicles/FillUps/AddFillUpForm.htm",

Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/FillUps/FillUp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="~/Client/Vendor/moment.js"/>
/// <reference path="~/Client/Shared/Object.js"/>

var FillUp = Object.inherit({
var FillUp = Base.inherit({
init: function (data) {
var units = ["gallon", "litre"];
var currency = "$";
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/FillUps/FillUpsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <reference path="FillUp.js"/>
/// <reference path="AddFillUpForm.js" />

var FillUpsPage = Object.inherit({
var FillUpsPage = Base.inherit({

templateId: "Client/Vehicles/FillUps/FillUpsPage.htm",

Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/List/VehicleSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="~/Client/Shared/Object.js"/>
/// <reference path="~/Client/Shared/knockout-helpers.js"/>

var VehicleSummary = Object.inherit({
var VehicleSummary = Base.inherit({
init: function(data) {
this.name = ko.observable(data.name);
this.photo = ko.observable(data.photo ? data.photo.url : "");
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/List/VehicleSummaryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <reference path="~/Client/Vendor/knockout.js"/>
/// <reference path="VehicleSummary.js" />

var VehicleSummaryList = Object.inherit({
var VehicleSummaryList = Base.inherit({

init: function (vehiclesLink, eventHub) {
this.http = http;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/MasterPage/MasterPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="~/Client/Vendor/knockout.js"/>
/// <reference path="../List/VehicleSummaryList.js" />

var MasterPage = Object.inherit({
var MasterPage = Base.inherit({

init: function (viewData, eventHub) {
this.vehicles = VehicleSummaryList.create(viewData.vehicles, eventHub);
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/Reminders/AddReminderForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="~/Client/Shared/validation/objectWithValidateableProperties.js"/>
/// <reference path="~/Client/Shared/Modal.js" />

var AddReminderForm = Object.inherit({
var AddReminderForm = Base.inherit({
init: function (viewData) {
this.http = http;
this.addCommand = viewData.add;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/Reminders/Reminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <reference path="~/Client/Vendor/moment.js"/>
/// <reference path="AddReminderForm.js"/>

var Reminder = Object.inherit({
var Reminder = Base.inherit({
init: function (data) {
this.http = http;
this.title = data.Title;
Expand Down
2 changes: 1 addition & 1 deletion App/Client/Vehicles/Reminders/RemindersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="Reminder.js"/>
/// <reference path="AddReminderForm.js"/>

var RemindersPage = Object.inherit({
var RemindersPage = Base.inherit({
init: function (viewData, flashMessage) {
this.flashMessage = flashMessage;
this.reminders = ko.observableArray(viewData.reminders.map(this.createReminderViewModel, this));
Expand Down

0 comments on commit 20cb35c

Please sign in to comment.