Permalink
Browse files

Ready for takeoff

  • Loading branch information...
1 parent 9bdc14f commit b97d19a7bad201e7cff3a8b0f5476a2dda211b1b Jacob Waller committed Sep 19, 2011
View
@@ -2,8 +2,6 @@ Ti.include("/kranium/lib/kranium.js");
K.initBackbone();
-K.settings.useCustomAndroidNavBar = true;
-
K({
type: 'tabgroup',
tabs: [{
@@ -6,6 +6,6 @@
global.TEST = false;
global.BOOTSTRAPPED = true;
if(K.is.ios){
- K.watch("10.10.10.42", "8128");
+ K.watch("10.10.10.2", "8128");
}
})(this);
@@ -2686,12 +2686,12 @@ $.qsa = $$ = (function(document, global){
};
// From Zepto
- $.get = function(url, success) {
+ /*$.get = function(url, success) {
$.ajax({
url: url,
success: success
})
- };
+ };*/
$.post = function(url, data, success, dataType) {
if ($.isFunction(data)) dataType = dataType || success,
success = data,
View
@@ -3,12 +3,16 @@ window {
bar-color: #23aaff;
}
-.toolbar {
- background-color: #555;
+tabbedbar {
+ style: Ti.UI.iPhone.SystemButtonStyle.BAR;
+}
+
+buttonbar {
+ style: Ti.UI.iPhone.SystemButtonStyle.BAR;
}
-.toolbarButton {
- style: Ti.UI.iPhone.SystemButtonStyle.BORDERED;
+.toolbar {
+ background-color: #555;
}
.board {
@@ -1,19 +1,19 @@
.demoitem {
- width: 200;
+ width: 240;
height: 40;
top: 10;
}
.swipeme {
- border-radius: 5;
+ border-radius: 15;
background-color: #f00;
- text-align: left;
+ text-align: right;
}
.clickme {
top: 10;
}
.coffeetable {
height: 200;
- border-width: 2;
+ border-width: 4;
border-color: #ccc;
border-radius: 7;
}
@@ -1,65 +1,60 @@
+// Define model
+RowModel = Backbone.Model.extend({
+ type: 'tableviewrow'
+});
+
+// Define collection
+RowCollection = Backbone.Collection.extend({
+ model: RowModel,
+ comparator: function(model) {
+ return model.get("title");
+ }
+});
+
+// Create todos collection
+todos = new RowCollection();
+todos.add([
+ { title: "An example todo" },
+ { title: "Another example todo" },
+]);
+
+// Create todolist
+var todolist = K.create({
+ type: 'todolist',
+ collection: todos
+});
exports.Class = Window.extend({
navBarHidden: true,
init: function(o){
- RowModel = Backbone.Model.extend({
- type: 'tableviewrow'
- });
-
- RowCollection = Backbone.Collection.extend({
- // Reference to this collection's model.
- model: RowModel,
- comparator: function(model) {
- return model.get("title");
- }
- });
-
- // Global on purpose since Titanium cannot handle collections on elements
- todos = new RowCollection();
- todos.add([
- { title: "An example todo" },
- { title: "Another example todo" },
- ]);
-
- var todolist = this.todolist = K.create({
- type: 'todolist',
- collection: todos
- });
-
this.titleLabel = K.createLabel({
className: 'titleLabel'
});
-
todos.bind('all', this.updateTitleLabel.bind(this));
this.updateTitleLabel();
this.children = [{
- type: 'toolbar',
- className: 'todoToolbar',
- items: [{
- type: 'textfield',
- className: 'todoInputTextField',
- events: {
- "return": function(e){
- todos.add({
- title: e.value
- });
+ type: 'toolbar',
+ className: 'todoToolbar',
+ items: [{
+ type: 'textfield',
+ className: 'todoInputTextField',
+ events: {
+ "return": function(e){
+ todos.add({ title: e.value });
+ }
}
- }
- },
- 'spacer',
- this.titleLabel]
- }, todolist];
-
+ },
+ 'spacer',
+ this.titleLabel]
+ }, todolist];
this._super(o);
},
updateTitleLabel: function(){
- var completed = todos.pluck('hasCheck').filter(function(val){ return !!val }).length;
+ var completed = todos.filter(function(m){ return m.get('hasCheck') }).length;
this.titleLabel.text = completed + ' / ' + todos.length + ' todos';
}
-
-});
-
+});
@@ -1,14 +1,16 @@
+// kui/todolist.js
+
exports.Class = BackboneView.extend({
type: 'tableview',
editable: true,
events: {
click: function(e){
- var model = todos.get(e.rowData._modelId) || todos.getByCid(e.rowData._modelCid);
+ var model = todos.getByCid(e.rowData._modelCid);
model.set({ hasCheck: !model.get('hasCheck') });
},
"delete": function(e){
- var model = todos.get(e.rowData._modelId) || todos.getByCid(e.rowData._modelCid);
+ var model = todos.getByCid(e.rowData._modelCid);
todos.remove(model);
}
}
View
@@ -10,8 +10,13 @@
});
describe('TabGroup', function(){
- it('Has tabgroup', function(){ expect(K('tabgroup').length).toBeGreaterThan(0); });
- it('TabGroup.activeTab.title === "test"', function(){ expect(K('tabgroup').get(0).activeTab.title).toEqual("Coffee Demo"); });
+ it('Has tabgroup', function(){
+ expect(K('tabgroup').length).toBeGreaterThan(0);
+ });
+
+ it('First tab title should be "Shims"', function(){
+ expect(K('tabgroup').get(0).activeTab.title).toEqual("Shims");
+ });
});
});

0 comments on commit b97d19a

Please sign in to comment.