diff --git a/app/scripts/models/entry-model.js b/app/scripts/models/entry-model.js index eeabb915..841976f5 100644 --- a/app/scripts/models/entry-model.js +++ b/app/scripts/models/entry-model.js @@ -41,6 +41,7 @@ var EntryModel = Backbone.Model.extend({ this.expires = entry.times.expires ? entry.times.expiryTime : undefined; this.expired = entry.times.expires && entry.times.expiryTime <= new Date(); this.historyLength = entry.history.length; + this._buildCustomIcon(); this._buildSearchText(); this._buildSearchTags(); this._buildSearchColor(); @@ -62,6 +63,16 @@ var EntryModel = Backbone.Model.extend({ this.searchText = text; }, + _buildCustomIcon: function() { + this.customIcon = null; + if (this.entry.customIcon) { + var iconData = this.file.db.meta.customIcons[this.entry.customIcon]; + if (iconData) { + this.customIcon = kdbxweb.ByteUtils.bytesToBase64(iconData); + } + } + }, + _buildSearchTags: function() { this.searchTags = this.entry.tags.map(function(tag) { return tag.toLowerCase(); }); }, diff --git a/app/scripts/presenters/entry-presenter.js b/app/scripts/presenters/entry-presenter.js index b5b4584b..b1ecacca 100644 --- a/app/scripts/presenters/entry-presenter.js +++ b/app/scripts/presenters/entry-presenter.js @@ -18,6 +18,7 @@ EntryPresenter.prototype = { }, get id() { return this.entry ? this.entry.id : this.group.get('id'); }, get icon() { return this.entry ? this.entry.icon : (this.group.get('icon') || 'folder'); }, + get customIcon() { return this.entry ? this.entry.customIcon : undefined; }, get color() { return this.entry ? this.entry.color : undefined; }, get title() { return this.entry ? this.entry.title : this.group.get('title'); }, get notes() { return this.entry ? this.entry.notes : undefined; }, diff --git a/app/styles/areas/_list.scss b/app/styles/areas/_list.scss index 989509d3..6c1fbcd6 100644 --- a/app/styles/areas/_list.scss +++ b/app/styles/areas/_list.scss @@ -91,11 +91,27 @@ .list__item-title, .list__item-descr { text-decoration: line-through; } } - i { + &-icon { width: 16px; + height: 16px; + &--custom { + @include filter(grayscale(1)); + vertical-align: text-bottom; + // TODO: find more suitable colors + &.yellow { @include filter(grayscale(1) sepia(1) hue-rotate(20deg) brightness(0.4) saturate(3) brightness(2)); } + &.green { @include filter(grayscale(1) sepia(1) hue-rotate(70deg) brightness(.5) saturate(2) brightness(1.3)); } + &.red { @include filter(grayscale(1) sepia(1) hue-rotate(320deg) brightness(0.6) saturate(4) brightness(1)); } + &.orange { @include filter(grayscale(1) sepia(1) hue-rotate(340deg) brightness(.4) saturate(3) brightness(1.8)); } + &.blue { @include filter(grayscale(1) sepia(1) hue-rotate(170deg) brightness(0.3) saturate(3) brightness(2)); } + &.violet { @include filter(grayscale(1) sepia(1) hue-rotate(240deg) brightness(0.8) saturate(2.7) brightness(.9)); } + } } - .list__item-descr { + &-title { + margin-left: 2px; + } + + &-descr { font-size: .8em; @include th { color: muted-color(); } display: block; diff --git a/app/templates/list-item-short.html b/app/templates/list-item-short.html index 1c1e6f55..0e671505 100644 --- a/app/templates/list-item-short.html +++ b/app/templates/list-item-short.html @@ -1,4 +1,5 @@
- <%- title || '(no title)' %><%- description %> + <% if (customIcon) { %><% } + else { %><% } %> + <%- title || '(no title)' %><%- description %>