]> source.dussan.org Git - nextcloud-server.git/commitdiff
add OC.Breadcrumb.show(dir, filename, link)
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 1 Aug 2013 12:38:06 +0000 (14:38 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 2 Aug 2013 09:46:44 +0000 (11:46 +0200)
core/js/js.js

index a92d41f236fdf5dc35bccaa79fb38c716cfa5ca3..17a24dd4bc5b45140b1d07e5dd9b8979754fe81e 100644 (file)
@@ -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');