Skip to content

Instantly share code, notes, and snippets.

@hvgotcodes
Created March 14, 2012 01:06
Show Gist options
  • Save hvgotcodes/2033133 to your computer and use it in GitHub Desktop.
Save hvgotcodes/2033133 to your computer and use it in GitHub Desktop.
Sudoku.TopSurface = SC.View.extend({
init: function(){
sc_super();
var newButton = SC.ButtonWidget.create({
layout: { width: 100, top: 0, left: 0, height: 30 },
title: "New Game",
theme: 'square',
isDefault: true,
action: function() { alert('save'); }
});
this.get('layers').pushObject(newButton);
},
updateLayout: function(){
var frame = this.getPath('supersurface.frame'),
w = Math.round(frame[2] / 2) - Math.round(594 / 2);
this.set('frame', SC.MakeRect(w, 120, 594, 30));
}
});
----
function main() {
Sudoku.createGame();
var ui = Sudoku.MainSurface.create(),
board = Sudoku.BoardSurface.create(),
topView = Sudoku.TopSurface.create();
Sudoku.board = board;
ui._board = board;
board._parentSurface = ui;
ui.get('subsurfaces').pushObjects([topView, board]);
SC.app.set('ui', ui);
SC.app.set('inputSurface', topView);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment