Skip to content

Instantly share code, notes, and snippets.

@hvgotcodes
Created May 4, 2012 00:45
Show Gist options
  • Save hvgotcodes/2590736 to your computer and use it in GitHub Desktop.
Save hvgotcodes/2590736 to your computer and use it in GitHub Desktop.
class hsc.ui.VerticalScorecard
constructor: ->
less = if Ti.App.SCREEN_WIDTH < Ti.App.SCREEN_HEIGHT then Ti.App.SCREEN_WIDTH else Ti.APP.SCREEN_HEIGHT
if Ti.App.SCREEN_WIDTH < Ti.App.SCREEN_HEIGHT
diff = Ti.App.SCREEN_HEIGHT - Ti.App.SCREEN_WIDTH
else
diff = Ti.App.SCREEN_WIDTH - Ti.APP.SCREEN_HEIGHT
top = diff - 24
width = less / 3 - 6
height = less / 3 - 6
@window = Ti.UI.createWindow
title: 'sc',
backgroundColor: '#000'
@cells = []
left = 5
for i in [1..9]
cell = new hsc.ui.CellView i, width, height, top, left
@cells.push cell
@window.add cell.view
left = left + 6 + width;
if i > 0 and i % 3 is 0
top = top + 6 + height
left = 6
open: ->
@window.open()
----- becomes ----
// Generated by CoffeeScript 1.3.1
(function() {
hsc.ui.VerticalScorecard = (function() {
VerticalScorecard.name = 'VerticalScorecard';
function VerticalScorecard() {
var cell, diff, height, i, left, less, top, width, _i;
less = Ti.App.SCREEN_WIDTH < Ti.App.SCREEN_HEIGHT ? Ti.App.SCREEN_WIDTH : Ti.APP.SCREEN_HEIGHT;
if (Ti.App.SCREEN_WIDTH < Ti.App.SCREEN_HEIGHT) {
diff = Ti.App.SCREEN_HEIGHT - Ti.App.SCREEN_WIDTH;
} else {
diff = Ti.App.SCREEN_WIDTH - Ti.APP.SCREEN_HEIGHT;
}
top = diff - 24;
width = less / 3 - 6;
height = less / 3 - 6;
this.window = Ti.UI.createWindow({
title: 'sc',
backgroundColor: '#000'
});
this.cells = [];
left = 5;
for (i = _i = 1; _i <= 9; i = ++_i) {
cell = new hsc.ui.CellView(i, width, height, top, left);
this.cells.push(cell);
this.window.add(cell.view);
left = left + 6 + width;
if (i > 0 && i % 3 === 0) {
top = top + 6 + height;
left = 6;
}
}
}
VerticalScorecard.prototype.open = function() {
return this.window.open();
};
return VerticalScorecard;
})();
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment