the group more structured and also demo connecting with gmail account..

This commit is contained in:
Harry Bomrah committed 2012-04-30 21:17:20 +08:00
1 parent 1b7fb106f8
commit 769a67f026
5 files changed
+87 -208

No files matched your search

+75 -41
View File
@@ -162,13 +162,15 @@ var orbitDesktop = function(dom){
$.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids});
},
update:function(){
var s = $(this).find('.element').length,
last = $(this).find('.element').eq(s-1).position(),
lasth = $(this).find('.element').eq(s-1).outerHeight(true);
if ((last.top+lasth)>528){
$(this).sortable('cancel');
}
var s = $(this).find('.element').length;
if(s!=0){
last = $(this).find('.element').eq(s-1).position(),
lasth = $(this).find('.element').eq(s-1).outerHeight(true);
if ((last.top+lasth)>528){
$(this).sortable('cancel');
}
}else{$(this).remove();}
},
receive: function(event, ui){
@@ -216,39 +218,51 @@ var orbitDesktop = function(dom){
$li,
bdsum = 0,
bwsum = 0,
bhsum = 0;
bhsum = 0,
small = 0,
single = false;
$group.append($col);
$.each(group,function(j,tile){
var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
var op = opacity[Math.floor(Math.random()*opacity.length)];
if(j==0)$group.attr("id",tile.group_id);
if(tile.data_category == "app")
$li = $('<li id="'+tile._id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile._id+'" class="appicon" onclick="return false;"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
else
$li = $('<li id="'+tile._id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><h1 class="appname thmtxt">'+tile.title+'</h1><div class="appholder">Loading...</div></li>');
// $group.find("ul").append($li);
// column experiment start
for(j=0;j<group.length;j++){
var tile = group[j];
var brick = tile.shape.replace(' holder_f','').split(' '),
bw = parseInt(brick[0].substr(1)),
bh = parseInt(brick[1].substr(1)),
bd = bw * bh;
if(bh==1 && bw==1){
small++;
}else if(bh!=1 && bw!=1){
single = true;
}
if(small==2){
small=0;
single=false;
}else if(small==1 && single==true){
bh++;
small=0;
single=false;
}else{small=0;single=false;}
bdsum+=bd;
bwsum+=bw;
bhsum+=bh;
if( bdsum > 8 ){
bdsum = 0, bhsum = 0, colindex+=1;
if(bdsum > 8 || bhsum > 6){
bdsum = 0, bhsum = 0, colindex++,j--;
$group.append('<ul class="g_col g_col_w2 col'+ colindex +'"/>');
$group.find('.col'+colindex).eq(colindex).append($li);
} else {
$group.find('.col'+colindex).eq(0).append($li);
}else{
var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
var op = opacity[Math.floor(Math.random()*opacity.length)];
if(j==0)$group.attr("id",tile.group_id);
if(tile.data_category == "app")
$li = $('<li id="'+tile._id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile._id+'" class="appicon" onclick="return false;"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
else
$li = $('<li id="'+tile._id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><h1 class="appname thmtxt">'+tile.title+'</h1><div class="appholder">Loading...</div></li>');
$group.find('.col'+colindex).append($li);
}
});
}
$("div#desktop div#group_wrapper").append($group);
})
bindHandlers();
@@ -345,8 +359,19 @@ var orbitDesktop = function(dom){
allApps = $("div#app_manager .group_search .element").sort(sortDescending);
break;
}
$("div#app_manager .group_search").html(allApps);
$("div#app_manager #app_list").empty();
var count = 0, colindex = 0;
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
$.each(allApps,function(i,app){
count++;
if( count > 4 ){
count = 1, colindex+=1;
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
$('.g_col.col'+ colindex).append(app);
} else {
$('.g_col.col'+ colindex).append(app);
}
})
return false;
})
$('.tinycanvas')
@@ -362,11 +387,8 @@ var orbitDesktop = function(dom){
$.each(appss,function(i,apps){
$.each(apps,function(i,app){
var $app;
count++;
$app = $('<div class="element w1 h1 hp vp thmc2" data-category="'+app.data_category+'" data-content="'+app.data_content+'"><span class="tile thmc2"></span><a href="'+app._id+'" class="appicon"><img src="'+o.iconPath+app.data_content+'.png" alt="" onclick="return false;"></a><h1 class="appname thmtxt">'+app.title+'</h1></div>');
if( count > 4 ){
count = 1, colindex+=1;
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
@@ -374,10 +396,6 @@ var orbitDesktop = function(dom){
} else {
$('.g_col.col'+ colindex).append($app);
}
console.log(count, colindex);
})
})
@@ -736,7 +754,23 @@ var orbitDesktop = function(dom){
var connection = function(){
var bindHandlers = function(){
$("#gmail_connect_btn").click(function(){
var usernm = $("input#gmail_username").val(),
pwd = $("input#gmail_password").val(),
type = $(this).attr("href"),
what = "edit";
if(usernm!="" && pwd!="")
saveaccount(usernm,pwd,type,what);
})
}
var saveaccount = function(usernm,pwd,type,what){
$.post("/desktop/save_account_info",{email:usernm,password:pwd,account:type,dowhat:what},function(result){
if(result[0].success=="true")
o.notify("Gmail account connected!!","success",2);
else
o.notify("Gmail account connection failed!!","imp",2);
})
}
$("div#settings div#panel_r").load("/desktop/settingconnection",function(){
bindHandlers();
@@ -845,7 +879,7 @@ var orbitDesktop = function(dom){
})
};
this.saveWallpaper = function(wallpaper){ // this function saves wallpaper in db
$.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result,status){
$.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){
if(result[0].success=="true")
o.notify("Wallpaper saved!!","success",2);
else