diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-08-01 14:38:06 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-08-02 11:46:44 +0200 |
commit | b12c1cb32521f643bcb3e2c4238fa2b9cf0fda55 (patch) | |
tree | 699e162274bb48a7f800737747cbb25193108097 /core/js/js.js | |
parent | 41739ff83f24d3ed62d4a3f3649375aec11c7dda (diff) | |
download | nextcloud-server-b12c1cb32521f643bcb3e2c4238fa2b9cf0fda55.tar.gz nextcloud-server-b12c1cb32521f643bcb3e2c4238fa2b9cf0fda55.zip |
add OC.Breadcrumb.show(dir, filename, link)
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js index a92d41f236f..17a24dd4bc5 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -370,6 +370,68 @@ OC.Notification={ OC.Breadcrumb={ container:null, crumbs:[], + show:function(dir, filename, link){ + OC.Breadcrumb.clear(); + var path = dir.split('/'); + + //add home + var link = OC.linkTo('files','index.php'); + + var crumb=$('<div/>'); + crumb.addClass('crumb'); + + var crumbLink=$('<a/>'); + crumbLink.attr('href',link); + + 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/>'); + 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/>'); + crumbLink.attr('href',link); + crumbLink.text(filename); + crumb.append(crumbLink); + OC.Breadcrumb.crumbs.push(crumb); + } + + // update crumb array + var lastCrumb = OC.Breadcrumb.crumbs.pop(); + lastCrumb = jQuery(lastCrumb).addClass('last'); + 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){ if(!OC.Breadcrumb.container){//default OC.Breadcrumb.container=$('#controls'); |