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 #11385 from EverythingMe/evme-middle-squashed
Browse files Browse the repository at this point in the history
[Bug 838634] Move Evme to landing page [r=21]
  • Loading branch information
vingtetun committed Aug 6, 2013
2 parents 2c4e7fb + 1424b32 commit 06e7146
Show file tree
Hide file tree
Showing 26 changed files with 319 additions and 349 deletions.
2 changes: 2 additions & 0 deletions apps/homescreen/everything.me/config/config.js
Expand Up @@ -145,6 +145,7 @@ Evme.__config = {
"142": "music",
"355": "new-apps",
"245": "news",
"349": "photography",
"270": "recipes",
"220": "restaurants",
"238": "shopping",
Expand All @@ -154,6 +155,7 @@ Evme.__config = {
"352": "top-apps",
"306": "travel",
"213": "tv",
"357": "utilities",
"211": "video",
"249": "weather"
}
Expand Down
26 changes: 7 additions & 19 deletions apps/homescreen/everything.me/config/shortcuts.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/homescreen/everything.me/css/common.css
Expand Up @@ -7,6 +7,7 @@
bottom: 0;
left: 0;
width: 100%;
z-index: 100;
background: transparent;
background-size: 100% 100%;
font-weight: normal;
Expand Down
46 changes: 39 additions & 7 deletions apps/homescreen/everything.me/css/everything.me.css
@@ -1,14 +1,46 @@
#evmeContainer {
opacity: 0;
-moz-transition: opacity .3s ease;
display: none;
}

#loading-overlay {
#evme-activation-icon {
position: absolute;
top: 3.2rem;
left: 1.1rem;
right: 1.1rem;
z-index: 200;
-moz-transition: opacity .3s ease;
pointer-events: none;
vertical-align: middle;
}
#evme-activation-icon input {
position: relative;
width: 100%;
height: 3.6rem;
line-height: 3.6rem;
padding: 0.2rem 1.8rem 0.4rem 0.8rem;
border-radius: 0.2rem;
box-shadow: 0.1rem 0.1rem 0 0 #ccc inset, 0 0 0 0.1rem rgba(0, 0, 0, .3);
font-size: 1.5rem;
vertical-align: middle;
border: none;
display: inline;
-moz-box-sizing: border-box;
background: #ffffff url('/everything.me/images/search-icon.png') 98% 50% no-repeat;
background-size: 1.6rem 1.6rem;
}

#loading-overlay > section {
visibility: hidden;

.evme-loaded #evmeContainer {
display: block;
}
.evme-loaded #evme-activation-icon {
display: none;
}

.evme-loading #footer,
.evme-has-results #footer,
.evme-display-shortcuts #footer {
display: none;
}

body:not(.evme-displayed) #footer {
display: block;
}
61 changes: 48 additions & 13 deletions apps/homescreen/everything.me/js/Brain.js
Expand Up @@ -26,6 +26,10 @@ Evme.Brain = new function Evme_Brain() {
TIMEOUT_BEFORE_RUNNING_IMAGE_SEARCH = 800,
TIMEOUT_BEFORE_AUTO_RENDERING_MORE_APPS = 200,
TIMEOUT_BEFORE_SHOWING_APPS_LOADING = 800,

CLASS_WHEN_LOADED = 'evme-loaded',
CLASS_WHEN_HAS_RESULTS = 'evme-has-results',
CLASS_WHEN_SHOWING_SHORTCUTS = 'evme-display-shortcuts',

L10N_SYSTEM_ALERT="alert",

Expand All @@ -41,13 +45,22 @@ Evme.Brain = new function Evme_Brain() {
DISPLAY_INSTALLED_APPS = "FROM_CONFIG",

INSTALLED_APPS_TO_TYPE = {
"music": ["FM Radio", "Music", "Video"],
"games": ["Marketplace", "CrystalSkull", "PenguinPop", "TowerJelly"],
"maps": ["Maps"],
"productivity": ["Calendar", "Clock"],
"utilities": ["Calendar", "Clock", "Browser", "Settings", "Marketplace"],
"email": ["E-mail"],
"internet": ["Browser", "Settings"],
"photography": ["Gallery", "Camera"],
"images": ["Gallery", "Camera"],
"music": ["FM Radio", "Music", "Video"],
"radio": ["FM Radio", "Music"],
"video": ["Video", "Camera"],
"local": ["Maps", "FM Radio"]
"social": ["Messages"],
"personal communication": ["Messages"],
"tv": ["Video"],
"funny": ["Video"],
"games": ["Marketplace", "CrystalSkull", "PenguinPop", "TowerJelly"],
"maps": ["Here Maps"],
"local": ["Here Maps"]
},

timeoutSetUrlAsActive = null,
Expand Down Expand Up @@ -131,6 +144,8 @@ Evme.Brain = new function Evme_Brain() {
Brain.Searchbar.setEmptyClass();

Evme.Shortcuts.show();

document.body.classList.add(CLASS_WHEN_LOADED);
};
};

Expand All @@ -150,17 +165,17 @@ Evme.Brain = new function Evme_Brain() {
Evme.Helper.showSuggestions();
} else {
Brain.Helper.showDefault();
document.body.classList.add(CLASS_WHEN_SHOWING_SHORTCUTS);
}
};

