Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #26095 from alivedise/bugzilla/1097503/shadow-stat…
Browse files Browse the repository at this point in the history
…usbar

Bug 1097503 - Implement ShadowStatusbar, r=etienne/kgrandon
  • Loading branch information
alivedise committed Nov 19, 2014
2 parents 37b6db1 + c12c1d5 commit fc4d17e
Show file tree
Hide file tree
Showing 16 changed files with 528 additions and 431 deletions.
1 change: 1 addition & 0 deletions apps/system/index.html
Expand Up @@ -373,6 +373,7 @@
<script defer src="js/app_modal_dialog.js"></script>
<script defer src="js/app_chrome.js"></script>
<script defer src="js/attention_toaster.js"></script>
<script defer src="js/app_statusbar.js"></script>
<script defer src="js/app_transition_controller.js"></script>
<script defer src="js/app_authentication_dialog.js"></script>
<script defer src="js/text_selection_dialog.js"></script>
Expand Down
15 changes: 5 additions & 10 deletions apps/system/js/activity_window.js
Expand Up @@ -88,6 +88,8 @@

ActivityWindow.prototype = Object.create(AppWindow.prototype);

ActivityWindow.prototype.constructor = ActivityWindow;

ActivityWindow.prototype.eventPrefix = 'activity';

ActivityWindow.prototype.CLASS_NAME = 'ActivityWindow';
Expand Down Expand Up @@ -166,11 +168,6 @@
_id++;
return '<div class="appWindow activityWindow inline-activity' +
'" id="' + this.instanceID + '">' +
'<div class="titlebar">' +
' <div class="notifications-shadow"></div>' +
' <div class="statusbar-shadow titlebar-maximized"></div>' +
' <div class="statusbar-shadow titlebar-minimized"></div>' +
'</div>' +
'<div class="fade-overlay"></div>' +
'<div class="browser-container">' +
' <div class="screenshot-overlay"></div>' +
Expand All @@ -184,13 +181,11 @@
'valueSelector': window.ValueSelector,
'authDialog': window.AppAuthenticationDialog,
'contextmenu': window.BrowserContextMenu,
'childWindowFactory': window.ChildWindowFactory
'childWindowFactory': window.ChildWindowFactory,
'statusbar': window.AppStatusbar
};

ActivityWindow.REGISTERED_EVENTS =
['mozbrowserclose', 'mozbrowsererror', 'mozbrowservisibilitychange',
'mozbrowserloadend', 'mozbrowseractivitydone', 'mozbrowserloadstart',
'_localized'];
ActivityWindow.REGISTERED_EVENTS = AppWindow.REGISTERED_EVENTS;

