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-8446] Window open, close, focus, and blur events not firing when opened with tab.open() #2220

Merged
merged 11 commits into from
May 18, 2012
Merged
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions mobileweb/themes/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ html {
}

body {
background-color: #000;
display: block;
margin: 0;
overflow: hidden;
Expand Down
15 changes: 15 additions & 0 deletions mobileweb/themes/default/default.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.TiUITabBarContainer {
background-color: #aaa;
}

.TiUINavigationGroup {
background-color: #888;
}

.TiUINavigationGroupTop {
border-top: 1px solid #555;
}

.TiUINavigationGroupBottom {
border-bottom: 1px solid #555;
}
157 changes: 84 additions & 73 deletions mobileweb/titanium/Ti/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ define(
function(_, Evented, lang, ready, style, dom) {

var global = window,
body = document.body,
doc = document,
body = doc.body,
on = require.on,
modules = "2DMatrix,ActivityIndicator,AlertDialog,Animation,Button,EmailDialog,ImageView,Label,OptionDialog,Picker,PickerColumn,PickerRow,ProgressBar,ScrollableView,ScrollView,Slider,Switch,Tab,TabGroup,TableView,TableViewRow,TableViewSection,TextArea,TextField,View,WebView,Window",
creators = {},
Expand All @@ -16,6 +17,7 @@ define(
Ti.UI._recalculateLayout();
hidingAddressBar = 0;
},
splashScreen,
unitize = dom.unitize,
has = require.has;

Expand Down Expand Up @@ -71,36 +73,37 @@ define(
}

ready(10, function() {
var splashScreen = document.getElementById("splash"),
container = (Ti.UI._container = Ti.UI.createView({
var container = (Ti.UI._container = Ti.UI.createView({
left: 0,
top: 0
})),
node = container.domNode,
coefficients = container._layoutCoefficients;

coefficients.width.x1 = 1;
coefficients.height.x1 = 1;
container._measuredTop = 0;
container._measuredLeft = 0;
node.id = "TiUIContainer";
setStyle(node, "overflow", "hidden");
body.appendChild(node);
container.addEventListener("postlayout", function() {

(splashScreen = doc.getElementById("splash")) && container.addEventListener("postlayout", function(){
setTimeout(function(){
setStyle(splashScreen,{
position: "absolute",
width: unitize(container._measuredWidth),
height: unitize(container._measuredHeight),
left: "0px",
top: "0px",
right: "",
bottom: ""
left: 0,
top: 0,
right: '',
bottom: ''
});
},10);
}, 10);
});
hideAddressBar();
});

function updateOrientation() {
Ti.UI._recalculateLayout();
require("Ti/Gesture")._updateOrientation();
Expand All @@ -112,6 +115,10 @@ define(
_addWindow: function(win, set) {
this._container.add(win.modal ? win._modalParentContainer : win);
set && this._setWindow(win);

// as soon as we add a window or tabgroup, we can destroy the splash screen
splashScreen && dom.destroy(splashScreen);

return win;
},

Expand All @@ -123,32 +130,33 @@ define(
this._container.remove(win.modal ? win._modalParentContainer : win);
return win;
},

_layoutSemaphore: 0,

_nodesToLayout: [],

_startLayout: function() {
this._layoutSemaphore++;
},

_finishLayout: function() {
this._layoutSemaphore--;
if (this._layoutSemaphore === 0) {
if (--this._layoutSemaphore === 0) {
this._triggerLayout(true);
}
},

_elementLayoutCount: 0,

_triggerLayout: function(node, force) {
var self = this;

if (~self._nodesToLayout.indexOf(node)) {
return;
}

self._nodesToLayout.push(node);

function startLayout() {

self._elementLayoutCount = 0;
var nodes = self._nodesToLayout,
layoutNode,
Expand All @@ -163,64 +171,66 @@ define(
breakAfterChildrenCalculations,
container = self._container,
i,
j,
len = nodes.length;
has("ti-instrumentation") && (this._layoutInstrumentationTest = instrumentation.startTest("Layout"));


has("ti-instrumentation") && (this._layoutInstrumentationTest = instrumentation.startTest("Layout"));

// Determine which nodes need to be re-layed out
for (i = 0; i < len; i++) {
layoutNode = nodes[i];

// Mark all of the children for update that need to be updated
recursionStack = [layoutNode];
while (recursionStack.length > 0) {
node = recursionStack.pop();
node._markedForLayout = true;
children = node.children;
for (var j in children) {
child = children[j];
if (node.layout !== "composite" || child._needsMeasuring || node._layout._isDependentOnParent(child)) {
recursionStack.push(child);
if (layoutNode._isAttachedToActiveWin()) {
// Mark all of the children for update that need to be updated
recursionStack = [layoutNode];
while (recursionStack.length > 0) {
node = recursionStack.pop();
node._markedForLayout = true;
children = node.children;
for (j in children) {
child = children[j];
if (node.layout !== "composite" || child._needsMeasuring || node._layout._isDependentOnParent(child)) {
recursionStack.push(child);
}
}
}
}

if (layoutNode === container) {
layoutRootNode = true;
} else {
// Go up and mark any other nodes that need to be marked
parent = layoutNode;
while(1) {

parent._markedForLayout = true;
previousParent = parent;
parent = parent._parent;

// Check if this parent is the stopping point
breakAfterChildrenCalculations = false;
if (!parent || parent === container) {
layoutRootNode = true;
break;
} else if(!parent._hasSizeDimensions() && !parent._needsMeasuring) {
!parent._markedForLayout && !~rootNodesToLayout.indexOf(parent) && rootNodesToLayout.push(parent);
breakAfterChildrenCalculations = true;
}

// Recurse through the children of the parent
recursionStack = [parent];
while (recursionStack.length > 0) {
node = recursionStack.pop();
children = node.children;
for (var j in children) {
child = children[j];
if (child !== previousParent && (node.layout !== "composite" || child._needsMeasuring || node._layout._isDependentOnParent(child))) {
child._markedForLayout = true;
recursionStack.push(child);

if (layoutNode === container) {
layoutRootNode = true;
} else {
// Go up and mark any other nodes that need to be marked
parent = layoutNode;
while(1) {
parent._markedForLayout = true;
previousParent = parent;
parent = parent._parent;

// Check if this parent is the stopping point
breakAfterChildrenCalculations = false;
if (!parent || parent === container) {
layoutRootNode = true;
break;
} else if(!parent._hasSizeDimensions() && !parent._needsMeasuring) {
!parent._markedForLayout && !~rootNodesToLayout.indexOf(parent) && rootNodesToLayout.push(parent);
breakAfterChildrenCalculations = true;
}

// Recurse through the children of the parent
recursionStack = [parent];
while (recursionStack.length > 0) {
node = recursionStack.pop();
children = node.children;
for (j in children) {
child = children[j];
if (child !== previousParent && (node.layout !== "composite" || child._needsMeasuring || node._layout._isDependentOnParent(child))) {
child._markedForLayout = true;
recursionStack.push(child);
}
}
}
}

if (breakAfterChildrenCalculations) {
break;
if (breakAfterChildrenCalculations) {
break;
}
}
}
}
Expand All @@ -245,16 +255,17 @@ define(
node = rootNodesToLayout[i];
node._layout._doLayout(node, node._measuredWidth, node._measuredHeight, node._parent._layout._getWidth(node, node.width) === Ti.UI.SIZE, node._parent._layout._getHeight(node, node.height) === Ti.UI.SIZE);
}

has("ti-instrumentation") && instrumentation.stopTest(this._layoutInstrumentationTest,
self._elementLayoutCount + " out of approximately " + document.getElementById("TiUIContainer").getElementsByTagName("*").length + " elements laid out.");

self._layoutInProgress = false;
self._layoutTimer = null;
self._nodesToLayout = [];

self.fireEvent("postlayout");
}

if (force) {
clearTimeout(self._layoutTimer);
self._layoutInProgress = true;
Expand All @@ -264,7 +275,7 @@ define(
self._layoutTimer = setTimeout(startLayout, 10);
}
},

_recalculateLayout: function() {
var container = this._container;
if (container) {
Expand All @@ -286,7 +297,7 @@ define(
},
currentTab: void 0
},

convertUnits: function(convertFromValue, convertToUnits) {
var intermediary = dom.computeSize(convertFromValue, 0, false);
switch(convertToUnits) {
Expand Down
4 changes: 2 additions & 2 deletions mobileweb/titanium/Ti/UI/MobileWeb.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define(["Ti/_/Evented", "Ti/_/lang", "Ti/UI/MobileWeb/NavigationGroup"],
function(Evented, lang, NavigationGroup) {

return lang.setObject("Ti.UI.MobileWeb", Evented, {
createNavigationGroup: function(args) {
return new NavigationGroup(args);
}
});

});