use fixed OC.Breadcrumb.push()

This commit is contained in:
Jörn Friedrich Dreyer 2013-08-02 11:44:53 +02:00
parent b12c1cb325
commit f8bb4e10ae
1 changed files with 30 additions and 54 deletions

View File

@ -370,67 +370,43 @@ OC.Notification={
OC.Breadcrumb={ OC.Breadcrumb={
container:null, container:null,
crumbs:[], crumbs:[],
show:function(dir, filename, link){ show:function(dir, leafname, leaflink){
OC.Breadcrumb.clear(); OC.Breadcrumb.clear();
var path = dir.split('/');
//add home // show home + path in subdirectories
var link = OC.linkTo('files','index.php'); if (dir && dir !== '/') {
//add home
var crumb=$('<div/>'); var link = OC.linkTo('files','index.php');
crumb.addClass('crumb');
var crumbLink=$('<a/>'); var crumb=$('<div/>');
crumbLink.attr('href',link); crumb.addClass('crumb');
var crumbImg=$('<img/>');
crumbImg.attr('src',OC.imagePath('core','places/home'));
crumbLink.append(crumbImg);
crumb.append(crumbLink);
OC.Breadcrumb.crumbs.push(crumb);
//add path parts
var pathurl = '';
jQuery.each(path, function(i,name) {
if (name !== '') {
pathurl = pathurl+'/'+name;
var link = OC.linkTo('files','index.php')+'?dir='+encodeURIComponent(pathurl);
var crumb=$('<div/>');
crumb.addClass('crumb');
var crumbLink=$('<a/>'); var crumbLink=$('<a/>');
crumbLink.attr('href',link); crumbLink.attr('href',link);
crumbLink.text(name);
crumb.append(crumbLink);
OC.Breadcrumb.crumbs.push(crumb);
}
});
//add filename (optional)
if (filename && link) {
pathurl = pathurl+'/'+filename;
var crumb=$('<div/>');
crumb.addClass('crumb');
var crumbLink=$('<a/>'); var crumbImg=$('<img/>');
crumbLink.attr('href',link); crumbImg.attr('src',OC.imagePath('core','places/home'));
crumbLink.text(filename); crumbLink.append(crumbImg);
crumb.append(crumbLink); crumb.append(crumbLink);
OC.Breadcrumb.crumbs.push(crumb); OC.Breadcrumb.container.prepend(crumb);
OC.Breadcrumb.crumbs.push(crumb);
//add path parts
var segments = dir.split('/');
var pathurl = '';
jQuery.each(segments, function(i,name) {
if (name !== '') {
pathurl = pathurl+'/'+name;
var link = OC.linkTo('files','index.php')+'?dir='+encodeURIComponent(pathurl);
OC.Breadcrumb.push(name, link);
}
});
} }
// update crumb array //add leafname
var lastCrumb = OC.Breadcrumb.crumbs.pop(); if (leafname && leaflink) {
lastCrumb = jQuery(lastCrumb).addClass('last'); OC.Breadcrumb.push(leafname, leaflink);
OC.Breadcrumb.crumbs.push(lastCrumb); }
var crumbs = OC.Breadcrumb.crumbs;
crumbs.reverse();
jQuery.each(crumbs, function(i,crumb){
OC.Breadcrumb.container.prepend(crumb);
});
}, },
push:function(name, link){ push:function(name, link){
if(!OC.Breadcrumb.container){//default if(!OC.Breadcrumb.container){//default