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

310 lines
12 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";
this.desktopData = {"home":"","fun":"","work":"","favorite":"","apps_manager":"","sections":""};
this.tp = "";
this.initialize = function(){
var theme = o.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);
2012-03-29 07:23:48 +00:00
$('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
})
2012-03-29 07:23:48 +00:00
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);
});
}
});
$("select#change_theme").change(function(){
o.changeTheme($(this).val());
})
$(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
});
$(o.contentHolder).mousemove(function(event){
/*if(($(window).width()-50)<=event.pageX){
$("#holder").animate({scrollLeft:$("#holder").scrollLeft()+500},1000);
}
if(event.pageX<300){
$("#holder").animate({scrollLeft:0},1000);
}*/
});
};
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";
var groupWrapperWidth = 0;
var groupWrapperHeight = 0;
var extraspace = 300;
var currentElement, elementParent, targetParent, tempElement, widthcheck;
widthcheck = false;
var bindHandlers = function(){
$(".element").mousedown(function(){
currentElement = $(this);
elementParent = $(this).parent();
})
$(".group").mouseenter(function(){
targetParent = $(this);
})
$(".group").each(function(){groupWrapperWidth+=$(this).width();})
groupWrapperWidth+=200;
groupWrapperHeight = $(".group").height() + 20;
groupWrapperHeight = (groupWrapperHeight > ($(window).height()-extraspace))? $(window).height()-extraspace:groupWrapperHeight;
$("#group_wrapper").css("width",groupWrapperWidth);
$(".grp").sortable({
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);
var newParentWidth = $("#group_wrapper").width()+currentElementWidth;
$("#group_wrapper").css("width",newParentWidth);
}else if(targetParent.height()<540){
var newWidth = targetElementWidth - (540-targetElementWidth);
targetParent.css("max-width",newWidth);
var newParentWidth = $("#group_wrapper").width()+currentElementWidth;
$("#group_wrapper").css("width",newParentWidth);
}
}
});
2012-04-04 18:31:32 +00:00
$('#holder').tinyscrollbar({ axis: 'x'});
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-03-28 10:53:30 +00:00
bindHandlers();
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
bindHandlers();
}
};
this.tempFunc = function(){
2012-03-30 10:06:06 +00:00
o.notify("This is test notification!!","alert",2)
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(){
$("#group_wrapper").css("min-width",$(window).width()-100);
$(".group_search").css("width",$(window).width()-200);
//for textbox search
$("#searchbox").focus(function(){$(this).val("");}).keyup(function(e){
if($(this).val()){
$(".search_result").empty();
$("#seperator").hide();
searchArray = $(".element:containsi("+$(this).val()+")");
if(searchArray.length>0){
$("#seperator").show();
searchArray.each(function(){
var $newelement = $('<div class="search element w1 h1 hp vp thmc2" data-category="desktop">'+$(this).html()+'</div>');
$(".search_result").prepend($newelement);
})
}
}else{$("#seperator").hide();$(".search_result").empty();}
}).blur(function(){$(this).val("Search");});
//for Alphabet sorting
$("a#alphabet_sort_btn").click(function(){
switch ($(this).attr("href")) {
case "ascending":
$(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
allApps = $(".group_search .element").sort(sortAscending);
break;
case "descending":
$(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]");
allApps = $(".group_search .element").sort(sortDescending);
break;
}
$(".group_search").html(allApps);
return false;
})
2012-04-04 18:31:32 +00:00
$('#holder').tinyscrollbar({ axis: 'x'});
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-03-28 10:53:30 +00:00
bindHandlers();
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
bindHandlers();
}
};
this.initializeSectionsManager = function(target){
o.currenthtml = target;
o.currentface = "settings";
var elementParent,element;
var bindHandlers = function(){
$(".group").width(530);
$("#group_wrapper .element").sortable({
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);
}
});
$(".section_label ul li:not(:nth-child(1))").droppable({
drop:function(){
2012-03-29 11:50:23 +00:00
if($("#"+$(this).attr("data-category")+" .element").length>=24){
o.notify("Section is full.","alert");
}
2012-03-28 10:53:30 +00:00
else
$("#"+$(this).attr("data-category")).append(element);
}
});
$(".section_label ul li:not(:nth-child(1)) span.tile").hover(function(){
$(this).toggleClass("op06");
})//.mouseleave(function(){$(this).addClass("op06");});
2012-04-04 18:31:32 +00:00
$('#holder').tinyscrollbar({ axis: 'x'});
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-03-28 10:53:30 +00:00
bindHandlers();
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
bindHandlers();
}
};
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-03-29 07:23:48 +00:00
$("#home_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.home);
$("#app_manager_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.app_manager);
$("#sections_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.sections);
2012-04-03 10:06:16 +00:00
$("#settings_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.settings);
$("#publication_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.publication);
$("#journal_p_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.journal_p);
$("#seminar_p_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.seminar_p);
$("#books_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.books);
$("#research_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.research);
$("#research_d_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.research_d);
$("#research_p_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.research_p);
$("#patents_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.patents);
$("#labs_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.labs);
$("#experience_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.experience);
$("#working_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.working);
$("#education_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.education);
$("#honors_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.honors);
$("#activities_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.activities);
$("#clubs_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.clubs);
$("#landt_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.landt);
$("#courses_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.courses);
$("#homework_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.homework);
$("#certification_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.certification);
$("#personal_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.personal);
$("#mypage_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.mypage);
$("#blog_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.blog);
$("#album_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.album);
$("#calendar_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.calendar);
$("#files_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.files);
$("#orbit_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.orbit);
$("#connection_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.connection);
$("#appstore_icon").attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons.appstore);
2012-03-28 10:53:30 +00:00
}
o.initialize();
}
2012-03-29 07:23:48 +00:00
orbitDesktop.prototype.themefolder = "themes";
2012-04-03 21:53:49 +00:00
// devin
(function(){
$(document).ready(function(){
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-04-04 18:31:32 +00:00
2012-04-03 21:53:49 +00:00
});
}());