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 #6917 from crdlc/bug-805977
Browse files Browse the repository at this point in the history
Bug 805977 - Long app names should be dealt with in a better way [r=ving...
  • Loading branch information
vingtetun committed Jan 8, 2013
2 parents 3a21ed0 + 792df26 commit 1b1d055
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/homescreen/index.html
Expand Up @@ -45,6 +45,13 @@
<body data-mode="normal">
<div id="search-overlay"></div>
<div id="landing-overlay"></div>
<!-- This markup is just to detect text overflow with app names
because of pages are hidden after rendering -->
<div id="fake-icon">
<span id="fake-icon-name-wrapper" class="labelWrapper">
<span id="fake-icon-name"></span>
</span>
</div>

<section id="confirm-dialog">
<form role="dialog" data-type="confirm">
Expand Down
25 changes: 25 additions & 0 deletions apps/homescreen/js/page.js
Expand Up @@ -106,6 +106,7 @@ Icon.prototype = {
var label = this.label = document.createElement('span');
label.textContent = localizedName;
wrapper.appendChild(label);
this.applyOverflowTextMask();

icon.appendChild(wrapper);

Expand All @@ -129,6 +130,15 @@ Icon.prototype = {
}
},

applyOverflowTextMask: function icon_applyOverflowTextMask() {
var label = this.label;
if (TextOverflowDetective.check(label.textContent)) {
label.parentNode.classList.add('mask');
} else {
label.parentNode.classList.remove('mask');
}
},

fetchImageData: function icon_fetchImageData() {
var descriptor = this.descriptor;
var icon = descriptor.icon;
Expand Down Expand Up @@ -369,6 +379,8 @@ Icon.prototype = {
descriptor.localizedName = localizedName;
GridManager.markDirtyState();
}

this.applyOverflowTextMask();
},

/*
Expand Down Expand Up @@ -800,3 +812,16 @@ dockProto.getChildren = function dk_getChildren() {
};

HTMLCollection.prototype.indexOf = Array.prototype.indexOf;

const TextOverflowDetective = (function() {
var iconFakeWrapperWidht = document.querySelector('#fake-icon-name-wrapper').
offsetWidth;
var iconFakeLabel = document.querySelector('#fake-icon-name');

return {
check: function od_check(text) {
iconFakeLabel.textContent = text;
return iconFakeLabel.offsetWidth >= iconFakeWrapperWidht;
}
}
})();
9 changes: 9 additions & 0 deletions apps/homescreen/style/app_name_mask.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions apps/homescreen/style/grid.css
Expand Up @@ -75,12 +75,30 @@
word-wrap: break-word;
}

.apps ol > li > div > span.mask {
mask: url('app_name_mask.svg#fade_right_mask');
text-overflow: '';
}

/* text label */
.apps ol > li > div > span > span {
font-size: -moz-calc(5.75 * 0.226rem); /* was 5pt */
text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
}

/* These classes detect text overflow from JS code */
#fake-icon {
width: 8rem; /* Like li items */
position: fixed;
top: 200%; /* Outside viewport */
display: block;
}

#fake-icon-name {
font-size: -moz-calc(5.75 * 0.226rem);
text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
}

.labelWrapper {
color: #fff; /* App label color */
white-space: nowrap; /* NO new lines */
Expand Down

0 comments on commit 1b1d055

Please sign in to comment.