Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix #358, #359, #360
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Nov 25, 2013
1 parent 6370e91 commit 702a9cc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
62 changes: 42 additions & 20 deletions core/src/plugins/access.ajxp_user/class.UserDashboardHome.js
Expand Up @@ -30,49 +30,59 @@ Class.create("UserDashboardHome", AjxpPane, {

var wsElement = oFormObject.down('#workspaces_list');

var switchToRepo = function(repoId){
if(!repoId) return;
if(oFormObject.down('#save_ws_choice').checked){
// Save this preference now!
var params = $H({
'PREFERENCES_DEFAULT_START_REPOSITORY':repoId,
'get_action':'custom_data_edit'
});
var conn = new Connexion();
conn.setParameters(params);
conn.setMethod("POST");
conn.onComplete = function(transport){
ajaxplorer.user.setPreference('DEFAULT_START_REPOSITORY', repoId, false);
};
conn.sendAsync();
}
ajaxplorer.triggerRepositoryChange(repoId);
};

ajaxplorer.user.repositories.each(function(pair){
var repoId = pair.key;
var repoObject = pair.value;
if(repoObject.getAccessType() == 'ajxp_user') return;

var repoEl = new Element('li').update("<h3>"+repoObject.getLabel() + "</h3><h4>" + repoObject.getDescription()+"</h4>");
wsElement.insert(repoEl);
repoEl.observe("click", function(e){
var select = function(e){
var target = Event.findElement(e, "li");
target.nextSiblings().invoke('removeClassName', 'selected');
target.previousSiblings().invoke('removeClassName', 'selected');
target.addClassName('selected');
oFormObject.down('#go_to_ws').removeClassName("disabled");
oFormObject.down('#save_ws_choice').removeClassName("disabled").disabled = false;
oFormObject.down('#go_to_ws').CURRENT_REPO_ID = repoId;
};
repoEl.observe("click", select);
repoEl.observe("dblclick", function(e){
select(e);
switchToRepo(repoId);
});
});

oFormObject.down('#go_to_ws').observe("click", function(e){
var target = e.target;
if(!target.CURRENT_REPO_ID) return;
if(oFormObject.down('#save_ws_choice').checked){
// Save this preference now!
var params = $H({
'PREFERENCES_DEFAULT_START_REPOSITORY':target.CURRENT_REPO_ID,
'get_action':'custom_data_edit'
});
var conn = new Connexion();
conn.setParameters(params);
conn.setMethod("POST");
conn.onComplete = function(transport){
ajaxplorer.user.setPreference('DEFAULT_START_REPOSITORY', target.CURRENT_REPO_ID, false);
};
conn.sendAsync();
}
ajaxplorer.triggerRepositoryChange(target.CURRENT_REPO_ID);
switchToRepo(target.CURRENT_REPO_ID);
});

var notifCenter = ajaxplorer.NotificationLoaderInstance;
var notificationElement = oFormObject.down("#notifications_center");

if(notifCenter){
notifCenter.ajxpNode.observe("loaded", function(){
var existingItems = notificationElement.select('li');
notifCenter.childrenToMenuItems(function(obj){
var a = new Element('li', {title:obj['alt']}).update(obj['name']);
notificationElement.insert(a);
Expand All @@ -81,21 +91,33 @@ Class.create("UserDashboardHome", AjxpPane, {
a.insert({top:img});
obj.pFactory.enrichBasePreview(obj.ajxpNode, a);
});
existingItems.invoke('remove');
});

var clicker = function(){
var clicker = function(e, skipsave){
var save;
if(oFormObject.down("#notifications_center").hasClassName('folded')){
oFormObject.down("#workspaces_center").setStyle({marginLeft: '15%'});
oFormObject.down("#notifications_center").setStyle({width: '30%'});
save = 'opened';
}else{
oFormObject.down("#workspaces_center").setStyle({marginLeft: '30%'});
oFormObject.down("#notifications_center").setStyle({width: '0'});
save = 'closed';
}
oFormObject.down("#notifications_center").toggleClassName('folded');
};
if(!skipsave){
this.setUserPreference('dashboard-notification-center', save);
}
}.bind(this);
oFormObject.down("#close-icon").observe("click", clicker);

window.setTimeout(clicker, 4000);
var pref = this.getUserPreference('dashboard-notification-center');
if(pref == undefined){
window.setTimeout(function(){clicker(null, true);}, 4000);
}else if(pref == 'closed'){
clicker(null, true);
}
}else{
oFormObject.down("#workspaces_center").setStyle({marginLeft: '30%'});
notificationElement.hide();
Expand Down
14 changes: 9 additions & 5 deletions core/src/plugins/access.ajxp_user/manifest.xml
Expand Up @@ -120,13 +120,17 @@
</div>
<script>
document.observeOnce("ajaxplorer:context_changed", function(){
$("global_toolbar").insert({bottom: $("search_container_settings")});
$("search_container_settings").show();
$("browser").ajxpPaneObject.resize();
try{
$("global_toolbar").insert({bottom: $("search_container_settings")});
$("search_container_settings").show();
$("browser").ajxpPaneObject.resize();
}catch(e){}
document.observeOnce("ajaxplorer:repository_list_refreshed",function(){
if(ajaxplorer.repositoryId == 'ajxp_user') return;
$("global_toolbar").down("#search_container_settings").ajxpPaneObject.destroy();
$("global_toolbar").down("#search_container_settings").remove();
try{
$("global_toolbar").down("#search_container_settings").ajxpPaneObject.destroy();
$("global_toolbar").down("#search_container_settings").remove();
}catch(e){}
});
});
window.setTimeout(function(){
Expand Down

0 comments on commit 702a9cc

Please sign in to comment.