-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Closed
Changes from 9 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
21f8fc9
Merge branch 'timob-7170' into timob-7199
nebrius 44ed111
[TIMOB-7199] Implemented option dialog.
nebrius 94c9f9a
[TIMOB-7199] Finished option dialog implementation.
nebrius 0cf9b4e
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
nebrius File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.