orbit-basic/app/assets/javascripts/orbitdesktop.js

588 lines
22 KiB
JavaScript
Raw Normal View History

2012-03-28 10:53:30 +00:00
// JavaScript Document
//harry
var orbitDesktop = function(dom){
orbitDesktopAPI.apply(this);
o = this;
this.contentHolder = dom;
this.themesettings = "";
this.theme = "default";
2012-03-29 07:23:48 +00:00
// this.themefolder = "themes";
2012-03-28 10:53:30 +00:00
this.transitionTime = 500;
this.currenthtml = "desktop.html";
this.currentface = "home";
2012-04-05 12:09:01 +00:00
this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":""};
2012-03-28 10:53:30 +00:00
this.tp = "";
2012-04-12 06:44:08 +00:00
this.sectionList;
2012-03-28 10:53:30 +00:00
this.initialize = function(){
2012-04-05 12:32:56 +00:00
var theme = o.theme;
2012-04-12 14:18:58 +00:00
$.getJSON("/desktop/get_desktop_settings",{"get":"desktop","desktopid":o.desktopId},function(desktopSettings){
2012-04-05 12:32:56 +00:00
if(desktopSettings){
2012-04-06 09:24:39 +00:00
theme = desktopSettings.theme;
o.theme = theme;
loadTheme();
}else{loadTheme();}
2012-03-28 10:53:30 +00:00
})
2012-04-06 09:24:39 +00:00
var loadTheme = function(){
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
o.themesettings = eval(ts);
$('head').append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
$(document).ready(function(){o.loadWallpaper();o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();});
})
}
2012-03-28 10:53:30 +00:00
};
this.changeTheme = function(theme){
o.theme = theme;
2012-03-29 07:23:48 +00:00
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
2012-03-28 10:53:30 +00:00
o.themesettings = eval(ts);
$('head').find("#dyn_css").remove();
2012-03-30 10:06:06 +00:00
$('head').append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
2012-03-28 10:53:30 +00:00
o.loadWallpaper();
o.loadIconCache();
})
};
this.bindDesktopEvents = function(){
2012-04-04 18:31:32 +00:00
$("a#d_app_manager").click(function(){
2012-03-28 10:53:30 +00:00
var target = $(this).attr("href");
if(o.currenthtml!=target){
o.desktopData[o.currentface] = $(o.contentHolder).html();
$("#content").hide("drop",o.transitionTime,function(){
o.initializeAppSearch(target);
});
}
});
2012-04-04 18:31:32 +00:00
$("a#d_desktop").click(function(){
2012-03-28 10:53:30 +00:00
var target = $(this).attr("href");
if(o.currenthtml!=target){
o.desktopData[o.currentface] = $(o.contentHolder).html();
$("#content").hide("drop",o.transitionTime,function(){
o.initializeDesktop(target);
});
}
});
2012-04-04 18:31:32 +00:00
$("a#d_sections").click(function(){
2012-03-28 10:53:30 +00:00
var target = $(this).attr("href");
if(o.currenthtml!=target){
o.desktopData[o.currentface] = $(o.contentHolder).html();
$("#content").hide("drop",o.transitionTime,function(){
o.initializeSectionsManager(target);
});
}
});
2012-04-05 12:09:01 +00:00
$("a#d_settings").click(function(){
var target = $(this).attr("href");
if(o.currenthtml!=target){
o.desktopData[o.currentface] = $(o.contentHolder).html();
$("#content").hide("drop",o.transitionTime,function(){
o.initializeSettings(target);
2012-04-05 12:09:01 +00:00
});
}
});
2012-03-28 10:53:30 +00:00
$(window).resize(function(){
var ww = $(window).width();
2012-04-03 10:25:41 +00:00
$("img#thmbackground").attr({"width":ww});
2012-03-28 10:53:30 +00:00
});
2012-04-11 07:31:10 +00:00
var $widget_fn = $('.widget_fn'),$fn_des = $('.fn_des');
$widget_fn.hover(function(){
var fn_name = $(this).find('img').attr('alt'),nth = $(this).parents('.d_cate').index(),des_left = $('.dock_child').eq(nth).width();
$(this).addClass('thmc1');
$fn_des.text(fn_name).css({'top':nth * 60,'left': des_left + 60}).stop(true, true).fadeIn();
},function(){
$(this).removeClass('thmc1');
$fn_des.stop(true, true).fadeOut();
2012-03-28 10:53:30 +00:00
});
};
this.initializeDesktop = function(target){
2012-03-29 07:23:48 +00:00
if(!target)target = "desktop";
2012-03-28 10:53:30 +00:00
o.currenthtml = target;
o.currentface = "home";
2012-04-11 07:31:10 +00:00
2012-03-28 10:53:30 +00:00
var extraspace = 300;
var currentElement, elementParent, targetParent, tempElement, widthcheck;
widthcheck = false;
var bindHandlers = function(){
2012-04-11 07:31:10 +00:00
var groupWrapperWidth = 0;
var groupWrapperHeight = 0;
2012-04-16 17:32:53 +00:00
$('div#desktop div.group').width(528);
2012-04-12 14:18:58 +00:00
$("div#desktop .element").mousedown(function(){
2012-03-28 10:53:30 +00:00
currentElement = $(this);
elementParent = $(this).parent();
})
2012-04-12 14:18:58 +00:00
$("div#desktop .group").mouseenter(function(){
2012-03-28 10:53:30 +00:00
targetParent = $(this);
})
2012-04-12 14:18:58 +00:00
$("div#desktop .group").each(function(){groupWrapperWidth+=$(this).width();})
2012-03-28 10:53:30 +00:00
groupWrapperWidth+=200;
groupWrapperHeight = $(".group").height() + 20;
2012-04-12 06:44:08 +00:00
// groupWrapperHeight = (groupWrapperHeight > ($(window).height()-extraspace))? $(window).height()-extraspace:groupWrapperHeight;
2012-04-12 14:18:58 +00:00
$("div#desktop #group_wrapper").css("width",groupWrapperWidth);
var first = true;
2012-04-12 14:18:58 +00:00
$("div#desktop .grp").sortable({
2012-03-28 10:53:30 +00:00
connectWith: ".grp",
tolerance: 'pointer' ,
revert:true,
stop:function(){
o.tp = targetParent.height();
var currentElementWidth = currentElement.width();
var targetElementWidth = targetParent.width();
if(targetParent.height()>540){
//targetParent.width(currentElement.width());
var newWidth = targetElementWidth+currentElementWidth;
targetParent.css("max-width",newWidth);
2012-04-12 14:18:58 +00:00
var newParentWidth = $("div#desktop #group_wrapper").width()+currentElementWidth;
$("div#desktop #group_wrapper").css("width",newParentWidth);
2012-03-28 10:53:30 +00:00
}else if(targetParent.height()<540){
var newWidth = targetElementWidth - (540-targetElementWidth);
targetParent.css("max-width",newWidth);
2012-04-12 14:18:58 +00:00
var newParentWidth = $("div#desktop #group_wrapper").width()+currentElementWidth;
$("div#desktop #group_wrapper").css("width",newParentWidth);
}
first = true;
},
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("ul.grp li");
$.each($ul,function(){
groupone.push($(this).attr("id"));
})
newpostitions.push(groupone);
});
$.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids},function(){
})
}
2012-03-28 10:53:30 +00:00
}
});
2012-04-12 14:18:58 +00:00
$('div#desktop .tinycanvas').tinyscrollbar({ axis: 'x'});
$("div#desktop div.scrollbar").hover(function(){
$(this).removeClass('op01');
}, function(){
$(this).addClass('op01');
});
// simple dropdown menu
var $sdm = $('.sdm');
if( !$sdm.children('.sdm_o') ){
return;
} else {
$sdm.hover(function(){
$(this).addClass('thmc2');
}, function(){
$(this).removeClass('thmc2');
});
}
2012-04-11 07:31:10 +00:00
2012-03-28 10:53:30 +00:00
}
2012-04-11 07:31:10 +00:00
var loadTiles = function(id){
2012-04-12 14:18:58 +00:00
$("div#desktop div#group_wrapper").empty();
2012-04-11 07:31:10 +00:00
$.getJSON("/desktop/getgroups",{sectionid:id},function(groups){
var tilecolors = o.themesettings.tilecolor;
2012-04-11 07:50:27 +00:00
var opacity = ["op05","op06","op07","op08","op09"];
2012-04-11 07:31:10 +00:00
$.each(groups,function(i,group){
group.sort(o.sortJSON("position",true,parseInt));
var $group = $('<div class="group"><ul class="grp ui-sortable"></ul></div>');
$.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);
2012-04-11 07:31:10 +00:00
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>');
2012-04-11 07:31:10 +00:00
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>');
2012-04-11 07:31:10 +00:00
$group.find("ul").append($li);
})
2012-04-12 14:18:58 +00:00
$("div#desktop div#group_wrapper").append($group);
2012-04-11 07:31:10 +00:00
})
bindHandlers();
o.initializeWidgets();
})
}
var loadSectionList = function(){
$.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){
2012-04-12 06:44:08 +00:00
o.sectionList = eval(sectionlist);
2012-04-11 07:31:10 +00:00
$.each(sectionlist,function(i,section){
var tempstyle="";
if(i==0){
tempstyle = "style='display:none;'";
2012-04-12 14:18:58 +00:00
$("div#desktop span#section_heading").text(section.name);
2012-04-11 07:31:10 +00:00
}
2012-04-12 14:18:58 +00:00
$("div#desktop ul#section_list").append($('<li class="section_name" '+tempstyle+'><a class="admtxt hp w2 hh2" onclick="return false;" href="'+section._id+'" >'+section.name+'</a></li>'));
2012-04-11 07:31:10 +00:00
})
bindSecondaryHandlers();
})
}
var bindSecondaryHandlers = function(){
2012-04-12 14:18:58 +00:00
$("div#desktop ul#section_list li.section_name").click(function(){
$("div#desktop li.section_name").show();
2012-04-11 07:31:10 +00:00
$(this).hide();
2012-04-12 14:18:58 +00:00
$("div#desktop span#section_heading").text($(this).text());
o.sectionId = $(this).find("a").attr("href");
loadTiles(o.sectionId);
2012-04-11 07:31:10 +00:00
})
}
2012-03-28 10:53:30 +00:00
if(!o.desktopData[o.currentface]){
2012-03-29 07:23:48 +00:00
$(o.contentHolder).empty().load("/desktop/"+target,function(){
2012-04-11 07:31:10 +00:00
loadTiles(o.sectionId);
loadSectionList();
2012-03-28 10:53:30 +00:00
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
2012-04-11 07:31:10 +00:00
bindHandlers();
o.initializeWidgets();
bindSecondaryHandlers();
2012-04-12 16:00:24 +00:00
$("div#desktop ul#section_list").empty();
$.each(o.sectionList,function(i,section){
var tempstyle="";
if(i==0){
tempstyle = "style='display:none;'";
$("div#desktop span#section_heading").text(section.name);
}
$("div#desktop ul#section_list").append($('<li class="section_name" '+tempstyle+'><a class="admtxt hp w2 hh2" onclick="return false;" href="'+section._id+'" >'+section.name+'</a></li>'));
})
bindSecondaryHandlers();
2012-03-28 10:53:30 +00:00
}
};
2012-04-11 07:22:05 +00:00
this.tempFunc = function(th){
2012-04-12 14:18:58 +00:00
2012-03-28 10:53:30 +00:00
}
this.initializeAppSearch = function(target){
o.currenthtml = target;
o.currentface = "apps_manager";
var searchArray,allApps;
var bindHandlers = function(){
2012-04-12 14:18:58 +00:00
$("div#app_manager #group_wrapper").css("min-width",$(window).width()-100);
$("div#app_manager .group_search").css("width",$(window).width()-200);
2012-03-28 10:53:30 +00:00
//for textbox search
2012-04-12 14:18:58 +00:00
$("div#app_manager #searchbox").focus(function(){$(this).val("");}).keyup(function(e){
2012-03-28 10:53:30 +00:00
if($(this).val()){
2012-04-12 14:18:58 +00:00
$("div#app_manager .search_result").empty();
$("div#app_manager #seperator").hide();
searchArray = $("div#app_manager .element:containsi("+$(this).val()+")");
2012-03-28 10:53:30 +00:00
if(searchArray.length>0){
2012-04-12 14:18:58 +00:00
$("div#app_manager #seperator").show();
2012-03-28 10:53:30 +00:00
searchArray.each(function(){
var $newelement = $('<div class="search element w1 h1 hp vp thmc2" data-category="desktop">'+$(this).html()+'</div>');
2012-04-12 14:18:58 +00:00
$("div#app_manager .search_result").prepend($newelement);
2012-03-28 10:53:30 +00:00
})
}
2012-04-12 14:18:58 +00:00
}else{$("div#app_manager #seperator").hide();$("div#app_manager .search_result").empty();}
2012-03-28 10:53:30 +00:00
}).blur(function(){$(this).val("Search");});
//for Alphabet sorting
2012-04-12 14:18:58 +00:00
$("div#app_manager a#alphabet_sort_btn").click(function(){
2012-04-11 07:31:10 +00:00
switch ($(this).attr("href")){
2012-03-28 10:53:30 +00:00
case "ascending":
$(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
2012-04-12 14:18:58 +00:00
allApps = $("div#app_manager .group_search .element").sort(sortAscending);
2012-03-28 10:53:30 +00:00
break;
case "descending":
$(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]");
2012-04-12 14:18:58 +00:00
allApps = $("div#app_manager .group_search .element").sort(sortDescending);
2012-03-28 10:53:30 +00:00
break;
}
2012-04-12 14:18:58 +00:00
$("div#app_manager .group_search").html(allApps);
2012-03-28 10:53:30 +00:00
return false;
})
2012-04-10 09:44:36 +00:00
$('.tinycanvas').tinyscrollbar({ axis: 'x'});
2012-03-28 10:53:30 +00:00
}
2012-04-12 06:44:08 +00:00
var loadApps = function(){
$.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
$.each(appss,function(i,apps){
$.each(apps,function(i,app){
var $div;
$div = $('<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>');
$("#app_list").append($div);
})
})
bindHandlers();
})
}
2012-03-28 10:53:30 +00:00
if(!o.desktopData[o.currentface]){
2012-04-05 05:58:58 +00:00
$(o.contentHolder).empty().load("/desktop/"+target,function(){
2012-04-12 06:44:08 +00:00
loadApps();
2012-03-28 10:53:30 +00:00
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
bindHandlers();
2012-03-28 10:53:30 +00:00
}
};
this.initializeSectionsManager = function(target){
o.currenthtml = target;
2012-04-05 12:09:01 +00:00
o.currentface = "sections";
2012-04-13 09:01:00 +00:00
var elementParent,element;
2012-03-28 10:53:30 +00:00
var bindHandlers = function(){
2012-04-13 09:01:00 +00:00
var groupWrapperWidth = 0;
2012-04-12 16:00:24 +00:00
$("div#sections .group").width(400);
2012-04-12 14:18:58 +00:00
$("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
2012-04-12 08:25:06 +00:00
groupWrapperWidth+=200;
2012-04-12 16:00:24 +00:00
groupWrapperHeight = $(".group").height() + 20;
2012-04-13 09:01:00 +00:00
$("#group_wrapper").width(groupWrapperWidth);
2012-04-12 14:18:58 +00:00
$("div#sections #group_wrapper .to_drop").sortable({
2012-03-28 10:53:30 +00:00
start:function(){
var $elementParent = $(this).parent().parent();
elementParent = $elementParent;
element = $(this);
$elementParent.find("div.section_label ul li").fadeIn(500);
},
stop:function(){
elementParent.find("div.section_label ul li:not(:nth-child(1))").fadeOut(500);
}
});
2012-04-12 14:18:58 +00:00
$("div#sections .section_label ul li:not(:nth-child(1))").droppable({
2012-03-28 10:53:30 +00:00
drop:function(){
2012-03-29 11:50:23 +00:00
if($("#"+$(this).attr("data-category")+" .element").length>=24){
o.notify("Section is full.","alert");
}
else{
2012-03-28 10:53:30 +00:00
$("#"+$(this).attr("data-category")).append(element);
$.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":element.attr("id"),"newsectionid":$(this).attr("data-content"),"desktopid":o.desktopId})
if(o.sectionId == $(this).attr("data-content") || o.sectionId == elementParent.attr("id")){
o.desktopData["home"]="";
}
}
},
over:function(){
2012-04-09 09:40:03 +00:00
$(this).find('span.tile').removeClass('op06');
},
out:function(){
$(this).find('span.tile').addClass('op06');
}
2012-04-09 09:40:03 +00:00
});
2012-04-10 09:44:36 +00:00
$('.tinycanvas').tinyscrollbar({ axis: 'x'});
var $sdm = $('.sdm');
if( !$sdm.children('.sdm_o') ){
return;
} else {
2012-04-12 06:44:08 +00:00
$sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');});
}
2012-03-28 10:53:30 +00:00
};
2012-04-12 06:44:08 +00:00
var loadApps = function(){
$.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
var $group,$lii,$li;
var z=0;
for(section in o.sectionList){
$group = $('<div class="group" id="'+o.sectionList[section]._id+'"><div class="section_label"><ul class="section_grp"></ul></div><ul class="grp" id="section'+(z+1)+'"></ul></div>');
2012-04-12 06:44:08 +00:00
for(x=0;x<4;x++){
if(x==0){
$li = $('<li class="element w1 h1 hp vp thmtxt" style="font-size:20px;" data-content="'+o.sectionList[z]._id+'"><span class="tile thmc1"></span><span class="thmtxt">'+o.sectionList[z].name+'</span></li>');
2012-04-12 06:44:08 +00:00
$group.find("ul.section_grp").append($li);
}
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>');
2012-04-12 06:44:08 +00:00
$group.find("ul.section_grp").append($lii);
}
}
z++;
$("div#group_wrapper").append($group);
}
2012-04-12 08:25:06 +00:00
var yy=1,y=0;
2012-04-12 06:44:08 +00:00
$.each(appss,function(i,apps){
2012-04-12 08:25:06 +00:00
2012-04-12 06:44:08 +00:00
$.each(apps,function(i,app){
$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>');
2012-04-12 08:25:06 +00:00
$("ul#section"+yy).append($li);
2012-04-12 06:44:08 +00:00
})
2012-04-12 08:25:06 +00:00
if(y==1){
y=-1;
yy++;
}
2012-04-12 06:44:08 +00:00
y++;
})
bindHandlers();
})
}
2012-03-28 10:53:30 +00:00
if(!o.desktopData[o.currentface]){
2012-04-05 05:58:58 +00:00
$(o.contentHolder).empty().load("/desktop/"+target,function(){
2012-04-12 06:44:08 +00:00
loadApps();
2012-03-28 10:53:30 +00:00
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
bindHandlers();
}
};
this.initializeSettings = function(target){
o.currenthtml = target;
o.currentface = "settings";
var bindHandlers = function(){
2012-04-12 14:18:58 +00:00
$("div#settings ul#setting_left_nav li a").click(function(){
2012-04-11 09:58:52 +00:00
var tfunc = $(this).attr("href");
switch(tfunc){
case "themes":
themes();
break;
case "sections":
sections();
break;
}
2012-04-12 14:18:58 +00:00
$("div#settings ul#setting_left_nav li a").removeClass('thmc1 thmtxt').data('clicked',null);
2012-04-12 06:19:53 +00:00
$(this).addClass('thmc1 thmtxt').data('clicked',true);
});
2012-04-12 14:18:58 +00:00
$("div#settings ul#setting_left_nav li a").hover(function(){
2012-04-12 06:19:53 +00:00
$(this).removeClass('admtxt').addClass('thmc1 thmtxt');
}, function(){
var t = $(this).data('clicked') ? '' : 'thmc1 thmtxt';
$(this).removeClass(t).addClass('admtxt');
});
2012-04-11 09:58:52 +00:00
}
var sections = function(){
var bindHandlers = function(){
2012-04-12 06:19:53 +00:00
$('.tinycanvas').each(function(){
var h = $(this).parent().height(),
sh = $(this).siblings('.s_tab').height();
$(this).css({'height': h-sh-24}).tinyscrollbar({ axis: 'y'});
});
2012-04-12 14:18:58 +00:00
$("a#name_save_btn").click(function(){
var desktopnm = new Array;
$("#desktop_names input").each(function(){
desktopnm.push($(this).val());
})
$.post("/desktop/save_desktop_settings",{"save":"desktopnames","desktopid":o.desktopId,"desktopnms":desktopnm},function(result,status){
if(status=="success"){
if(result[0].success=="true")
o.notify("Names Saved!!","success",2);
else
o.notify("Name saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
})
2012-04-12 16:00:24 +00:00
$.each(o.sectionList,function(i,sec){
sec.name = desktopnm[i];
})
2012-04-12 14:18:58 +00:00
})
2012-04-11 09:58:52 +00:00
}
2012-04-12 14:18:58 +00:00
$("div#settings div#panel_r").load("/desktop/settingsections",function(){
$.getJSON("/desktop/get_desktop_settings",{"get":"sectionnames","desktopid":o.desktopId},function(sectionnames){
$("#desktop_names input").each(function(i){
$(this).val(sectionnames[i]);
})
2012-04-11 09:58:52 +00:00
bindHandlers();
2012-04-12 14:18:58 +00:00
})
2012-04-11 09:58:52 +00:00
})
2012-04-11 09:26:25 +00:00
}
2012-04-11 09:58:52 +00:00
var themes = function(){
2012-04-11 09:26:25 +00:00
var bindHandlers = function(){
$(".theme_list > li").click(function(){
o.changeTheme($(this).find('.theme_name').text());
$(".theme_list > li").removeClass('thmc1').data('clicked',null).find('.theme_name').removeClass('thmtxt');
$(this).addClass('thmc1').data('clicked',true).find('.theme_name').addClass('thmtxt');
2012-04-12 14:18:58 +00:00
$.post("/desktop/save_desktop_settings",{"save":"theme","desktopid":o.desktopId,"theme":$(this).text()},function(result,status){
if(status=="success"){
if(result[0].success=="true")
o.notify("Theme Saved!!","success",2);
else
o.notify("Theme saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
});
2012-04-11 09:26:25 +00:00
});
$('.tinycanvas').each(function(){
var h = $(this).parent().height(),
sh = $(this).siblings('.s_tab').height();
$(this).css({'height': h-sh-24}).tinyscrollbar({ axis: 'y'});
});
2012-04-10 09:44:36 +00:00
2012-04-11 09:26:25 +00:00
var $anchor = $('.s_tab a[href*=#]'),
$tabcontent = $('.st_c');
2012-04-10 09:44:36 +00:00
2012-04-11 09:26:25 +00:00
$anchor.each(function(){
$(this).click(function(){
var target = $(this).attr('href');
$anchor.removeClass('thmc2 thmtxt admtxt admbg').addClass('admtxt admbg');
$(this).toggleClass('thmc2 thmtxt admtxt admbg');
$tabcontent.hide();
$(target).show();
$('.tinycanvas').tinyscrollbar_update();
return false;
});
});
$('.color-picker').miniColors();
$('.theme_list li:first-child').data('clicked',true); // this line just for demo
$('.theme_list li').hover(function(){
$(this).addClass('thmc1').find('.theme_name').addClass('thmtxt');
}, function(){
2012-04-12 06:19:53 +00:00
var c = $(this).data('clicked') ? '' : 'thmc1',
t = $(this).data('clicked') ? '' : 'thmtxt';
2012-04-11 09:26:25 +00:00
$(this).removeClass(c).find('.theme_name').removeClass(t);
});
2012-04-11 05:46:32 +00:00
}
2012-04-12 14:18:58 +00:00
$("div#settings div#panel_r").load("/desktop/settingthemes",function(){
$.getJSON("/desktop/get_desktop_settings",{"get":"theme","desktopid":o.desktopId},function(theme){
$("#st1 ul.theme_list li:containsi("+theme+")").addClass("thmc1").find("span").addClass("thmtxt");
2012-04-11 09:26:25 +00:00
bindHandlers();
2012-04-12 14:18:58 +00:00
})
2012-04-11 09:26:25 +00:00
})
}
2012-04-11 07:36:32 +00:00
2012-04-11 09:26:25 +00:00
$(o.contentHolder).empty().load("/desktop/"+target,function(){
2012-04-11 09:58:52 +00:00
bindHandlers();
2012-04-12 06:44:08 +00:00
themes();
2012-04-11 09:26:25 +00:00
});
};
2012-03-28 10:53:30 +00:00
this.loadWallpaper = function(wallpaper){
if(!wallpaper)wallpaper = o.themesettings.background;
var ww = $(window).width();
var wh = $(window).height();
if(o.themesettings.background)
2012-03-29 07:23:48 +00:00
$("img#thmbackground").attr({"src":"/"+o.themefolder+"/"+o.theme+"/images/"+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
2012-03-28 10:53:30 +00:00
else
2012-03-29 07:23:48 +00:00
$("img#thmbackground").attr({"src":"/"+"images/"+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
2012-03-28 10:53:30 +00:00
$("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh});
};
this.loadIconCache = function(){
2012-04-05 12:32:56 +00:00
var imgs = $("ul.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])
})
2012-04-06 07:18:39 +00:00
};
this.initializeWidgets = function(){
var elements = $("#group_wrapper li.element");
$.each(elements,function(){
var widget = $(this);
if(widget.attr("data-category")=="widget"){
2012-04-11 07:31:10 +00:00
var widgename = widget.attr("data-content");
$.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){
widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb");
});
// $(this).find("div.appholder").append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css"));
}
})
2012-03-28 10:53:30 +00:00
}
2012-03-28 10:53:30 +00:00
o.initialize();
}
2012-03-29 07:23:48 +00:00
orbitDesktop.prototype.themefolder = "themes";
orbitDesktop.prototype.widgetfolder = "desktop_widgets";
2012-04-05 12:32:56 +00:00
orbitDesktop.prototype.desktopId = "1";
orbitDesktop.prototype.notifyImgPath = "temp";
2012-04-12 06:44:08 +00:00
orbitDesktop.prototype.iconPath = "/assets/icons/";
2012-04-12 14:18:58 +00:00
orbitDesktop.prototype.currentLanguage = "en";
2012-04-11 07:31:10 +00:00
var uselessfunction = function(){
$.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"});
}
2012-04-03 21:53:49 +00:00