Merge pull request #1756 from nextcloud/filepicker

Filepicker styling
This commit is contained in:
Morris Jobke 2016-10-14 18:40:38 +02:00 committed by GitHub
commit 14981210e0
4 changed files with 35 additions and 16 deletions

View File

@ -14,7 +14,8 @@
background: white; background: white;
font-weight: bold; font-weight: bold;
font-size: 110%; font-size: 110%;
margin-bottom: 10px; margin-bottom: 5px;
margin-top: -9px;
} }
.oc-dialog-content { .oc-dialog-content {
z-index: 1000; z-index: 1000;

View File

@ -774,29 +774,39 @@ a.bookmarklet { background-color:#ddd; border:1px solid #ccc; padding:5px;paddin
.ui-datepicker-prev,.ui-datepicker-next{ border:1px solid #ddd; background:#fff; } .ui-datepicker-prev,.ui-datepicker-next{ border:1px solid #ddd; background:#fff; }
/* ---- DIALOGS ---- */ /* ---- DIALOGS ---- */
#oc-dialog-filepicker-content .dirtree {width:92%; overflow:hidden; } #oc-dialog-filepicker-content .dirtree {
#oc-dialog-filepicker-content .dirtree .home { width:92%;
float: left;
margin-left: 15px;
overflow:hidden;
}
#oc-dialog-filepicker-content .dirtree div:first-child a {
background-image:url('../img/places/home.svg?v=1'); background-image:url('../img/places/home.svg?v=1');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position: left center; background-position: left center;
width: 30px;
display: inline-block;
} }
#oc-dialog-filepicker-content .dirtree span:not(:last-child) { cursor: pointer; } #oc-dialog-filepicker-content .dirtree span:not(:last-child) { cursor: pointer; }
#oc-dialog-filepicker-content .dirtree span:last-child { font-weight: bold; } #oc-dialog-filepicker-content .dirtree span:last-child { font-weight: bold; }
#oc-dialog-filepicker-content .dirtree span:not(:last-child)::after { content: '>'; padding: 3px;} #oc-dialog-filepicker-content .dirtree span:not(:last-child)::after { content: '>'; padding: 3px;}
#oc-dialog-filepicker-content .filelist { #oc-dialog-filepicker-content .filelist {
overflow-y:auto; overflow-y:auto;
height: 300px; height: 290px;
background-color:white; background-color:white;
width:100%; width:100%;
} }
#oc-dialog-filepicker-content .filelist li:first-child {
border-top: 1px solid #eee;
}
#oc-dialog-filepicker-content .filelist li { #oc-dialog-filepicker-content .filelist li {
position: relative; position: relative;
height: 40px;
padding: 5px;
border-bottom: 1px solid #eee;
} }
#oc-dialog-filepicker-content .filelist .filename { #oc-dialog-filepicker-content .filelist .filename {
position: absolute; position: absolute;
top: 8px; padding-top: 9px;
max-width: 60%; max-width: 60%;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;

View File

@ -174,7 +174,7 @@ var OCdialogs = {
self.$filePicker.ready(function() { self.$filePicker.ready(function() {
self.$filelist = self.$filePicker.find('.filelist'); self.$filelist = self.$filePicker.find('.filelist');
self.$dirTree = self.$filePicker.find('.dirtree'); self.$dirTree = self.$filePicker.find('.dirtree');
self.$dirTree.on('click', 'span:not(:last-child)', self, self._handleTreeListSelect); self.$dirTree.on('click', 'div:not(:last-child)', self, self._handleTreeListSelect.bind(self));
self.$filelist.on('click', 'li', function(event) { self.$filelist.on('click', 'li', function(event) {
self._handlePickerClick(event, $(this)); self._handlePickerClick(event, $(this));
}); });
@ -769,10 +769,17 @@ var OCdialogs = {
}); });
if (entry.type === 'file') { if (entry.type === 'file') {
var urlSpec = { var urlSpec = {
file: dir + '/' + entry.name file: dir + '/' + entry.name,
}; };
$li.find('img').attr('src', OC.MimeType.getIconUrl(entry.mimetype));
var img = new Image();
var previewUrl = OC.generateUrl('/core/preview.png?') + $.param(urlSpec); var previewUrl = OC.generateUrl('/core/preview.png?') + $.param(urlSpec);
$li.find('img').attr('src', previewUrl); img.onload = function() {
if (img.width > 5) {
$li.find('img').attr('src', previewUrl);
}
};
img.src = previewUrl;
} }
else { else {
$li.find('img').attr('src', OC.Util.replaceSVGIcon(entry.icon)); $li.find('img').attr('src', OC.Util.replaceSVGIcon(entry.icon));
@ -792,8 +799,9 @@ var OCdialogs = {
_fillSlug: function() { _fillSlug: function() {
this.$dirTree.empty(); this.$dirTree.empty();
var self = this; var self = this;
var dir;
var path = this.$filePicker.data('path'); var path = this.$filePicker.data('path');
var $template = $('<span data-dir="{dir}">{name}</span>'); var $template = $('<div data-dir="{dir}"><a>{name}</a></div>').addClass('crumb');
if(path) { if(path) {
var paths = path.split('/'); var paths = path.split('/');
$.each(paths, function(index, dir) { $.each(paths, function(index, dir) {
@ -809,17 +817,17 @@ var OCdialogs = {
} }
$template.octemplate({ $template.octemplate({
dir: '', dir: '',
name: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' // Ugly but works ;) name: '' // Ugly but works ;)
}, {escapeFunction: null}).addClass('home svg').prependTo(this.$dirTree); }, {escapeFunction: null}).prependTo(this.$dirTree);
}, },
/** /**
* handle selection made in the tree list * handle selection made in the tree list
*/ */
_handleTreeListSelect:function(event) { _handleTreeListSelect:function(event) {
var self = event.data; var self = event.data;
var dir = $(event.target).data('dir'); var dir = $(event.target).parent().data('dir');
self._fillFilePicker(dir); self._fillFilePicker(dir);
var getOcDialog = this.closest('.oc-dialog'); var getOcDialog = (event.target).closest('.oc-dialog');
var buttonEnableDisable = $('.primary', getOcDialog); var buttonEnableDisable = $('.primary', getOcDialog);
if (this.$filePicker.data('mimetype') === "http/unix-directory") { if (this.$filePicker.data('mimetype') === "http/unix-directory") {
buttonEnableDisable.prop("disabled", false); buttonEnableDisable.prop("disabled", false);

View File

@ -1,5 +1,5 @@
<div id="{dialog_name}" title="{title}"> <div id="{dialog_name}" title="{title}">
<span class="dirtree"></span> <span class="dirtree breadcrumb"></span>
<ul class="filelist"> <ul class="filelist">
<li data-entryname="{filename}" data-type="{type}"> <li data-entryname="{filename}" data-type="{type}">
<img /> <img />