1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 22:54:11 +00:00

Merge pull request #1059 from haiwen/lib-icon

Improve library icon
This commit is contained in:
llj
2016-03-14 12:18:14 +08:00
14 changed files with 82 additions and 43 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

@@ -30,11 +30,7 @@
</script> </script>
<script type="text/template" id="repo-tmpl"> <script type="text/template" id="repo-tmpl">
<td> <td>
<% if (encrypted) { %> <img src="<%= icon_url %>" title="<%= icon_title %>" alt="" width="24" />
<img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
<% } else { %>
<img src="{{ MEDIA_URL }}img/sync-folder-20.png" title="{% trans "Read-Write" %}" alt="" />
<% } %>
</td> </td>
<% if (name) { %> <% if (name) { %>
<td><span class="repo-name-span"><a href="#my-libs/lib/<%= id %>"><%- name %></a></span></td> <td><span class="repo-name-span"><a href="#my-libs/lib/<%= id %>"><%- name %></a></span></td>
@@ -67,15 +63,7 @@
</script> </script>
<script type="text/template" id="group-repo-tmpl"> <script type="text/template" id="group-repo-tmpl">
<td> <td>
<% if (encrypted) { %> <img src="<%= icon_url %>" title="<%= icon_title %>" alt="" width="24" />
<img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
<% } else { %>
<% if (permission == 'rw') { %>
<img src="{{ MEDIA_URL }}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
<% } else { %>
<img src="{{ MEDIA_URL }}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
<% } %>
<% } %>
</td> </td>
<td><a href="#group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td> <td><a href="#group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td>
<td class="alc"> <td class="alc">
@@ -91,15 +79,7 @@
</script> </script>
<script type="text/template" id="organization-repo-tmpl"> <script type="text/template" id="organization-repo-tmpl">
<td> <td>
<% if (encrypted) { %> <img src="<%= icon_url %>" title="<%= icon_title %>" alt="" width="24" />
<img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
<% } else { %>
<% if (permission == 'rw') { %>
<img src="{{ MEDIA_URL }}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
<% } else { %>
<img src="{{ MEDIA_URL }}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
<% } %>
<% } %>
</td> </td>
<td><a href="#org/lib/<%= id %>"><%- name %></a></td> <td><a href="#org/lib/<%= id %>"><%- name %></a></td>
<td class="alc"> <td class="alc">
@@ -603,15 +583,7 @@
</script> </script>
<script type="text/template" id="shared-repo-tmpl"> <script type="text/template" id="shared-repo-tmpl">
<td> <td>
<% if (encrypted) { %> <img src="<%= icon_url %>" title="<%= icon_title %>" alt="" width="24" />
<img src="{{MEDIA_URL}}img/sync-folder-encrypt-20.png" title="{% trans "Read-Write" %}" alt="{% trans "directory icon" %}" />
<% } else { %>
<% if (permission == 'rw') { %>
<img src="{{MEDIA_URL}}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="{% trans "directory icon" %}" />
<% } else { %>
<img src="{{MEDIA_URL}}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="{% trans "directory icon" %}" />
<% } %>
<% } %>
</td> </td>
<td><a href="#shared-libs/lib/<%= id %>"><%- name %></a></td> <td><a href="#shared-libs/lib/<%= id %>"><%- name %></a></td>
<td class="alc"> <td class="alc">

View File

@@ -1,7 +1,8 @@
define([ define([
'underscore', 'underscore',
'backbone' 'backbone',
], function(_, Backbone) { 'common'
], function(_, Backbone, Common) {
'use strict'; 'use strict';
var Repo = Backbone.Model.extend({ var Repo = Backbone.Model.extend({
@@ -14,7 +15,8 @@ define([
mtime_relative: "", mtime_relative: "",
encrypted: false, encrypted: false,
owner: "-", owner: "-",
owner_nickname: "-" owner_nickname: "-",
permission: "rw"
}, },
parse: function(response) { parse: function(response) {
@@ -37,6 +39,25 @@ define([
} }
if (attrs.passwd1 != attrs.passwd2) return gettext("Passwords don't match"); 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);
},
getIconTitle: function() {
var icon_title = '';
if (this.get('encrypted')) {
icon_title = gettext("Encrypted");
} else if (this.get('permission') == "rw") {
icon_title = gettext("Read-Write");
} else {
icon_title = gettext("Read-Only");
}
return icon_title;
} }
}); });

View File

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

View File

@@ -31,6 +31,8 @@ define([
render: function() { render: function() {
var obj = 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, { $.extend(obj, {
group_id: this.group_id, group_id: this.group_id,
is_staff: this.is_staff, is_staff: this.is_staff,
@@ -38,7 +40,9 @@ define([
share_from_me: app.pageOptions.username == this.model.get('owner') ? true : false, share_from_me: app.pageOptions.username == this.model.get('owner') ? true : false,
// 'owner_name' for '#groups', 'owner_nickname' for '#group/id/' // 'owner_name' for '#groups', 'owner_nickname' for '#group/id/'
owner_name: this.model.get('owner_nickname') || this.model.get('owner_name'), 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,
icon_title: this.model.getIconTitle()
}); });
this.$el.html(this.template(obj)); this.$el.html(this.template(obj));
return this; return this;

View File

@@ -15,7 +15,14 @@ define([
}, },
render: function() { 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,
'icon_title': this.model.getIconTitle()
});
this.$el.html(this.template(obj));
return this; return this;
}, },

View File

@@ -39,7 +39,14 @@ define([
}, },
render: function() { 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,
'icon_title': this.model.getIconTitle()
});
this.$el.html(this.template(obj));
return this; return this;
}, },

View File

@@ -47,7 +47,14 @@ define([
}, },
render: function() { 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,
'icon_title': this.model.getIconTitle()
});
this.$el.html(this.template(obj));
return this; 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() { isHiDPI: function() {
var pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1; var pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
if (pixelRatio > 1) { if (pixelRatio > 1) {