minor update

This commit is contained in:
devin chen 2013-04-10 11:16:06 +08:00 committed by Matt K. Fu
parent e2802d94d0
commit e3782c9cf7
5 changed files with 249 additions and 411 deletions

View File

@ -108,8 +108,8 @@ var orbitDesktop = function(dom){
this.contentHolder = dom;
this.themesettings = "";
this.theme = "4f8d3f493b67fcd05f086359";
this.transitionTime = 500;
this.currenthtml = "home";
this.transitionTime = 1000;
this.currenthtml = "desktop.html";
this.currentface = "home";
this.desktopData = {};
this.tp = "";
@ -135,7 +135,7 @@ var orbitDesktop = function(dom){
o.theme = theme;
loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper);
}else{loadTheme();}
})
});
var loadTheme = function(customtheme,customwallpaper){ //This function will load the theme from database
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
o.themesettings = eval(ts);
@ -160,8 +160,8 @@ var orbitDesktop = function(dom){
}
});
})
}
}
};
};
this.customPage = function(customload){
customload = customload.replace("#","");
if(customload.search("-") != -1){
@ -170,7 +170,7 @@ var orbitDesktop = function(dom){
}else{
o.menu_item($(".docklist a[custom-load="+customload+"]"),true);
}
}
};
this.changeTheme = function(theme){ // this function is used for changing theme
o.theme = theme;
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
@ -189,9 +189,9 @@ var orbitDesktop = function(dom){
$.getJSON("http://maps.googleapis.com/maps/api/geocode/json?latlng="+o.locationdata.lat+","+o.locationdata.lng+"&sensor=true",function(data){
$.each(data.results[0].address_components,function(i,val){
o.locationdata[val.types[0]] = val.long_name;
})
});
o.locationdata.formatted_address = data.results[0].formatted_address;
})
});
}
var locationError = function(){
@ -211,7 +211,7 @@ var orbitDesktop = function(dom){
$(".docklist a").click(function(){
o.menu_item($(this));
return false;
})
});
$('body').on({
@ -254,7 +254,7 @@ var orbitDesktop = function(dom){
}
$(this).ajaxSubmit(options);
return false;
})
});
$("body").on("click","*[ajax-remote]",function(){
var $e = $(this);
@ -262,8 +262,8 @@ var orbitDesktop = function(dom){
var classes_to_toggle = $e.attr("toggle-onclick");
var exe = $e.attr("callback-method"); // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : "");
if(classes_to_toggle){
$e.toggleClass(classes_to_toggle);
}
$e.toggleClass(classes_to_toggle);
}
if(t == "false"){
if(exe){
window.o[o.data_method][exe](null,$e);
@ -310,11 +310,11 @@ var orbitDesktop = function(dom){
a();
}
return false;
})
});
$(window).resize(function(){
var ww = $(window).width();
$("img#thmbackground").attr({"width":ww});
// var ww = $(window).width();
// $("img#thmbackground").attr({"width":ww});
if( $('.tinycanvas').length > 0 ){ $('.tinycanvas').tinyscrollbar_update('relative'); }
if($(o.contentHolder).find("div.app_frame").length > 0){
$(o.contentHolder).find("div.app_frame").each(function(){
@ -322,7 +322,7 @@ var orbitDesktop = function(dom){
var app_holder_width = $(this).width();
$(this).find("div.app_holder").height(app_holder_height);
$(this).find("div.app_holder iframe").attr({"height":app_holder_height,"width":app_holder_width});
})
});
}
});
@ -372,14 +372,14 @@ var orbitDesktop = function(dom){
this.value = terms.join( ", " );
return false;
}
})
})
});
});
};
this.layout_data = function(h){
var $e;
var column_container,layout, base_width , no_of_entries = 0, pagination_link , pagination_variable, gutter, total_width;
var column_container,layout, base_width, total_width, gutter, no_of_entries = 0, pagination_link, pagination_variable;
o.paging = true;
gutter = (!isNaN(gutter)) ? gutter : 12;
this.layout_data.generate_layout_html = function(l){
@ -393,7 +393,6 @@ var orbitDesktop = function(dom){
case "simple":
total_columns++;
temp_div.append(column_container.html());
total_width = "auto";
break;
case "datalist":
no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4);
@ -412,10 +411,7 @@ var orbitDesktop = function(dom){
x = 0;
temp_div.append(column);
}
})
if(x != 0){
temp_div.append(column);
}
});
}
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
break;
@ -423,16 +419,17 @@ var orbitDesktop = function(dom){
entries = column_container.find("div[column=true]"),x = 0,column;
if(entries.length!=0){
entries.each(function(i,ul){
column = $("<div class='column type_column' style='width:"+base_width+"px;margin-right:"+gutter+"px;padding-right:"+gutter+"px;'></div");
column = $("<div class='column type_column' style='width:"+base_width+"px;margin-right:"+gutter+"px;padding-right:"+gutter+"px;'></div");
total_columns++;
column.append(ul);
x++;
temp_div.append(column);
})
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
});
}
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
break;
default:
break;
}
// total_width = (!isNaN(base_width) ? ( base_width + 12 ) * total_columns : null);
@ -473,20 +470,22 @@ var orbitDesktop = function(dom){
var f = o.layout_data.generate_layout_html(html);
// console.log(f.total)
if(f.total > 0){
$("div[container=true] div.overview").append(f.markup);
$("div[container=true] .overview").append(f.markup);
if(f.width){
var w = $("div[container=true] div.overview").width();
$("div[container=true] div.overview").width(w+f.width);
var w = $("div[container=true] .overview").width();
$("div[container=true] .overview").width(w+f.width);
}
o.tinyscrollbar.tinyscrollbar_update("relative");
o.paging = true;
}else{o.paging = false;}
} else {
o.paging = false;
}
}
})
});
}
this.insert_new_column = function(index){
var column_container = $("div[container=true] div.overview"),layout = column_container.attr("content-layout"),base_width = parseInt(column_container.attr("base-width")),column;
var column_container = $("div[container=true] .overview"),layout = column_container.attr("content-layout"),base_width = parseInt(column_container.attr("base-width")),column;
var i = (index == 0? 0 : index-1);
var previous_column = column_container.find(".column").eq(i);
if(previous_column.length == 0)return false;
@ -515,7 +514,7 @@ var orbitDesktop = function(dom){
}
this.remove_column = function(index){
var column_container = $("div[container=true] div.overview"),layout = column_container.attr("content-layout"),column = column_container.find(".column").eq(index),base_width = parseInt(column_container.attr("base-width"));
var column_container = $("div[container=true] .overview"),layout = column_container.attr("content-layout"),column = column_container.find(".column").eq(index),base_width = parseInt(column_container.attr("base-width"));
if(column.length == 0)return false;
switch(layout){
case "datalist":
@ -542,53 +541,72 @@ var orbitDesktop = function(dom){
o.lastlink = url;
o.data_method = dom.attr("callback-method");
if(o.currenthtml!=target){
if(o.desktopData[o.currentface] == "undefined")
if(o.desktopData[o.currentface] == "undefined"){
o.desktopData[o.currentface] = "";
}
o.desktopData[o.currentface] = $(o.contentHolder).html();
if(customload){
$(o.contentHolder).html("<div id='content'></div>");
}
$("#content").hide("drop",o.transitionTime,function(){
$("#content > #holder").toggle("drop",{ easing: "easeInOutQuint" },o.transitionTime,function(){
o.currenthtml = target;
o.currentface = target;
var cache = false;
if(!o.desktopData[o.currentface]){
$(o.contentHolder).empty().load(url,function(data){
if(typeof o.data_method != "undefined"){
if(o.data_method != "")
if(o.data_method != ""){
window.o[o.data_method](target,url,cache);
}
}
try{
if(!customload)
try {
if(!customload){
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data);
else{
if(submenuitem)
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[custom-load="+submenuitem+"]"));
else
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data);
} else {
if(submenuitem){
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[custom-load="+submenuitem+"]"));
} else {
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data);
}
}catch(EX){}
})
}
} catch(EX){}
header_ani();
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
try{
if(!customload)
header_ani();
try {
if(!customload){
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data);
else{
if(submenuitem)
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[custom-load="+submenuitem+"]"));
else
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data);
} else {
if(submenuitem){
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[custom-load="+submenuitem+"]"));
} else {
o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data);
}
}catch(EX){}
}
} catch(EX){}
cache = true;
if(typeof o.data_method != "undefined"){
if(o.data_method != "")
window.o[o.data_method](target,url,cache);
if(o.data_method != ""){
window.o[o.data_method](target,url,cache);
}
}
}
});
$('#header')
.delay(600)
.effect('drop',{
easing: 'easeInOutQuint',
direction: 'down'
},300);
}
var header_ani = function(){
$('#header').hide().toggle('drop',{easing: 'easeInOutQuint', direction:'down'});
$('#header > *').each(function(i){
$(this).hide().delay(i*100).fadeIn(600,'easeInOutQuint');
});
}
}
this.sub_menu_item = function(dom,data){
@ -632,312 +650,112 @@ var orbitDesktop = function(dom){
}
this.initializeDesktop = function(target,url,cache){ //this is for initializing main desktops that are sections and tiles
if(!target)target = "home";
target = (!target) ? 'desktop' : target;
var bindHandlers = function(){ // this function will bind all the handlers in the desktop
// var groupWrapperWidth = 0;
// $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);});
// var grps = new Array;
// $("div#desktop #group_wrapper").css("width",groupWrapperWidth);
// var first = true;
// $("div#desktop .g_col").sortable({
// connectWith: ".g_col",
// tolerance: 'pointer' ,
// revert: 300,
// containment: '#group_wrapper',
// helper: 'clone',
// stop:function(){
// first = true;
// var grpwidth = 0;
// for(i in grps){
// var grp = grps[i];
// if(grp.find(".element").length == 0){
// grp.animate({"width":"0px"},500,function(){$(this).remove();});
// grpwidth+=225;
// }
// }
// grps = [];
// $("#group_wrapper").width($("#group_wrapper").width()-grpwidth);
// },
// start:function(){
// $("#group_wrapper").find("div.group").each(function(i,par){
// var nextnumber = $(this).find("ul").length;
// $newcol = $('<ul class="g_col g_col_w2 col'+nextnumber+' ui-sortable">');
// $(this).append($newcol);
// $newcol.sortable({connectWith: '.g_col'});
// grps.push($newcol);
// $("#group_wrapper").width($("#group_wrapper").width()+225);
// });
// $("div#desktop .g_col").sortable('refresh');
// },
// update:function(){
// if(first){
// first = false;
// var newpostitions = new Array;
// var groupids = new Array;
// $.each($("div#desktop .group"),function(i,grp){
// var groupone = new Array;
// groupids.push($(grp).attr("id"));
// $ul = $(grp).find(".g_col .element");
// $.each($ul,function(){
// groupone.push($(this).attr("id"));
// })
// newpostitions.push(groupone);
// });
// $.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids});
// }
// 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');
// }
// }
// $("#group_wrapper ul").each(function(){
// if($(this).find('.element').length == 0)
// $(this).animate({"width":"0px"},500,function(){$(this).remove();});
// })
// },
// receive: function(event, ui){
// 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){
// $(ui.sender).sortable('cancel');
// }
// }
// });
var dragged = null,draggable,lastpos = [];
o.gridvar = $(".grid ul").find("> li ").mousedown(function(e){
o.gridvar = $(".grid ul").find("> li ")
.mousedown(function(e){
!draggable;
dragged = $(this);
lastpos = [];
$(".grid ul li").each(function(){
lastpos.push({"col":$(this).attr("data-col"),"row":$(this).attr("data-row")})
})
}).end()
.gridster({
widget_margins: [6, 6],
widget_base_dimensions: [120, 120],
// avoid_overlapped_widgets: true,
serialize_params: function($w, wgd) { return { col: wgd.col, row: wgd.row, id: $w.data("id") } },
draggable : {
start : function(event, ui){
dragged.addClass("noClick");
},
stop: function(event, ui){
// var widgetchanged_col = dragged.attr("data-col");
// var total = 0;
// // console.log(widgetchanged.col);
// // console.log(o.gridvar.serialize_changed());
// $(".grid ul li[data-col="+widgetchanged_col+"]").each(function(i,w){
// var size = parseInt($(this).attr("data-sizey"));
// if(!isNaN(size)){
// total += size;
// }
// })
// // other way to calculate the overflow is by top > height of div
// if(total>totaltiles_in_a_row){
// revertbacktiles();
// }else{
// console.log(widgetchanged_col-1);
// $(".grid ul li[data-col="+(widgetchanged_col-1)+"]").each(function(i,w){
// var sizey = parseInt($(this).attr("data-sizey"));
// var sizex = parseInt($(this).attr("data-sizex"));
// if(sizey==1){
// sizex = sizex - 1;
// }
// console.log(sizex);
// if(!isNaN(sizex)){
// total += sizex;
// }
// })
// if(total>totaltiles_in_a_row){
// revertbacktiles();
// }
// }
for (var i = 1; i <= 30; i++) {
// var celement = $(".grid ul .widget[data-col="+i+"]:last");
$(".grid ul .widget[data-col="+i+"]").each(function(){
var pos = $(this).position();
if(pos){
if((pos.top + $(this).height() + 6) > 550){
revertbacktiles();
}
}
})
}
var newpos = o.gridvar.serialize();
console.log(newpos);
$.post("/desktop/newpositions",{"newpositions":newpos});
lastpos.push({"col":$(this).attr("data-col"),"row":$(this).attr("data-row")});
});
})
.end()
.gridster({
widget_margins: [6, 6],
widget_base_dimensions: [120, 120],
draggable : {
start: function(event, ui){
dragged.addClass("noClick");
},
stop: function(event, ui){
for (var i = 1; i <= 30; i++) {
// var celement = $(".grid ul .widget[data-col="+i+"]:last");
$(".grid ul .widget[data-col="+i+"]").each(function(){
var pos = $(this).position();
if(pos && (pos.top + $(this).height() + 6) > 550){
revertbacktiles();
}
});
}
}
}).data('gridster');
}
})
.data('gridster');
var revertbacktiles = function(){
lastpos.push({"col":"","row":""});
$(".grid ul li").each(function(i){
$(this).attr({"data-col":lastpos[i].col,"data-row":lastpos[i].row});
})
});
}
var remove_empty_columns = function(){
for (var i = 1; i <= 30; i++) {
// var celement = $(".grid ul .widget[data-col="+i+"]:last");
$(".grid ul .widget[data-col="+i+"]").each(function(){
})
});
break;
}
}
o.simple_drop_down();
o.tinyscrollbar_ext({
main: '.tinycanvas'
})
$("li.app[data-category=app]").click(function(){
if(!$(this).hasClass("noClick")){
var url = $(this).find("a").data("url");
var app = $(this);
o.appWindow({
"appid" : app.data("id"),
"title" : app.data("title"),
"url" : url
})
}
dragged.removeClass("noClick");
$(".app[data-category=app]").click(function(){
if(!$(this).hasClass("noClick")){
var url = $(this).find("a").data("url");
var app = $(this);
o.appWindow({
"appid" : app.data("id"),
"title" : app.data("title"),
"url" : url
})
}
dragged.removeClass("noClick");
})
// $("div#group_wrapper ul li[data-category=app]").click(function(){
// o.appWindow({
// title : $(this).find("a").attr("href"),
// appid : $(this).find("a").attr("href")
// });
// });
});
o.simple_drop_down();
o.tinyscrollbar_ext({
main: '.tinycanvas'
});
}
var loadTiles = function(id){ //This will load tiles for a specific desktop .. id of section has to be passed here to load tiles
$("div#desktop div#group_wrapper").empty();
$("#desktop #group_wrapper").empty();
$.getJSON("/desktop/getgroups",{sectionid:id},function(tiles){
// tiles.sort(o.sortJSON("position",true,parseInt));
tiles.sort(o.sortJSON("position",true,parseInt));
var tilecolors = o.themesettings.tilecolor;
var totaltiles_in_a_row = 4;
var opacity = ["op07","op08","op09",""];
var row = 0,col = 1,x = 1,y = 1,total_x = 0,prev_y = 0;
var row = 1, col = 1, x = 1, y = 1;
var $group = $('<div class="grid gridster"></div>');
var $ul = $('<ul style="margin: -6px 0 0 -6px;"></ul>');
var $ul = $('<ul></ul>');
$.each(tiles,function(i,tile){
var shape = tile.shape.split(" ");
// if(tile.title == "Weather")console.log("Big - row : " + tile.row + ", col : "+ tile.column);
// if(tile.title == "Google Scholar")console.log("Scholar - row : " + tile.row + ", col : "+ tile.column);
// if(total_x % 2 != 0)
// row = row - y;
// if(i == 7)tile.row = null;
if(tile.row){
row = tile.row;
col = tile.column;
x = parseInt(shape[0].substr(1,1));
y = parseInt(shape[1].substr(1,1));
}else{
x = parseInt(shape[0].substr(1,1));
if(total_x % 2 == 0){
row = row + y;
}else if(x == 1){
col++;
}
y = parseInt(shape[1].substr(1,1));
total_x = total_x + ( x * y );
prev_y = y;
if(total_x > 8){
row = 1;
total_x = 0;
col++;
}
if(row >= 4){
row = 1;
col++;
}
var shape = tile.shape.split(" ");
x = parseInt(shape[0].substr(1,1));
y = parseInt(shape[1].substr(1,1));
var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
var op = opacity[Math.floor(Math.random()*opacity.length)];
var f = (tile.fullsize?"fullsize":null);
if(tile.data_category == "app")
if(tile.data_category == "app"){
$li = $('<li data-id="'+tile.id+'" class="app" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-title="'+tile.title+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile.data_content+'" class="appicon" onclick="return false;" data-url="'+tile.link+'"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
else
$li = $('<li data-id="'+tile.id+'" class="widget '+f+'" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><div class="appholder"><div class="thmtxt o-loading"><i class="icon-spinning icon-spinner"></i> Loading</div></div><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
} else {
$li = $('<li data-id="'+tile.id+'" class="widget '+f+'" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><div class="appholder"></div><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
}
row = row + y;
$ul.append($li);
})
});
$group.append($ul);
$("div#desktop div#group_wrapper").append($group);
$("#desktop #group_wrapper").append($group);
bindHandlers();
o.initializeWidgets();
})
// var tilecolors = o.themesettings.tilecolor;
// var opacity = ["op05","op06","op07","op08","op09"];
// $.each(groups,function(i,group){
// group.sort(o.sortJSON("position",true,parseInt));
// // var $group = $('<div class="group"><ul class="grp ui-sortable"></ul></div>'),
// var colindex = 0,
// $group = $('<div class="group"></div>'),
// $col = $('<ul class="g_col g_col_w2 col'+ colindex +'"/>'),
// $li,
// bdsum = 0,
// bwsum = 0,
// bhsum = 0,
// small = 0,
// single = false;
// $group.append($col);
// 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 || bhsum > 6){
// bdsum = 0, bhsum = 0, colindex++,j--;
// $group.append('<ul class="g_col g_col_w2 col'+ colindex +'"/>');
// }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 data-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.data_content+'" 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 data-id="'+tile.id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><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();
o.initializeWidgets();
});
}
var loadSectionList = function(){ //This will load the section list from the db
$.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){
@ -948,39 +766,39 @@ var orbitDesktop = function(dom){
tempstyle = "style='display:none;'";
$("#desktop #section_heading").text(section.name);
}
$("div#desktop ul#section_list").append($('<li class="section_name" '+tempstyle+'><a class="admtxt hp w2 hh1" onclick="return false;" href="'+section._id+'" >'+section.name+'</a></li>'));
})
$("#desktop #section_list").append($('<li class="section_name" '+tempstyle+'><a class="admtxt hp hh1" onclick="return false;" href="'+section._id+'" >'+section.name+'</a></li>'));
});
bindSecondaryHandlers();
o.simple_drop_down();
})
}
var bindSecondaryHandlers = function(){ //This is the secondary bind handler function which is used to bind events which are repeatative
$("div#desktop ul#section_list li.section_name").click(function(){
$("div#desktop li.section_name").show();
$("#desktop #section_list .section_name").click(function(){
$("#desktop .section_name").show();
$(this).hide();
$("#desktop #section_heading").text($(this).text());
o.sectionId = $(this).find("a").attr("href");
loadTiles(o.sectionId);
})
});
}
if(cache){
bindHandlers();
o.initializeWidgets();
bindSecondaryHandlers();
$("div#desktop ul#section_list").empty();
$("#desktop #section_list").empty();
$.each(o.sectionList,function(i,section){
var tempstyle="";
if(section._id==o.sectionId){
tempstyle = "style='display:none;'";
$("div#desktop span#section_heading").text(section.name);
$("#desktop #section_heading").text(section.name);
}
$("div#desktop ul#section_list").append($('<li class="section_name" '+tempstyle+'><a class="admtxt hp w2 hh1" onclick="return false;" href="'+section._id+'" >'+section.name+'</a></li>'));
})
$("#desktop #section_list").append($('<li class="section_name" '+tempstyle+'><a class="admtxt hp w2 hh1" onclick="return false;" href="'+section._id+'" >'+section.name+'</a></li>'));
});
bindSecondaryHandlers();
}else{
loadTiles(o.sectionId);
loadSectionList();
loadTiles(o.sectionId);
}
};
}
this.tempFunc = function(th){
$.post("desktop/twitter",function(){});
@ -996,11 +814,11 @@ var orbitDesktop = function(dom){
//for textbox search
$("#app_manager #searchbox").focus(function(){$(this).val("");}).keyup(function(e){
if($(this).val()){
$("div#app_manager .search_result").empty();
$("div#app_manager #seperator").hide();
searchArray = $("div#app_manager .element:containsi("+$(this).val()+")");
$("#app_manager .search_result").empty();
$("#app_manager #seperator").hide();
searchArray = $("#app_manager .element:containsi("+$(this).val()+")");
if(searchArray.length>0){
$("div#app_manager #seperator").show();
$("#app_manager #seperator").show();
var i = 0;
var $column;
searchArray.each(function(){
@ -1011,19 +829,19 @@ var orbitDesktop = function(dom){
var $newelement = $('<div class="search element w1 h1 hp vp thmc2" data-category="desktop">'+$(this).html()+'</div>');
$column.append($newelement);
if(i == 4){
$("div#app_manager .search_result").append($column);
$("#app_manager .search_result").append($column);
i = 0;
}
})
if(i != 0){
$("div#app_manager .search_result").append($column);
$("#app_manager .search_result").append($column);
}
}
}else{$("div#app_manager #seperator").hide();$("div#app_manager .search_result").empty();}
}else{$("#app_manager #seperator").hide();$("#app_manager .search_result").empty();}
}).blur(function(){$(this).val("Search");});
//for Alphabet sorting
$("div#app_manager a#alphabet_sort_btn").click(function(){
$("#app_manager #alphabet_sort_btn").click(function(){
switch ($(this).attr("href")){
case "ascending":
$(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
@ -1031,10 +849,10 @@ var orbitDesktop = function(dom){
break;
case "descending":
$(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]");
allApps = $("div#app_manager .group_search .element").sort(sortDescending);
allApps = $("#app_manager .group_search .element").sort(sortDescending);
break;
}
$("div#app_manager #app_list").empty();
$("#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){
@ -1046,9 +864,9 @@ var orbitDesktop = function(dom){
} else {
$('.g_col.col'+ colindex).append(app);
}
})
});
return false;
})
});
}
var loadApps = function(){ //this load apps for sorting and searching
$.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
@ -1066,22 +884,23 @@ var orbitDesktop = function(dom){
} else {
$('.g_col.col'+ colindex).append($app);
}
})
})
});
});
bindHandlers();
})
});
}
if(cache)
if(cache){
bindHandlers();
else
} else {
loadApps();
}
};
this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager
var elementParent,element,slabel;
var bindHandlers = function(){ // this is bind handler for section manager page
var groupWrapperWidth = 0;
$("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
$("#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
groupWrapperWidth+=200;
groupWrapperHeight = $(".group").height() + 20;
$("#group_wrapper").width(groupWrapperWidth);
@ -1095,9 +914,9 @@ var orbitDesktop = function(dom){
slabel.find('li:not(:nth-child(1))').stop(1,1).fadeOut(500);
}
}
$("div#sections #group_wrapper .appgroup").sortable(sortingoptions);
$("#sections #group_wrapper .appgroup").sortable(sortingoptions);
$("div#sections .section_label li:not(:nth-child(1))").droppable({
$("#sections .section_label li:not(:nth-child(1))").droppable({
drop:function(event, ui){
elementParent = ui.draggable.parents('.group');
elementParentUl = ui.draggable.parents(".appgroup");
@ -1141,15 +960,15 @@ var orbitDesktop = function(dom){
}
if(newul){
$("div#sections #group_wrapper .appgroup").sortable(sortingoptions);
$("#sections #group_wrapper .appgroup").sortable(sortingoptions);
$list.removeClass("no_app");
}
});
$.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":ui.draggable.attr("id"),"newsectionid":$(this).data("content"),"desktopid":o.desktopId});
// if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){
if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){
o.desktopData["home"]="";
// }
}
}
$(this).find('span.tile').addClass('op06',400);
},
@ -1175,12 +994,12 @@ var orbitDesktop = function(dom){
}
if(z!=x){
$lii = $('<li class="element w1 h1 hp vp thmtxt" style="display: none;" data-category="section'+(x+1)+'" data-content="'+o.sectionList[x]._id+'"><span class="tile thmc2 op06"></span><span class="thmtxt">'+o.sectionList[x].name+'</span></li>');
$group.find("ul.section_grp").append($lii);
$group.find(".section_grp").append($lii);
}
}
z++;
$("div#group_wrapper").append($group);
$("#group_wrapper").append($group);
}
var x = 0;
@ -1194,14 +1013,14 @@ var orbitDesktop = function(dom){
$li = $('<li class="element to_drop w1 hh2 hp vp" data-category="'+app.data_category+'" data-content="'+app.data_content+'" id="'+app._id+'"><div class="appicon"><img src="'+o.iconPath+app.data_content+'.png" class="" width="30" /></div><h1 class="appname thmtxth">'+app.title+'</h1></li>');
$ul.append($li);
if(x == 7){
$("div#group_wrapper div#section"+(i+1)).append($ul);
$("div#group_wrapper div#section"+(i+1)).removeClass("no_app")
$("#group_wrapper #section"+(i+1)).append($ul);
$("#group_wrapper #section"+(i+1)).removeClass("no_app")
x = 0;
}
})
if(x != 0){
$("div#group_wrapper div#section"+(i+1)).append($ul);
$("div#group_wrapper div#section"+(i+1)).removeClass("no_app")
$("#group_wrapper #section"+(i+1)).append($ul);
$("#group_wrapper #section"+(i+1)).removeClass("no_app")
}
})
bindHandlers();
@ -1227,7 +1046,7 @@ var orbitDesktop = function(dom){
this.initializeSettings.sections = function(){ // this load section page in setting page
var bindHandlers = function(){ // binding handlers in section page
$("a#name_save_btn").click(function(){
$("#name_save_btn").click(function(){
var desktopnm = new Array;
$("#desktop_names input").each(function(){
desktopnm.push($(this).val());
@ -1294,7 +1113,7 @@ var orbitDesktop = function(dom){
}
});
$("a#theme_submit").click(function(){
$("#theme_submit").click(function(){
o.confirm({
message : "Are you sure that you want to save custom theme?",
highlighted : 1,
@ -1438,7 +1257,7 @@ var orbitDesktop = function(dom){
$ul.find("input[type=password]").replaceWith("<div class='c_info pwd'>&#8226;&#8226;&#8226;&#8226;&#8226;&#8226;</div>");
$ul.find("a[for=new]").text("Edit").attr("for","edit");
$ul.find("a[for=delete]").show();
$ul.find("span.c_status").text("Connected").addClass("c_status_on");
$ul.find(".c_status").text("Connected").addClass("c_status_on");
})
bindHandlers();
})
@ -1558,21 +1377,21 @@ var orbitDesktop = function(dom){
s_name_list_not+= "<a href='addthis' for='"+sec_link+"' style='text-decoration:underline;'>"+sec_name+"</a> ";
}
})
li.find("div.status").html("Status : Installed on "+s_name_list);
li.find(".status").html("Status : Installed on "+s_name_list);
if(s_name_list_not)
li.find("div.not_status").html("Install on "+s_name_list_not);
li.find(".not_status").html("Install on "+s_name_list_not);
}else{
li.find("div.not_status").html("Install on <a href='addthis' for='"+o.sectionList[0]._id+"' style='text-decoration:underline;'>"+o.sectionList[0].name+"</a> <a href='addthis' for='"+o.sectionList[1]._id+"' style='text-decoration:underline;'>"+o.sectionList[1].name+"</a> <a href='addthis' for='"+o.sectionList[2]._id+"' style='text-decoration:underline;'>"+o.sectionList[2].name+"</a> <a href='addthis' for='"+o.sectionList[3]._id+"' style='text-decoration:underline;'>"+o.sectionList[3].name)+"</a>";
li.find(".not_status").html("Install on <a href='addthis' for='"+o.sectionList[0]._id+"' style='text-decoration:underline;'>"+o.sectionList[0].name+"</a> <a href='addthis' for='"+o.sectionList[1]._id+"' style='text-decoration:underline;'>"+o.sectionList[1].name+"</a> <a href='addthis' for='"+o.sectionList[2]._id+"' style='text-decoration:underline;'>"+o.sectionList[2].name+"</a> <a href='addthis' for='"+o.sectionList[3]._id+"' style='text-decoration:underline;'>"+o.sectionList[3].name)+"</a>";
}
//console.log(section_names);
column.find("ul").append(li);
if(counter%4==0){
$("#apps_store div#widget_list").append(column);
$("#apps_store #widget_list").append(column);
column = $('<div class="g_col list_t" style="width:350px;"><ul></ul></div>');
}
counter++;
})
$("#apps_store div#widget_list").append(column);
$("#apps_store #widget_list").append(column);
})
@ -1592,33 +1411,52 @@ var orbitDesktop = function(dom){
this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper
wallpapernm = (!wallpaper) ? o.themesettings.background : wallpaper;
if(!wallpaper){
$("img#thmbackground").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+wallpapernm);
$("#thmbackground").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+wallpapernm);
} else {
$("img#thmbackground").attr("src",o.wallpaperPath+wallpaper);
$("#thmbackground").attr("src",o.wallpaperPath+wallpaper);
}
};
this.loadIconCache = function(){ // this function load or refresh icon cache for the theme
var imgs = $("ul.docklist img");
var imgs = $(".docklist img");
$.each(imgs,function(){
var setting_name = $(this).attr("id").replace("_icon","");
$(this).attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons[setting_name])
})
};
this.initializeWidgets = function(){ // this function will initialize all the widgets in the desktop
var elements = $("#group_wrapper li.widget");
var elements = $("#group_wrapper .widget"),
loading = '<div class="thmtxt o-loading"><i class="icon-spin icon-spinner"></i> Loading</div>';
$.each(elements,function(){
var widget = $(this);
var widget = $(this),
widget_holder = $(this).find('.appholder'),
widget_style = (widget.find('.widget_style').length > 0) ? '' : '<link class="widget_style" rel="stylesheet" href="'+widget.attr("css-link")+'" type="text/css" />';
if(widget.attr("data-category")=="widget"){
var widgename = widget.attr("data-content");
$.getScript(widget.attr("js-link"),function(){
widget.find("div.appholder").load(widget.attr("data-content"));
var widgetname = widget.attr("data-content");
widget_holder.before(widget_style).empty();
$.getScript(widget.attr("js-link")).done(function(){
// widget.find(".appholder").load(widget.attr("data-content"));
$.ajax({
url: widgetname,
beforeSend: function(){
widget_holder.html(loading);
},
success: function(html){
widget_holder
.css('top','100%')
.html(html);
},
complete: function(){
widget_holder
.delay(300)
.animate({top:'0'},500,'easeInOutQuint');
}
});
});
$(this).find("div.appholder").append( '<link rel="stylesheet" id="dyn_css" href="'+widget.attr("css-link")+'" type="text/css" />')
// $(this).find(".appholder").append( '<link rel="stylesheet" href="'+widget.attr("css-link")+'" type="text/css" />');
}
})
});
};
this.saveWallpaper = function(wallpaper){ // this function saves wallpaper in db
$.post("/desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){
@ -1734,12 +1572,6 @@ var orbitDesktop = function(dom){
});
});
}
this.use_select2 = function(){
$('select:not(.select2-offscreen)').select2({
minimumResultsForSearch: -1
// minimumInputLength: -1
});
}
o.initialize();
}

