Desktop Commit
This commit is contained in:
1 parent
4798cd43c1
commit
2e283a039d
43 files changed
+793
-1
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery-ui
|
||||
//= require bootstrap
|
||||
//= require orbitdesktopAPI
|
||||
//= require orbitdesktop
|
||||
//= require desktopload
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
//orbitDesktop.prototype.themesfolder = "<%= "#{Rails.root}/lib/desktop_themes" %>";
|
||||
var od = new orbitDesktop("#ajax_container");
|
||||
// alert(od.themefolder);
|
||||
$(document).ready(function(){
|
||||
alert("something");
|
||||
|
||||
// od.initializeDesktop();
|
||||
});
|
||||
|
||||
Executable
+242
@@ -0,0 +1,242 @@
|
||||
// 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":"","fun":"","work":"","favorite":"","apps_manager":"","sections":""};
|
||||
this.tp = "";
|
||||
this.initialize = function(){
|
||||
var theme = o.theme;
|
||||
$.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();});
|
||||
};
|
||||
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( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', o.themefolder+"/"+theme+"/css/"+ts.css));
|
||||
o.loadWallpaper();
|
||||
o.loadIconCache();
|
||||
})
|
||||
|
||||
};
|
||||
this.bindDesktopEvents = function(){
|
||||
$("a#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#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#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);
|
||||
});
|
||||
}
|
||||
});
|
||||
$("select#change_theme").change(function(){
|
||||
o.changeTheme($(this).val());
|
||||
})
|
||||
$(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);
|
||||
}*/
|
||||
});
|
||||
};
|
||||
this.initializeDesktop = function(target){
|
||||
if(!target)target = "desktop.html";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("pages/"+target,function(){
|
||||
bindHandlers();
|
||||
});
|
||||
}else{
|
||||
$(o.contentHolder).html(o.desktopData[o.currentface]);
|
||||
bindHandlers();
|
||||
}
|
||||
};
|
||||
this.tempFunc = function(){
|
||||
alert(o.tp);
|
||||
}
|
||||
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;
|
||||
})
|
||||
}
|
||||
if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("pages/"+target,function(){
|
||||
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(){
|
||||
if($("#"+$(this).attr("data-category")+" .element").length>=24)
|
||||
o.notify("Section is full");
|
||||
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");});
|
||||
};
|
||||
if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("pages/"+target,function(){
|
||||
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)
|
||||
$("img#thmbackground").attr({"src":o.themefolder+"/"+o.theme+"/images/"+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
|
||||
else
|
||||
$("img#thmbackground").attr({"src":"images/"+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
|
||||
|
||||
$("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh});
|
||||
};
|
||||
this.loadIconCache = function(){
|
||||
$("#home_icon").attr("src","themes/"+o.theme+"/images/"+o.themesettings.icons.home);
|
||||
$("#app_manager_icon").attr("src","themes/"+o.theme+"/images/"+o.themesettings.icons.app_manager);
|
||||
$("#sections_icon").attr("src","themes/"+o.theme+"/images/"+o.themesettings.icons.sections);
|
||||
}
|
||||
o.initialize();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// JavaScript Document
|
||||
$.extend($.expr[':'], {
|
||||
'containsi': function (elem, i, match, array) {
|
||||
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
||||
}
|
||||
});
|
||||
$.fn.sort = function(c) {
|
||||
return this.pushStack([].sort.apply(this, arguments), []);
|
||||
};
|
||||
var sortAscending = function(a, b) {
|
||||
return $(a).find("h1").text() > $(b).find("h1").text() ? 1 : -1;
|
||||
};
|
||||
var sortDescending = function(a, b) {
|
||||
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
|
||||
};
|
||||
var orbitDesktopAPI = function(){
|
||||
o = this;
|
||||
this.notify = function(msg){
|
||||
alert(msg);
|
||||
};
|
||||
|
||||
};
|
||||
Reference in new issue
Block a user