// Searchbar blurred. Keyboard hides.
this.blur = function blur(data) {
// Gaia bug workaround because of this http://b2g.everything.me/tests/input-blur.html
if (data && data.e) {
if (data && data.e && data.e.stopPropagation) {
data.e.stopPropagation();
}


var didClickApp = false,
elClicked = data && data.e && data.e.explicitOriginalTarget;
if (elClicked) {
Expand Down Expand Up @@ -212,6 +227,8 @@ Evme.Brain = new function Evme_Brain() {
Evme.Apps.clear();
Evme.Helper.setTitle();
Brain.Helper.showDefault();
document.body.classList.remove(CLASS_WHEN_HAS_RESULTS);
document.body.classList.add(CLASS_WHEN_SHOWING_SHORTCUTS);
};

// Keyboard action key ("search") pressed
Expand All @@ -226,8 +243,12 @@ Evme.Brain = new function Evme_Brain() {

if (!query) {
elContainer.classList.add("empty-query");
document.body.classList.remove(CLASS_WHEN_HAS_RESULTS);
document.body.classList.add(CLASS_WHEN_SHOWING_SHORTCUTS);
} else {
elContainer.classList.remove("empty-query");
document.body.classList.add(CLASS_WHEN_HAS_RESULTS);
document.body.classList.remove(CLASS_WHEN_SHOWING_SHORTCUTS);
}
};

Expand Down Expand Up @@ -274,6 +295,15 @@ Evme.Brain = new function Evme_Brain() {
};
};

// modules/SearchHistory/
this.SearchHistory = new function SearchHistory() {

// items were loaded from the cache
this.populate = function populate() {
Evme.Brain.Helper.showDefault();
};
};

// modules/Helper/
this.Helper = new function Helper() {
var self = this,
Expand Down Expand Up @@ -1236,13 +1266,17 @@ Evme.Brain = new function Evme_Brain() {
// item clicked
this.click = function click(data) {
if(!Evme.Shortcuts.isEditing && !Evme.Shortcuts.isSwiping()) {
new Evme.SmartFolder({
"query": data.shortcut.getQuery(),
"experienceId": data.shortcut.getExperience(),
"bgImage": (Evme.BackgroundImage.get() || {}).image,
"elParent": elContainer,
"onScrollEnd": Evme.Brain.SmartFolder.loadMoreApps
}).show();
// get the shortcut's query
var query = data.shortcut.getQuery(),
experienceId = data.shortcut.getExperience();

// if there isn't a query - translate the experienceId to a query
if (!query) {
query = Evme.Utils.l10n('shortcut', 'id-' + Evme.Utils.shortcutIdToKey(experienceId));
}

// now set the query in the searchbar and perform the exact search
Searcher.searchExactFromOutside(query, SEARCH_SOURCES.SHORTCUT_SMART_FOLDER);
}
};

Expand Down Expand Up @@ -1948,6 +1982,7 @@ Evme.Brain = new function Evme_Brain() {
this.empty = function empty(){
Searcher.cancelRequests();
Evme.Apps.clear();
Evme.BackgroundImage.loadDefault();
resetLastSearch();
lastQueryForImage = "";

Expand Down
51 changes: 46 additions & 5 deletions apps/homescreen/everything.me/js/Core.js
Expand Up @@ -3,7 +3,9 @@ window.Evme = new function Evme_Core() {
recalculateHeightRetries = 1,
TIMEOUT_BEFORE_INIT_SESSION = "FROM CONFIG",
OPACITY_CHANGE_DURATION = 300,
head_ts = new Date().getTime();
head_ts = new Date().getTime(),

CLASS_WHEN_SHOWING_SHORTCUTS = 'evme-display-shortcuts';

this.shouldSearchOnInputBlur = true;

Expand All @@ -14,6 +16,8 @@ window.Evme = new function Evme_Core() {
apiHost && Evme.api.setHost(apiHost);

TIMEOUT_BEFORE_INIT_SESSION = data.timeoutBeforeSessionInit;

window.addEventListener('contextmenu', onContextMenu, true);

Evme.Brain.init({
"numberOfAppsToLoad": data.numberOfAppsToLoad+(Evme.Utils.devicePixelRatio>1? data.apps.appsPerRow: 0),
Expand All @@ -40,16 +44,44 @@ window.Evme = new function Evme_Core() {
this.pageMove = function pageMove(value) {
Evme.BackgroundImage.changeOpacity(Math.floor(value*100)/100);
};

this.onSwipeFromPage = function onSwipeFromPage() {

};

this.onHomeButtonPress = function onHomeButtonPress() {
Evme.Searchbar.clearIfHasQuery();
Evme.Searchbar.blur();

if (
Evme.BackgroundImage.closeFullScreen() ||
Evme.Brain.Shortcuts.hideIfEditing() ||
Evme.Brain.ShortcutsCustomize.hideIfOpen() ||
Evme.Brain.ShortcutsCustomize.hideIfRequesting()
) {
// return true to prevent homescreen from performing its own home button actions
return true;
}

document.body.classList.remove(CLASS_WHEN_SHOWING_SHORTCUTS);

// return false to allow homescreen to perform its own home button actions
return false;
};

this.searchFromOutside = function searchFromOutside(query) {
Evme.Brain.Searcher.searchExactFromOutside(query);
};
this.onShow = function onShow() {
self.displayed = true;
document.body.classList.add('evme-displayed');
};
this.onHide = function onHide() {
self.displayed = false;
document.body.classList.remove('evme-displayed');

Evme.Brain.Shortcuts.doneEdit();
Evme.Brain.SmartFolder.closeCurrent();
Evme.Shortcuts.scrollTo(0,0);
Evme.Searchbar.blur();
document.body.classList.remove(CLASS_WHEN_SHOWING_SHORTCUTS);
Evme.Brain.Shortcuts.hideIfEditing();
};

this.onHideStart = function onHideStart(source) {
Expand All @@ -69,6 +101,15 @@ window.Evme = new function Evme_Core() {
Evme.Searchbar.blur();
return false; // allow navigation to homescreen
};

function onContextMenu(e) {
if (self.displayed &&
(Evme.Searchbar.getValue() ||
document.body.classList.contains(CLASS_WHEN_SHOWING_SHORTCUTS))
) {
e.stopImmediatePropagation();
}
}

function initObjects(data) {
Evme.Features.init({
Expand Down

0 comments on commit 06e7146

Please sign in to comment.