View File

@ -478,6 +478,9 @@ a:focus {
left: 0;
top: 0; }
.gridster ul {
margin: -6px 0 0 -6px; }
.widget.gs_w {
cursor: move;
overflow: hidden; }

View File

@ -280,7 +280,6 @@ a:focus { outline: none; }
font-weight: normal;
}
}
/* panel */
#panel_l {
background-color: #f0f0f0;
@ -421,8 +420,6 @@ a:focus { outline: none; }
margin-right: 6px;
}
}
.appholder {
position: relative;
z-index: 2;
@ -455,6 +452,9 @@ a:focus { outline: none; }
left: 0;
top: 0;
}
.gridster ul {
margin: -6px 0 0 -6px;
}
.widget.gs_w {
cursor: move;
overflow: hidden;

View File

@ -86,15 +86,12 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
position: absolute;
z-index: 9999;
top: 100%;
background-color: #dddddd;
background-color: #fff;
color: #000;
border: 1px solid #dddddd;
border-top: 0; }
border: 2px solid #dddddd; }
.select2-drop.select2-drop-above {
margin-top: 1px;
border-top: 1px solid #dddddd;
border-bottom: 0; }
margin-top: 1px; }
.select2-container .select2-choice div {
display: block;
@ -171,8 +168,6 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
/* results */
.select2-results {
max-height: 200px;
padding: 0 0 0 4px;
margin: 4px 4px 4px 0;
font-size: 13px;
position: relative;
overflow-x: hidden;
@ -206,13 +201,16 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
.select2-results li {
list-style: none;
display: list-item;
background-image: none; }
background-image: none;
border-top: solid 1px #f7f7f7; }
.select2-results li :first-child {
border-top: 0; }
.select2-results li.select2-result-with-children > .select2-result-label {
font-weight: bold; }
.select2-results .select2-result-label {
padding: 4px 6px;
padding: 6px;
margin: 0;
cursor: pointer;
-webkit-touch-callout: none;

View File

@ -86,16 +86,16 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
position: absolute;
z-index: 9999;
top: 100%;
background-color: $gray;
background-color: #fff;
color: #000;
border: 1px solid $gray;
border-top: 0;
border: 2px solid $gray;
// border-top: 0;
}
.select2-drop.select2-drop-above {
margin-top: 1px;
border-top: 1px solid $gray;
border-bottom: 0;
// border-top: 1px solid $gray;
// border-bottom: 0;
}
.select2-container .select2-choice div {
@ -180,8 +180,8 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
/* results */
.select2-results {
max-height: 200px;
padding: 0 0 0 4px;
margin: 4px 4px 4px 0;
// padding: 0 0 0 4px;
// margin: 4px 4px 4px 0;
font-size: 13px;
position: relative;
overflow-x: hidden;
@ -205,6 +205,11 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
list-style: none;
display: list-item;
background-image: none;
border-top: solid 1px lighten($gray, 10%);
:first-child {
border-top: 0;
}
}
.select2-results li.select2-result-with-children > .select2-result-label {
@ -212,7 +217,7 @@ Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
}
.select2-results .select2-result-label {
padding: 4px 6px;
padding: 6px;
margin: 0;
cursor: pointer;