ActivityWindow.prototype._handle_mozbrowseractivitydone =
function aw__handle_mozbrowseractivitydone() {
Expand Down
173 changes: 173 additions & 0 deletions apps/system/js/app_statusbar.js
@@ -0,0 +1,173 @@
/* global BaseUI, TouchForwarder */

'use strict';

(function(exports) {
var AppStatusbar = function(app) {
this.app = app;
this.containerElement = app.element;
this.render();
this._fetchAllElements();
this._touchForwarder = new TouchForwarder();
this._touchForwarder.destination = this.app.browser.element;
};

AppStatusbar.prototype = Object.create(BaseUI.prototype);
AppStatusbar.prototype.constructor = AppStatusbar;
AppStatusbar.prototype.EVENT_PREFIX = 'appstatusbar';
AppStatusbar.prototype.DEBUG = false;
AppStatusbar.prototype.view = function() {
return '<div class="titlebar">' +
' <div class="notifications-shadow"></div>' +
' <div class="statusbar-shadow titlebar-maximized"></div>' +
' <div class="statusbar-shadow titlebar-minimized"></div>' +
'</div>';
};
AppStatusbar.prototype.RELEASE_TIMEOUT = 5000;
AppStatusbar.prototype.screen = document.getElementById('screen');

AppStatusbar.prototype._fetchAllElements = function(first_argument) {
this.titleBar = this.containerElement.querySelector('.titlebar');
};

AppStatusbar.prototype.handleStatusbarTouch = function(evt, barHeight) {
this.app.debug('preprocessing touch event...', evt.type);
var touch;
var cacheHeight = barHeight;
if (!this.chromeBar) {
// Because app chrome is loaded after us.
this.chromeBar = this.app.element.querySelector('.chrome');
}
if (this._dontStopEvent) {
return;
}
// If system is at fullscreen mode, let utility tray to handle the event.
if (!this.app || (!this.app.isFullScreen() && !document.mozFullScreen)) {
return;
}
this.app.debug('processing touch event...', evt.type);

evt.stopImmediatePropagation();
evt.preventDefault();
switch (evt.type) {
case 'touchstart':
clearTimeout(this._releaseTimeout);
this._touchStart = evt;
this._shouldForwardTap = true;

touch = evt.changedTouches[0];
this._startX = touch.clientX;
this._startY = touch.clientY;

this.chromeBar.style.transition = 'transform';
this.titleBar.style.transition = 'transform';
break;

case 'touchmove':
touch = evt.touches[0];
var height = cacheHeight;
var deltaX = touch.clientX - this._startX;
var deltaY = touch.clientY - this._startY;

if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
this._shouldForwardTap = false;
}

var translate = Math.min(deltaY, height);
var heightThreshold = height;

if (this.app && this.app.isFullScreen() && this.app.config.chrome &&
this.app.config.chrome.navigation) {
translate = Math.min(deltaY, this.app.appChrome.height);
heightThreshold = this.app.appChrome.height;

this.titleBar.style.transform = 'translateY(calc(' +
(translate - this.app.appChrome.height) + 'px)';
} else {
this.titleBar.style.transform =
'translateY(calc(' + translate + 'px - 100%)';
}
this.chromeBar.style.transform =
'translateY(calc(' + translate + 'px - 100%)';

this.app.debug(translate, heightThreshold);
if (translate >= heightThreshold) {
if (this._touchStart) {
this._touchForwarder.forward(this._touchStart);
this._touchStart = null;
}
this._touchForwarder.forward(evt);
}
break;

case 'touchend':
clearTimeout(this._releaseTimeout);

if (this._touchStart) {
if (this._shouldForwardTap) {
this._touchForwarder.forward(this._touchStart);
this._touchForwarder.forward(evt);
this._touchStart = null;
}
this._releaseBar();
} else {
this._dontStopEvent = true;
this._touchForwarder.forward(evt);
this._releaseAfterTimeout();
}
break;
}
};

AppStatusbar.prototype._releaseBar = function() {
this.app.debug('releasing statusbar');
this._dontStopEvent = false;
var titleBar = this.titleBar;
var chromeBar = this.chromeBar;

chromeBar.classList.remove('dragged');
chromeBar.style.transform = '';
chromeBar.style.transition = '';

titleBar.classList.remove('dragged');
titleBar.style.transform = '';
titleBar.style.transition = '';

this.screen.classList.remove('minimized-tray');

clearTimeout(this._releaseTimeout);
this._releaseTimeout = null;
};

AppStatusbar.prototype._releaseAfterTimeout = function() {
this.app.debug('stay until 5s');
this.screen.classList.add('minimized-tray');
var chromeBar = this.chromeBar;
var titleBar = this.titleBar;

var self = this;
titleBar.style.transform = '';
titleBar.style.transition = '';
titleBar.classList.add('dragged');

chromeBar.style.transform = '';
chromeBar.style.transition = '';
chromeBar.classList.add('dragged');

self._releaseTimeout = setTimeout(function() {
self._releaseBar();
window.removeEventListener('touchstart', closeOnTap);
}, this.RELEASE_TIMEOUT);

function closeOnTap(evt) {
if (evt.target != self._touchForwarder.destination) {
return;
}
window.removeEventListener('touchstart', closeOnTap);
self.app.debug('user interaction, will release statusbar.');
self._releaseBar(titleBar);
}
window.addEventListener('touchstart', closeOnTap);
};
exports.AppStatusbar = AppStatusbar;
}(window));
17 changes: 12 additions & 5 deletions apps/system/js/app_window.js
Expand Up @@ -520,11 +520,6 @@
return '<div class=" ' + this.CLASS_LIST +
' " id="' + this.instanceID +
'" transition-state="closed">' +
'<div class="titlebar">' +
' <div class="notifications-shadow"></div>' +
' <div class="statusbar-shadow titlebar-maximized"></div>' +
' <div class="statusbar-shadow titlebar-minimized"></div>' +
'</div>' +
'<div class="identification-overlay">' +
'<div>' +
'<div class="icon"></div>' +
Expand Down Expand Up @@ -733,6 +728,7 @@
'authDialog': window.AppAuthenticationDialog,
'contextmenu': window.BrowserContextMenu,
'childWindowFactory': window.ChildWindowFactory,
'statusbar': window.AppStatusbar
};

AppWindow.prototype.openAnimation = 'enlarge';
Expand Down Expand Up @@ -2193,5 +2189,16 @@
}
this.setVisible(false);
};

/**
* Statusbar will bypass touch event to us via this method
* @param {Object} evt Touch event object
* @param {Number} barHeight The height of the statusbar
*/
AppWindow.prototype.handleStatusbarTouch = function(evt, barHeight) {
if (this.statusbar) {
this.statusbar.handleStatusbarTouch(evt, barHeight);
}
};
exports.AppWindow = AppWindow;
}(window));
7 changes: 2 additions & 5 deletions apps/system/js/attention_window.js
Expand Up @@ -90,10 +90,6 @@
this.debug('intance id: ' + this.instanceID);
return '<div class="' + this.CLASS_LIST +
'" id="' + this.instanceID + '">' +
'<div class="titlebar">' +
' <div class="statusbar-shadow titlebar-maximized"></div>' +
' <div class="statusbar-shadow titlebar-minimized"></div>' +
'</div>' +
'<div class="browser-container"></div>' +
'<div class="screenshot-overlay"></div>' +
'</div>';
Expand All @@ -103,7 +99,8 @@
'transitionController': window.AppTransitionController,
'modalDialog': window.AppModalDialog,
'authDialog': window.AppAuthenticationDialog,
'attentionToaster': window.AttentionToaster
'attentionToaster': window.AttentionToaster,
'stautsbar': window.AppStatusbar
};

AttentionWindow.REGISTERED_EVENTS =
Expand Down
3 changes: 3 additions & 0 deletions apps/system/js/hierarchy_manager.js
Expand Up @@ -8,6 +8,9 @@
'registerHierarchy',
'unregisterHierarchy'
];
HierarchyManager.STATES = [
'getTopMostWindow'
];
BaseModule.create(HierarchyManager, {
name: 'HierarchyManager',
EVENT_PREFIX: 'hierachy',
Expand Down
15 changes: 5 additions & 10 deletions apps/system/js/homescreen_window.js
Expand Up @@ -70,6 +70,8 @@

HomescreenWindow.prototype = Object.create(AppWindow.prototype);

HomescreenWindow.prototype.constructor = HomescreenWindow;

HomescreenWindow.prototype._DEBUG = false;

HomescreenWindow.prototype.CLASS_NAME = 'HomescreenWindow';
Expand Down Expand Up @@ -102,17 +104,15 @@
this.isHomescreen = true;
};

HomescreenWindow.REGISTERED_EVENTS =
['_opening', '_localized', 'mozbrowserclose', 'mozbrowsererror',
'mozbrowservisibilitychange', 'mozbrowserloadend', '_orientationchange',
'_focus'];
HomescreenWindow.REGISTERED_EVENTS = AppWindow.REGISTERED_EVENTS;

HomescreenWindow.SUB_COMPONENTS = {
'transitionController': window.AppTransitionController,
'modalDialog': window.AppModalDialog,
'valueSelector': window.ValueSelector,
'authDialog': window.AppAuthenticationDialog,
'childWindowFactory': window.ChildWindowFactory
'childWindowFactory': window.ChildWindowFactory,
'statusbar': window.AppStatusbar
};

HomescreenWindow.prototype.openAnimation = 'zoom-out';
Expand Down Expand Up @@ -165,11 +165,6 @@

HomescreenWindow.prototype.view = function hw_view() {
return '<div class="appWindow homescreen" id="homescreen">' +
'<div class="titlebar">' +
' <div class="notifications-shadow"></div>' +
' <div class="statusbar-shadow titlebar-maximized"></div>' +
' <div class="statusbar-shadow titlebar-minimized"></div>' +
'</div>' +
'<div class="fade-overlay"></div>' +
'<div class="browser-container"></div>' +
'</div>';
Expand Down
9 changes: 9 additions & 0 deletions apps/system/js/lockscreen_window.js
Expand Up @@ -44,6 +44,15 @@
*/
LockScreenWindow.prototype = Object.create(AppWindow.prototype);

LockScreenWindow.prototype.constructor = LockScreenWindow;

LockScreenWindow.SUB_COMPONENTS = {
'transitionController': window.AppTransitionController,
'statusbar': window.AppStatusbar
};

LockScreenWindow.REGISTERED_EVENTS = AppWindow.REGISTERED_EVENTS;

/**
* We still need this before we put the lockreen inside an iframe.
*
Expand Down
3 changes: 2 additions & 1 deletion apps/system/js/popup_window.js
Expand Up @@ -41,7 +41,8 @@
'valueSelector': window.ValueSelector,
'authDialog': window.AppAuthenticationDialog,
'contextmenu': window.BrowserContextMenu,
'childWindowFactory': window.ChildWindowFactory
'childWindowFactory': window.ChildWindowFactory,
'statusbar': window.AppStatusbar
};

/**
Expand Down

0 comments on commit fc4d17e

Please sign in to comment.