Skip to content

Instantly share code, notes, and snippets.

@lsiden
Created November 17, 2009 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lsiden/237321 to your computer and use it in GitHub Desktop.
Save lsiden/237321 to your computer and use it in GitHub Desktop.
// ==========================================================================
// Project: EccapCalc.LedgerView
// Copyright: ©2009 Westside Consulting LLC
// ==========================================================================
/*globals EccapCalc */
/** @class
This is a reusable view that is meant to be instantiated from the function
EccapCalc.createLedgerView(x, y, w, h, title, arrayController).
@extends SC.View
*/
var x=100, y=100, w=400, h=200, title='Liquid Assets', arrayController='EccapCalc.assetsController';
var h_title = 25;
var h_total = 18;
var h_add = 25;
var h_ledger = h - h_title - h_add - h_total;
var w_amount = 100;
var w_ledger = w - w_amount;
var y_title = y;
var y_ledger = y_title + h_title;
var y_add = y_ledger + h_ledger + 3;
var y_total = y_add + h_add;
EccapCalc.LedgerView = SC.View.design(
SC.CollectionViewDelegate,
/** @scope EccapCalc.LedgerView.prototype */ {
childViews: 'title ledger button_add label_total total'.w(),
title: SC.LabelView.design({
displayValue: title,
fontWeight: SC.BOLD_WEIGHT,
layout: { left: x, top: y, width: w, height: h_title},
}),
ledger: SC.ScrollView.design({
layout: { left: x, top: y_ledger, width: w, height: h_ledger},
contentView: SC.ListView.design({
contentBinding: arrayController + '.arrangedObjects',
selectionBinding: arrayController + '.selection',
exampleView: SC.View.design(SC.Control, {
childViews: 'descriptionView amountView'.w(),
descriptionView: SC.ListItemView.design({
layout: { left: x, top: y_ledger, width: w - w_amount, height: h_ledger},
contentBinding: '.parentView.content',
contentValueKey: 'description',
canEditContent: YES,
canDeleteContent: YES,
}),
amountView: SC.ListItemView.design({
layout: { left: w + x - w_amount, top: y_ledger, width: w_amount, height: h_ledger},
contentBinding: '.parentView.content',
contentValueKey: 'value',
canEditContent: YES,
canDeleteContent: YES,
classNames: ['numeric'],
}),
}),
}),
}),
button_add: SC.ButtonView.design({
layout: { left: x, top: y_add, width: 140, height: h_add},
title: 'Add New Asset',
target: arrayController,
action: "add_item"
}),
label_total: SC.LabelView.design({
layout: { left: x, top: y_total, width: w - w_amount, height: h_add},
displayValue: 'Total',
fontWeight: SC.BOLD_WEIGHT,
}),
total: SC.LabelView.design({
layout: { left: x + w - w_amount, top: y_total, width: w_amount, height: h_title},
valueBinding: arrayController + '.total',
textAlign: SC.ALIGN_RIGHT,
}),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment