1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 07:08:55 +00:00

Improve library icon

This commit is contained in:
Daniel Pan
2016-03-11 12:10:55 +08:00
parent 565c05ee66
commit 0931bd0103
14 changed files with 66 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

BIN
media/img/lib/24/lib.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
media/img/lib/96/lib.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -31,9 +31,9 @@
<script type="text/template" id="repo-tmpl">
<td>
<% if (encrypted) { %>
<img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Encrypted" %}" alt="" width="24" />
<% } else { %>
<img src="{{ MEDIA_URL }}img/sync-folder-20.png" title="{% trans "Read-Write" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Read-Write" %}" alt="" width="24" />
<% } %>
</td>
<% if (name) { %>
@@ -68,12 +68,12 @@
<script type="text/template" id="group-repo-tmpl">
<td>
<% if (encrypted) { %>
<img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Encrypted" %}" alt="" width="24" />
<% } else { %>
<% if (permission == 'rw') { %>
<img src="{{ MEDIA_URL }}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Read-Write" %}" alt="" width="24" />
<% } else { %>
<img src="{{ MEDIA_URL }}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Read-Only" %}" alt="" width="24" />
<% } %>
<% } %>
</td>
@@ -92,12 +92,12 @@
<script type="text/template" id="organization-repo-tmpl">
<td>
<% if (encrypted) { %>
<img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Encrypted" %}" alt="" width="24" />
<% } else { %>
<% if (permission == 'rw') { %>
<img src="{{ MEDIA_URL }}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Read-Write" %}" alt="" width="24" />
<% } else { %>
<img src="{{ MEDIA_URL }}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
<img src="<%- icon_url %>" title="{% trans "Read-Only" %}" alt="" width="24" />
<% } %>
<% } %>
</td>
@@ -604,12 +604,12 @@
<script type="text/template" id="shared-repo-tmpl">
<td>
<% if (encrypted) { %>
<img src="{{MEDIA_URL}}img/sync-folder-encrypt-20.png" title="{% trans "Read-Write" %}" alt="{% trans "directory icon" %}" />
<img src="<%- icon_url %>" title="{% trans "Read-Write" %}" alt="" width="24" />
<% } else { %>
<% if (permission == 'rw') { %>
<img src="{{MEDIA_URL}}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="{% trans "directory icon" %}" />
<img src="<%- icon_url %>" title="{% trans "Read-Write" %}" alt="" width="24" />
<% } else { %>
<img src="{{MEDIA_URL}}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="{% trans "directory icon" %}" />
<img src="<%- icon_url %>" title="{% trans "Read-Only" %}" alt="" width="24" />
<% } %>
<% } %>
</td>

View File

@@ -1,7 +1,8 @@
define([
'underscore',
'backbone'
], function(_, Backbone) {
'backbone',
'common'
], function(_, Backbone, Common) {
'use strict';
var Repo = Backbone.Model.extend({
@@ -14,7 +15,8 @@ define([
mtime_relative: "",
encrypted: false,
owner: "-",
owner_nickname: "-"
owner_nickname: "-",
permission: "rw"
},
parse: function(response) {
@@ -37,6 +39,12 @@ define([
}
if (attrs.passwd1 != attrs.passwd2) return gettext("Passwords don't match");
}
},
getIconUrl: function(size) {
var is_encrypted = this.get('encrypted');
var is_readonly = this.get('permission') == "r" ? true : false;
return Common.getLibIconUrl(is_encrypted, is_readonly, size);
}
});

View File

@@ -4,8 +4,9 @@ define([
'backbone',
'common',
'app/collections/group-repos',
'app/views/group-repo'
], function($, _, Backbone, Common, GroupRepos, GroupRepoView) {
'app/views/group-repo',
'app/models/group-repo'
], function($, _, Backbone, Common, GroupRepos, GroupRepoView, GroupRepo) {
'use strict';
var GroupItemView = Backbone.View.extend({
@@ -37,7 +38,7 @@ define([
groupRepos.setGroupID(group_id);
$(repos).each(function(index, item) {
var view = new GroupRepoView({
model: new Backbone.Model(item, {collection: groupRepos}),
model: new GroupRepo(item, {collection: groupRepos}),
group_id: group_id,
is_staff: is_staff,
show_shared_by: false // don't show 'Shared By'

View File

@@ -31,6 +31,8 @@ define([
render: function() {
var obj = this.model.toJSON();
var icon_size = Common.isHiDPI() ? 96 : 24;
var icon_url = this.model.getIconUrl(icon_size);
$.extend(obj, {
group_id: this.group_id,
is_staff: this.is_staff,
@@ -38,7 +40,8 @@ define([
share_from_me: app.pageOptions.username == this.model.get('owner') ? true : false,
// 'owner_name' for '#groups', 'owner_nickname' for '#group/id/'
owner_name: this.model.get('owner_nickname') || this.model.get('owner_name'),
show_shared_by: this.show_shared_by
show_shared_by: this.show_shared_by,
icon_url: icon_url
});
this.$el.html(this.template(obj));
return this;

View File

@@ -15,7 +15,11 @@ define([
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
var obj = this.model.toJSON();
var icon_size = Common.isHiDPI() ? 96 : 24;
var icon_url = this.model.getIconUrl(icon_size);
_.extend(obj, { 'icon_url': icon_url });
this.$el.html(this.template(obj));
return this;
},

View File

@@ -39,7 +39,11 @@ define([
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
var obj = this.model.toJSON();
var icon_size = Common.isHiDPI() ? 96 : 24;
var icon_url = this.model.getIconUrl(icon_size);
_.extend(obj, { 'icon_url': icon_url });
this.$el.html(this.template(obj));
return this;
},

View File

@@ -47,7 +47,11 @@ define([
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
var obj = this.model.toJSON();
var icon_size = Common.isHiDPI() ? 96 : 24;
var icon_url = this.model.getIconUrl(icon_size);
_.extend(obj, { 'icon_url': icon_url });
this.$el.html(this.template(obj));
return this;
},

View File

@@ -227,6 +227,26 @@ define([
}
},
getLibIconUrl: function(is_encrypted, is_readonly, size) {
if (size > 24) {
if (is_encrypted) {
return app.config.mediaUrl + "img/lib/96/lib-encrypted.png";
} else if (is_readonly) {
return app.config.mediaUrl + "img/lib/96/lib-readonly.png";
} else {
return app.config.mediaUrl + "img/lib/96/lib.png";
}
} else {
if (is_encrypted) {
return app.config.mediaUrl + "img/lib/24/lib-encrypted.png";
} else if (is_readonly) {
return app.config.mediaUrl + "img/lib/24/lib-readonly.png";
} else {
return app.config.mediaUrl + "img/lib/24/lib.png";
}
}
},
isHiDPI: function() {
var pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
if (pixelRatio > 1) {