Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timob 7199 Option dialog implementation #1360

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/OptionDialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Titanium.UI.OptionDialog
summary: The Option Dialog is created by <Titanium.UI.createOptionDialog> and allows you to show a modal dialog of one or more options to the user.
extends: Titanium.Proxy
since: "0.8"
platforms: [android, iphone, ipad]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should perhaps include all platforms explicitly, as before.

methods:
- name: show
summary: cause the dialog to become visible
Expand Down
4 changes: 2 additions & 2 deletions mobileweb/src/Ti/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ define("Ti/UI", ["Ti/_/dom", "Ti/_/Evented", "Ti/_/lang", "Ti/_/ready", "Ti/_/st
return new Ti.UI.Label(args);
},

createOptionDialog: function() {
console.debug('Method "Titanium.UI.createOptionDialog" is not implemented yet.');
createOptionDialog: function(args) {
return new Ti.UI.OptionDialog(args);
},

createPicker: function(args) {
Expand Down
3 changes: 3 additions & 0 deletions mobileweb/src/Ti/UI/AlertDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ define("Ti/UI/AlertDialog", ["Ti/_/declare", "Ti/_/Evented"], function(declare,
title: title,
index: index
});
if (index === self.cancel) {
button.domNode.className += " TiUIButtonCancel";
}
alertDialog.add(button);
button.addEventListener("singletap",function(){
alertWindow.close();
Expand Down
127 changes: 127 additions & 0 deletions mobileweb/src/Ti/UI/OptionDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
define("Ti/UI/OptionDialog", ["Ti/_/declare", "Ti/_/Evented"], function(declare, Evented) {

var undef;

return declare("Ti.UI.OptionDialog", Evented, {
show: function() {

// Create the window and a background to dim the current view
var optionsWindow = this._optionsWindow = Ti.UI.createWindow();
var dimmingView = Ti.UI.createView({
backgroundColor: "black",
opacity: 0,
left: 0,
top: 0,
right: 0,
bottom: 0
});
optionsWindow.add(dimmingView);

// Create the options dialog itself
var optionsDialog = Ti.UI.createView({
width: "100%",
height: "auto",
bottom: 0,
backgroundColor: "white",
layout: "vertical",
opacity: 0
});
optionsWindow.add(optionsDialog);

// Add the title
optionsDialog.add(Ti.UI.createLabel({
text: this.title,
font: {fontWeight: "bold"},
left: 5,
right: 5,
top: 5,
height: "auto",
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
}));

var self = this;
function addButton(title, index, bottom) {
var button = Ti.UI.createButton({
left: 5,
right: 5,
top: 5,
bottom: bottom,
height: "auto",
title: title,
index: index
});
if (index === self.destructive) {
button.domNode.className += " TiUIButtonDestructive";
} else if (index === self.cancel) {
button.domNode.className += " TiUIButtonCancel";
}
optionsDialog.add(button);
button.addEventListener("singletap",function(){
optionsWindow.close();
self._optionsWindow = undef;
self.fireEvent("click",{
index: index,
cancel: self.cancel,
destructive: self.destructive
});
});
}

// Add the buttons
var options = this.options,
i = 0;
if (require.is(options,"Array")) {
for (; i < options.length; i++) {
addButton(options[i], i, i === options.length - 1 ? 5 : 0);
}
}

// Show the options dialog
optionsWindow.open();

// Animate the background after waiting for the first layout to occur
setTimeout(function(){
optionsDialog.animate({
bottom: -optionsDialog._measuredHeight,
opacity: 1,
duration: 0
});
dimmingView.animate({
opacity: 0.5,
duration: 150
}, function(){
setTimeout(function(){
optionsDialog.animate({
bottom: 0,
duration: 150
});
},0);
});
},30);
},

properties: {

cancel: -1,

destructive: -1,

options: undef,

title: "",

titleid: {
get: function(value) {
console.debug('Property "Titanium.UI.optionsDialog#.titleid" is not implemented yet.');
return value;
},
set: function(value) {
console.debug('Property "Titanium.UI.optionsDialog#.titleid" is not implemented yet.');
return value;
}
}
}

});

});
80 changes: 80 additions & 0 deletions mobileweb/src/titanium.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,86 @@ textarea {
to(#fff));
}

.TiUIButtonDestructive {
background: -moz-linear-gradient(
top,
#f00 0%,
#f00 50%,
#a00);
background: -webkit-gradient(
linear, left top, left bottom,
from(#f00),
color-stop(0.50, #f00),
to(#a00));
color: white;
}

.TiUIButtonDestructive:hover {
background: -moz-linear-gradient(
top,
#f00 0%,
#f00 50%,
#700);
background: -webkit-gradient(
linear, left top, left bottom,
from(#f00),
color-stop(0.50, #f00),
to(#700));
}

.TiUIButtonDestructive:active {
background: -moz-linear-gradient(
top,
#a00 0%,
#f00 50%,
#f00);
background: -webkit-gradient(
linear, left top, left bottom,
from(#b00),
color-stop(0.50, #f00),
to(#f00));
}

.TiUIButtonCancel {
background: -moz-linear-gradient(
top,
#666 0%,
#666 50%,
#333);
background: -webkit-gradient(
linear, left top, left bottom,
from(#666),
color-stop(0.50, #666),
to(#333));
color: white;
}

.TiUIButtonCancel:hover {
background: -moz-linear-gradient(
top,
#666 0%,
#666 50%,
#222);
background: -webkit-gradient(
linear, left top, left bottom,
from(#666),
color-stop(0.50, #666),
to(#222));
}

.TiUIButtonCancel:active {
background: -moz-linear-gradient(
top,
#333 0%,
#666 50%,
#666);
background: -webkit-gradient(
linear, left top, left bottom,
from(#333),
color-stop(0.50, #666),
to(#666));
}

.TiUITab {
background-color: silver;
border: solid 1px black;
Expand Down
1 change: 1 addition & 0 deletions support/mobileweb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def __init__(self,project_dir,deploytype):
'Ti/UI/Button.js',
'Ti/UI/ImageView.js',
'Ti/UI/Label.js',
'Ti/UI/OptionDialog.js',
'Ti/UI/ScrollableView.js',
'Ti/UI/ScrollView.js',
'Ti/UI/Slider.js',
Expand Down