Skip to content

Commit

Permalink
Major update to lebowski to work with SC 1.5 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
mlcohen committed May 13, 2011
1 parent 3dc1e02 commit e45a604
Show file tree
Hide file tree
Showing 30 changed files with 702 additions and 190 deletions.
Expand Up @@ -9,55 +9,113 @@ TestApp.alertPanesController = SC.ObjectController.create({
status: '--',

showAlertWarn: function() {
this.alertTitle = "Warn";
SC.AlertPane.warn(this.alertTitle, "A warning alert", "", "OK", "Cancel", null, this);
this.set('status', 'opened alert pane - %@'.fmt(this.alertTitle));
var alertTitle = "Warn";
SC.AlertPane.warn({
message: alertTitle,
description: "A warning alert",
buttons: [
{ title: "OK" },
{ title: "Cancel" }
],
delegate: this
});
this.set('status', 'opened alert pane - %@'.fmt(alertTitle));
},

showAlertError: function() {
this.alertTitle = "Error";
SC.AlertPane.error(this.alertTitle, "An error alert", "", "OK", "Cancel", null, this);
this.set('status', 'opened alert pane - %@'.fmt(this.alertTitle));
var alertTitle = "Error";

SC.AlertPane.error({
message: alertTitle,
description: "A error alert",
buttons: [
{ title: "OK" },
{ title: "Cancel" }
],
delegate: this
});

this.set('status', 'opened alert pane - %@'.fmt(alertTitle));
},

showAlertInfo: function() {
this.alertTitle = "Info";
SC.AlertPane.info(this.alertTitle, "An info alert", "", "OK", "Cancel", null, this);
this.set('status', 'opened alert pane - %@'.fmt(this.alertTitle));
var alertTitle = "Info";

SC.AlertPane.info({
message: alertTitle,
description: "A info alert",
buttons: [
{ title: "OK" },
{ title: "Cancel" }
],
delegate: this
});

this.set('status', 'opened alert pane - %@'.fmt(alertTitle));
},

showAlertPlain: function() {
this.alertTitle = "Plain";
SC.AlertPane.plain(this.alertTitle, "A plain alert", "", "Yes", "No", null, this);
this.set('status', 'opened alert pane - %@'.fmt(this.alertTitle));
var alertTitle = "Plain";

SC.AlertPane.plain({
message: alertTitle,
description: "A plain alert",
buttons: [
{ title: "Yes" },
{ title: "No" }
],
delegate: this
});

this.set('status', 'opened alert pane - %@'.fmt(alertTitle));
},

showAlertExtraButton: function() {
this.alertTitle = "Extra Button";
SC.AlertPane.plain(this.alertTitle, "An alert with an extra button", "", "Foo", "Bar", "Extra", this);
this.set('status', 'opened alert pane - %@'.fmt(this.alertTitle));
var alertTitle = "Extra Button";

SC.AlertPane.plain({
message: alertTitle,
description: "An alert with an extra button",
buttons: [
{ title: "Yes" },
{ title: "No" },
{ title: "Extra" }
],
delegate: this
});

this.set('status', 'opened alert pane - %@'.fmt(alertTitle));
},

showAlertOneButton: function() {
this.alertTitle = "One Button";
SC.AlertPane.plain(this.alertTitle, "An alert with one button", "", "OK", null, null, this);
this.set('status', 'opened alert pane - %@'.fmt(this.alertTitle));
var alertTitle = "One Button";

SC.AlertPane.plain({
message: alertTitle,
description: "An alert with one button",
buttons: [
{ title: "OK" }
],
delegate: this
});

this.set('status', 'opened alert pane - %@'.fmt(alertTitle));
},

alertPaneDidDismiss: function(pane, status) {
var buttonTitle = '';

switch(status) {
case SC.BUTTON1_STATUS:
buttonTitle = pane.buttonOne.get('title');
buttonTitle = pane.get('button1').get('title');
break;

case SC.BUTTON2_STATUS:
buttonTitle = pane.buttonTwo.get('title');
buttonTitle = pane.get('button2').get('title');
break;

case SC.BUTTON3_STATUS:
buttonTitle = pane.buttonThree.get('title');
buttonTitle = pane.get('button3').get('title');
break;
}

Expand Down
Expand Up @@ -8,29 +8,9 @@ TestApp.menuPanesController = SC.ObjectController.create({

status: '--',

showMenuPane: function(view) {
showShortMenuPane: function(view) {
var controller = this;

var subMenuItems = [
{
title: 'Sub item 1',
isEnabled: true,
target: this,
action: 'clickedMenuItem'
},
{
title: 'Sub item 2',
isEnabled: true,
target: this,
action: 'clickedMenuItem'
}
];

var subMenu = SC.MenuPane.create({
layout: { width: 200 },
items: subMenuItems
});

var items = [
{
title: 'Menu item 1',
Expand All @@ -54,16 +34,6 @@ TestApp.menuPanesController = SC.ObjectController.create({
target: this,
action: 'clickedMenuItem'
}
// TODO: Put back in menu item after figuring out how submenus work in SproutCore.
// There is some unique behavior when working menu panes and trying to click
// a menu item in a sub menu pane
// ,
// {
// title: 'Menu item 4',
// isEnabled: true,
// subMenu: subMenu,
// branchItem: true
// }
];

var anchor = TestApp.getPath('mainPage.menuPaneButton');
Expand All @@ -77,8 +47,34 @@ TestApp.menuPanesController = SC.ObjectController.create({
this.set('status', 'Opened SC.MenuPane');
},

clickedMenuItem: function(menuItem, pane) {
this.set('status', 'Clicked %@'.fmt(menuItem.getPath('content.title')));
showLongMenuPane: function(view) {
var controller = this;

var items = [];

for (var i = 0; i < 100; i += 1) {
items.push({
title: 'Menu item ' + i,
isEnabled: true,
target: this,
action: 'clickedMenuItem'
});
}

var anchor = TestApp.getPath('mainPage.menuPaneButton');
SC.MenuPane.create({
layout: { width: 200 },
items: items,
itemTitleKey: 'title',
itemValueKey: 'title',
itemActionKey: 'action'
}).popup(view);
this.set('status', 'Opened SC.MenuPane');
},


clickedMenuItem: function(pane) {
this.set('status', 'Clicked %@'.fmt(pane.getPath('selectedItem.title')));
}

});
Expand Up @@ -25,12 +25,8 @@ TestApp.palettePanesController = SC.ObjectController.create({
close: SC.ButtonView.design({
layout: { height: 25, left: 0, right: 0, bottom: 0 },
title: 'Close Pane',
action: function() {
var pane = this.get('pane');
var paneType = SC._object_className(pane.constructor);
TestApp.palettePanesController.set('status', 'Closed %@ - ID = %@'.fmt(paneType, pane.id));
pane.remove();
}
target: 'TestApp.palettePanesController',
action: 'removePalettePane'
})
})
}),
Expand All @@ -52,6 +48,13 @@ TestApp.palettePanesController = SC.ObjectController.create({
this.set('status', 'Created a SC.PalettePane - ID = %@'.fmt(this.nextPalettePaneId));
},

removePalettePane: function(view) {
var pane = view.get('pane');
var paneType = SC._object_className(pane.constructor);
TestApp.palettePanesController.set('status', 'Closed %@ - ID = %@'.fmt(paneType, pane.id));
pane.remove();
},

resetPalettePaneIdCounter: function() {
this.nextPalettePaneId = null;
}
Expand Down
Expand Up @@ -15,12 +15,8 @@ TestApp.pickerPanesController = SC.ObjectController.create({
close: SC.ButtonView.design({
layout: { width: 200, height: 25, centerX: 0, centerY: 0 },
title: 'Close Palette Pane',
action: function() {
var pane = this.get('pane');
var paneType = SC._object_className(pane.constructor);
TestApp.pickerPanesController.set('status', 'Closed %@'.fmt(paneType));
pane.remove();
}
target: 'TestApp.pickerPanesController',
action: 'closePickerPane'
})
}),

Expand All @@ -39,6 +35,13 @@ TestApp.pickerPanesController = SC.ObjectController.create({
layout: { width: 400, height: 200 },
contentView: this.modalPaneView
}).popup(anchor, type);
},

closePickerPane: function(view) {
var pane = view.get('pane');
var paneType = SC._object_className(pane.constructor);
TestApp.pickerPanesController.set('status', 'Closed %@'.fmt(paneType));
pane.remove();
}

});
Expand Up @@ -6,8 +6,11 @@

TestApp.radioControlsController = SC.Object.create({

resetMixedRadioView: function() {
TestApp.setPath('radioViewsPage.mainView.mixedStateRadioView.radio.value', [1]);
reset: function() {
var page = TestApp.get('radioViewsPage');
page.setPath('horizontalRadioView.value', null);
page.setPath('verticalRadioView.value', 'cat');
page.setPath('mixedStateRadioView.value', [1]);
}

});
@@ -0,0 +1,15 @@
// ==========================================================================
// Project: Lebowski Framework - The SproutCore Test Automation Framework
// License: Licensed under MIT license (see License.txt)
// ==========================================================================
/*globals TestApp Core */

TestApp.selectButtonControlsController = SC.Object.create({

reset: function() {
var page = TestApp.get('selectButtonViewsPage'), view;
page.setPath('basicSelectButtonView.value', 'One');
page.setPath('advancedSelectButtonView.value', 1);
}

});
Expand Up @@ -6,6 +6,20 @@

TestApp.alertPanesPage = SC.Page.design({

alertWarnButton: SC.outlet('mainView.alertPanes.alertWarn'),

alertErrorButton: SC.outlet('mainView.alertPanes.alertError'),

alertInfoButton: SC.outlet('mainView.alertPanes.alertInfo'),

alertPlainButton: SC.outlet('mainView.alertPanes.alertPlain'),

alertExtraButton: SC.outlet('mainView.alertPanes.alertExtraButton'),

alertOneButton: SC.outlet('mainView.alertPanes.alertOneButton'),

statusLabel: SC.outlet('mainView.statusLabel'),

mainView: SC.View.design({
layout: { top: 20, bottom: 0, left: 20, right: 20 },
childViews: 'statusLabel alertPanes'.w(),
Expand All @@ -14,7 +28,7 @@ TestApp.alertPanesPage = SC.Page.design({
layerId: 'alert-panes-status-label',
layout: {left: 0, top: 0, right: 0, height: 25 },
textAlign: SC.ALIGN_LEFT,
valueBinding: 'TestApp.alertPanesController.status'
valueBinding: SC.Binding.oneWay('TestApp.alertPanesController.status')
}),

alertPanes: SC.View.design({
Expand Down
Expand Up @@ -5,10 +5,16 @@
/*globals TestApp */

TestApp.menuPanesPage = SC.Page.design({

statusLabel: SC.outlet('mainView.statusLabel'),

shortMenuButton: SC.outlet('mainView.shortMenu'),

longMenuButton: SC.outlet('mainView.longMenu'),

mainView: SC.View.design({
layout: { top: 20, bottom: 0, left: 20, right: 20 },
childViews: 'statusLabel basicMenu'.w(),
childViews: 'statusLabel shortMenu longMenu'.w(),

statusLabel: SC.LabelView.design({
layerId: 'menu-panes-status-label',
Expand All @@ -17,12 +23,18 @@ TestApp.menuPanesPage = SC.Page.design({
valueBinding: 'TestApp.menuPanesController.status'
}),

basicMenu: SC.ButtonView.design({
layerId: 'basic-menu-pane',
shortMenu: SC.ButtonView.design({
layout: {left: 0, top: 30, width: 200, height: 25 },
title: 'Basic Menu Pane',
title: 'Short Menu Pane',
target: TestApp.menuPanesController,
action: 'showMenuPane'
action: 'showShortMenuPane'
}),

longMenu: SC.ButtonView.design({
layout: {left: 0, top: 60, width: 200, height: 25 },
title: 'Long Menu Pane',
target: TestApp.menuPanesController,
action: 'showLongMenuPane'
})
})

Expand Down

0 comments on commit e45a604

Please sign in to comment.