Skip to content

Commit

Permalink
Implement directory open/close status.
Browse files Browse the repository at this point in the history
  • Loading branch information
masamitsu-murase committed Mar 17, 2012
1 parent 0a97483 commit 87212c2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
21 changes: 21 additions & 0 deletions extension/repository_view/dav_svn_model.js
Expand Up @@ -56,6 +56,9 @@ DavSvnResource.prototype = {
isFile: function(){
return this.type() == DavSvnResource.TYPE_FILE;
},
isUnknown: function(){
return this.type() == DavSvnResource.TYPE_UNKNOWN;
},

addChild: function(child){
var name = child.name();
Expand Down Expand Up @@ -108,6 +111,9 @@ DavSvnResource.prototype = {
markLoaded: function(){
this.m_state = DavSvnResource.STATE_LOADED;
},
isLoaded: function(){
return this.m_state == DavSvnResource.STATE_LOADED;
},

debugInfo: function(level){
level = (level || 0);
Expand Down Expand Up @@ -174,6 +180,9 @@ DavSvnModel.prototype = {
root_url: this.m_root_url
};
},

// Reload specified path.
// Directory state (opened/closed) is kept.
reloadPath: function(path){
var self = this;

Expand Down Expand Up @@ -207,6 +216,16 @@ DavSvnModel.prototype = {
});
target_resource.markLoaded();
self.setResource(target_info.path, target_resource);
if (target.isDirectory() && target_resource.isDirectory()){
if (target.dirIsOpened()){
target_resource.dirOpen();
}else{
target_resource.dirClose();
}
}else if (target.isUnknown() && target_resource.isDirectory()){
// first loading
target_resource.dirOpen();
}
self.notify();
});
},
Expand Down Expand Up @@ -265,10 +284,12 @@ DavSvnModel.prototype = {
}else{
var new_dir = new DavSvnResource(name, DavSvnResource.TYPE_DIRECTORY);
dir.addChild(new_dir);
dir.dirOpen();
dir = new_dir;
}
});
dir.addChild(resource);
dir.dirOpen();
},
resource: function(path){
if (!this.m_root_dir){
Expand Down
26 changes: 20 additions & 6 deletions extension/repository_view/repository_view.js
Expand Up @@ -39,11 +39,13 @@

createResourceNodeTitle: function(rsc){
var title = document.createElement("span");
var path_elem = document.createElement("span");
title.appendChild(path_elem);

if (rsc.isRoot()){
title.appendChild(document.createTextNode(this.m_model.repositoryInfo().root_url));
path_elem.appendChild(document.createTextNode(this.m_model.repositoryInfo().root_url));
}else{
title.appendChild(document.createTextNode(rsc.name()));
path_elem.appendChild(document.createTextNode(rsc.name()));
}
var class_name = rsc.isDirectory() ? DirectoryView.CLASS_TYPE_DIRECTORY : DirectoryView.CLASS_TYPE_FILE;
switch(rsc.state()){
Expand All @@ -66,14 +68,26 @@
if (rsc.isDirectory()){
var path = rsc.path();
var self = this;
title.addEventListener("click", function(){
path_elem.addEventListener("click", function(){
if (self.m_log_view){
self.m_log_view.updateLog(path);
}

self.m_model.changePath(path);
// self.m_model.reloadPath(path);
self.m_model.toggleDirectory(path);
if (rsc.isLoaded()){
self.m_model.toggleDirectory(path)
}else{
self.m_model.reloadPath(path);
self.m_model.openDirectory(path);
}
});

var reload_elem = document.createElement("img");
title.appendChild(reload_elem);
reload_elem.src = "images/icon_folder_opened.png";
reload_elem.alt = "Reload";
reload_elem.addEventListener("click", function(e){
self.m_model.reloadPath(path);
});
}

Expand All @@ -91,7 +105,7 @@
var title = this.createResourceNodeTitle(rsc);
resource_title.appendChild(title);

if (rsc.isDirectory()){
if (rsc.isDirectory() && rsc.dirIsOpened()){
// Information of children
var children_root = document.createElement("dd");
children_root.className = DirectoryView.CLASS_CHILDREN_ROOT;
Expand Down

0 comments on commit 87212c2

Please sign in to comment.