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 8019 Modal bug fix. #1685

Merged
merged 6 commits into from
Mar 15, 2012
Merged
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
8 changes: 8 additions & 0 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ properties:
window they are opened over do not support. Doing otherwise *may* cause
bad visual/redraw behavior after the modal is dismissed, due to how
iOS manages modal transitions.

Mobile Web note: On Mobile Web, windows are always modal, blocking input to underlying
windows. If the window does not occupy the full screen, setting `modal` to `true` provides
a visual cue by dimming any background windows. If the window occupies the full screen,
`modal` has no effect.

On Mobile Web and iOS, the modal property has no effect on whether the window is
translucent or opaque.
type: Boolean
default: false

Expand Down
4 changes: 2 additions & 2 deletions mobileweb/titanium/Ti/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ define(
return lang.setObject("Ti.UI", Evented, creators, {

_addWindow: function(win, set) {
this._container.add(win);
this._container.add(win.modal ? win._modalParentContainer : win);
set && this._setWindow(win);
return win;
},
Expand All @@ -67,7 +67,7 @@ define(
},

_removeWindow: function(win) {
this._container.remove(win);
this._container.remove(win.modal ? win._modalParentContainer : win);
return win;
},

Expand Down
49 changes: 29 additions & 20 deletions mobileweb/titanium/Ti/UI/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,40 @@ define(["Ti/_/declare", "Ti/Gesture", "Ti/Locale", "Ti/_/UI/SuperView", "Ti/UI"]
}
},

open: function(args) {
if (this.modal) {
UI._addWindow(this._modalWin = UI.createView({
backgroundColor: UI.backgroundColor,
backgroundImage: UI.backgroundImage
})).show();
}
SuperView.prototype.open.call(this, args);
},

close: function(args) {
var mw = this._modalWin;
if (mw) {
UI._removeWindow(mw).destroy();
this._modalWin = null;
}
SuperView.prototype.close.call(this, args);
},

constants: {
url: undef
},

properties: {
modal: undef,
modal: {
set: function(value, oldValue) {
if (value !== oldValue) {
if (value) {
var parentContainer = this._modalParentContainer = UI.createView();
parentContainer.add(UI.createView({
backgroundColor: "#000",
opacity: 0.5
}));
parentContainer.add(this._modalContentContainer = UI.createView({
width: UI.SIZE,
height: UI.SIZE,
}));
this._modalContentContainer.add(this);
} else if (this._modalParentContainer) {
if (this._modalParentContainer._opened) {
this._modalParentContainer.close();
}
this._modalContentContainer.remove(this);
this._modalParentContainer = null;
if (this._opened) {
this.close(); // Close to reset state...at this point it's not attached to the window anymore, but thinks it's still open
this.open();
}
}
}
return value;
}
},

orientation: {
get: function() {
Expand Down