diff --git a/core/src/plugins/access.ajxp_user/class.UserDashboardHome.js b/core/src/plugins/access.ajxp_user/class.UserDashboardHome.js index b81b484df4..55f82a87af 100644 --- a/core/src/plugins/access.ajxp_user/class.UserDashboardHome.js +++ b/core/src/plugins/access.ajxp_user/class.UserDashboardHome.js @@ -30,6 +30,25 @@ 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; @@ -37,7 +56,7 @@ Class.create("UserDashboardHome", AjxpPane, { var repoEl = new Element('li').update("

"+repoObject.getLabel() + "

" + repoObject.getDescription()+"

"); 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'); @@ -45,27 +64,17 @@ Class.create("UserDashboardHome", AjxpPane, { 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; @@ -73,6 +82,7 @@ Class.create("UserDashboardHome", AjxpPane, { 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); @@ -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(); diff --git a/core/src/plugins/access.ajxp_user/manifest.xml b/core/src/plugins/access.ajxp_user/manifest.xml index 69b433786f..5b663d9d0f 100644 --- a/core/src/plugins/access.ajxp_user/manifest.xml +++ b/core/src/plugins/access.ajxp_user/manifest.xml @@ -120,13 +120,17 @@