// JavaScript Document //harry var orbitDesktop = function(dom){ orbitDesktopAPI.apply(this); o = this; this.contentHolder = dom; this.themesettings = ""; this.theme = "default"; // this.themefolder = "themes"; this.transitionTime = 500; this.currenthtml = "desktop.html"; this.currentface = "home"; this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":""}; this.tp = ""; this.initialize = function(){ var theme = o.theme; $.getJSON("/desktop/get_desktop_settings",{id:o.desktopId},function(desktopSettings){ if(desktopSettings){ theme = desktopSettings.theme; o.theme = theme; loadTheme(); }else{loadTheme();} }) var loadTheme = function(){ $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ o.themesettings = eval(ts); $('head').append( $('').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css)); $(document).ready(function(){o.loadWallpaper();o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();}); }) } }; this.changeTheme = function(theme){ o.theme = theme; $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ o.themesettings = eval(ts); $('head').find("#dyn_css").remove(); $('head').append( $('').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css)); o.loadWallpaper(); o.loadIconCache(); }) }; this.bindDesktopEvents = function(){ $("a#d_app_manager").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.initializeAppSearch(target); }); } }); $("a#d_desktop").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.initializeDesktop(target); }); } }); $("a#d_sections").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.initializeSectionsManager(target); }); } }); $("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); }); } }); $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); }); $(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); }*/ }); 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(); }); }; this.initializeDesktop = function(target){ if(!target)target = "desktop"; 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); } } }); $('.tinycanvas').tinyscrollbar({ axis: 'x'}); $("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'); }); } } if(!o.desktopData[o.currentface]){ $(o.contentHolder).empty().load("/desktop/"+target,function(){ bindHandlers(); o.initializeWidgets(); }); }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); bindHandlers(); o.initializeWidgets(); } }; this.tempFunc = function(){ //o.notify("This is test notification!!","alert",2) $.post("/desktop/save_desktop_settings",{"id":o.desktopId,"theme":$('.theme_name').text()},function(){ o.notify("Settings Saved!!","success"); }) } 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 = $('