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

Add ellipsis to overflowing layer item name #559 #577

Merged
merged 4 commits into from
Dec 6, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/css/toolbox-layers-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,30 @@

.layer-item {
position: relative;
display: flex;
height:24px;
line-height: 24px;
padding: 0 0 0 10px;
border-top: 1px solid #444;
cursor: pointer;
}

.layer-item .layer-name {
padding: 0 0 0 10px;
flex: 1 auto;
white-space: nowrap;
}

.layer-item .layer-name.overflowing-name {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's add en empty line before this new selector.

overflow: hidden;
text-overflow: ellipsis;
}

.layer-item:hover {
background : #222;
}

.layer-item-opacity {
position: absolute;
right: 8px;
padding-right: 8px;
}

.current-layer-item,
Expand Down
10 changes: 8 additions & 2 deletions src/js/controller/LayersListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,21 @@
});
var layerItem = pskl.utils.Template.createFromHTML(layerItemHtml);
this.layersListEl.insertBefore(layerItem, this.layersListEl.firstChild);
if (layerItem.offsetWidth < layerItem.scrollWidth) {
$(layerItem).find('.layer-name')
.addClass('overflowing-name')
.attr('title', layer.getName())
.tooltip();
}
};

ns.LayersListController.prototype.onClick_ = function (evt) {
var el = evt.target || evt.srcElement;
var index;
if (el.classList.contains('button')) {
this.onButtonClick_(el);
} else if (el.classList.contains('layer-item')) {
index = el.dataset.layerIndex;
} else if (el.classList.contains('layer-name')) {
index = pskl.utils.Dom.getData(el, 'layerIndex');
this.piskelController.setCurrentLayerIndex(parseInt(index, 10));
} else if (el.classList.contains('layer-item-opacity')) {
index = pskl.utils.Dom.getData(el, 'layerIndex');
Expand Down
2 changes: 1 addition & 1 deletion src/templates/layers-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3 class="toolbox-title layers-title">Layers
<script type="text/template" id="layer-item-template">
<li class="layer-item {{isselected:current-layer-item}}"
data-layer-index="{{layerindex}}">
{{layername}}
<span class="layer-name" data-placement="top">{{layername}}</span>
<span class="layer-item-opacity"
title="Layer opacity" rel="tooltip" data-placement="top">
{{opacity}}&#945;
Expand Down