Fetching desktop from db
This commit is contained in:
1 parent
eb219c14b7
commit
4875b339f8
24 files changed
+470
-41
No files matched your search
@@ -82,34 +82,27 @@ var orbitDesktop = function(dom){
|
||||
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();
|
||||
});
|
||||
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(){
|
||||
var groupWrapperWidth = 0;
|
||||
var groupWrapperHeight = 0;
|
||||
$(".element").mousedown(function(){
|
||||
currentElement = $(this);
|
||||
elementParent = $(this).parent();
|
||||
@@ -163,16 +156,65 @@ var orbitDesktop = function(dom){
|
||||
$(this).removeClass('thmc2');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var loadTiles = function(id){
|
||||
$("div#group_wrapper").empty();
|
||||
$.getJSON("/desktop/getgroups",{sectionid:id},function(groups){
|
||||
var tilecolors = o.themesettings.tilecolor;
|
||||
var opacity = ["op05","op06","op07","op08"];
|
||||
$.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(tile.data_category == "app")
|
||||
$li = $('<li class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="" class="appicon"><img src="" alt=""></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
else
|
||||
$li = $('<li 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 holder_f">test content</div></li>');
|
||||
$group.find("ul").append($li);
|
||||
})
|
||||
$("div#group_wrapper").append($group);
|
||||
})
|
||||
bindHandlers();
|
||||
o.initializeWidgets();
|
||||
})
|
||||
}
|
||||
var loadSectionList = function(){
|
||||
$.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){
|
||||
$.each(sectionlist,function(i,section){
|
||||
var tempstyle="";
|
||||
if(i==0){
|
||||
tempstyle = "style='display:none;'";
|
||||
$("span#section_heading").text(section.name);
|
||||
}
|
||||
$("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();
|
||||
})
|
||||
}
|
||||
|
||||
var bindSecondaryHandlers = function(){
|
||||
$("ul#section_list li.section_name").click(function(){
|
||||
$("li.section_name").show();
|
||||
$(this).hide();
|
||||
$("span#section_heading").text($(this).text());
|
||||
loadTiles($(this).find("a").attr("href"));
|
||||
})
|
||||
}
|
||||
|
||||
if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("/desktop/"+target,function(){
|
||||
bindHandlers();
|
||||
o.initializeWidgets();
|
||||
loadTiles(o.sectionId);
|
||||
loadSectionList();
|
||||
});
|
||||
}else{
|
||||
$(o.contentHolder).html(o.desktopData[o.currentface]);
|
||||
bindHandlers();
|
||||
o.initializeWidgets();
|
||||
bindHandlers();
|
||||
o.initializeWidgets();
|
||||
bindSecondaryHandlers();
|
||||
}
|
||||
};
|
||||
this.tempFunc = function(){
|
||||
@@ -206,7 +248,7 @@ var orbitDesktop = function(dom){
|
||||
|
||||
//for Alphabet sorting
|
||||
$("a#alphabet_sort_btn").click(function(){
|
||||
switch ($(this).attr("href")) {
|
||||
switch ($(this).attr("href")){
|
||||
case "ascending":
|
||||
$(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
|
||||
allApps = $(".group_search .element").sort(sortAscending);
|
||||
@@ -225,7 +267,6 @@ var orbitDesktop = function(dom){
|
||||
if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("/desktop/"+target,function(){
|
||||
bindHandlers();
|
||||
|
||||
});
|
||||
}else{
|
||||
$(o.contentHolder).html(o.desktopData[o.currentface]);
|
||||
@@ -276,9 +317,10 @@ var orbitDesktop = function(dom){
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("/desktop/"+target,function(){
|
||||
bindHandlers();
|
||||
bindHandlers();
|
||||
});
|
||||
}else{
|
||||
$(o.contentHolder).html(o.desktopData[o.currentface]);
|
||||
@@ -294,14 +336,14 @@ var orbitDesktop = function(dom){
|
||||
o.changeTheme($(this).val());
|
||||
})
|
||||
}
|
||||
if(!o.desktopData[o.currentface]){
|
||||
// if(!o.desktopData[o.currentface]){
|
||||
$(o.contentHolder).empty().load("/desktop/"+target,function(){
|
||||
bindHandlers();
|
||||
});
|
||||
}else{
|
||||
$(o.contentHolder).html(o.desktopData[o.currentface]);
|
||||
bindHandlers();
|
||||
}
|
||||
// }else{
|
||||
// $(o.contentHolder).html(o.desktopData[o.currentface]);
|
||||
// bindHandlers();
|
||||
// }
|
||||
};
|
||||
this.loadWallpaper = function(wallpaper){
|
||||
if(!wallpaper)wallpaper = o.themesettings.background;
|
||||
@@ -326,7 +368,7 @@ var orbitDesktop = function(dom){
|
||||
$.each(elements,function(){
|
||||
var widget = $(this);
|
||||
if(widget.attr("data-category")=="widget"){
|
||||
var widgename =widget.attr("data-content");
|
||||
var widgename = widget.attr("data-content");
|
||||
$.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){
|
||||
widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb");
|
||||
});
|
||||
@@ -343,4 +385,6 @@ orbitDesktop.prototype.widgetfolder = "desktop_widgets";
|
||||
orbitDesktop.prototype.desktopId = "1";
|
||||
orbitDesktop.prototype.notifyImgPath = "temp";
|
||||
|
||||
// devin
|
||||
var uselessfunction = function(){
|
||||
$.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"});
|
||||
}
|
||||
@@ -38,4 +38,17 @@ var orbitDesktopAPI = function(){
|
||||
if(!time)time=5000; else time=time*1000;
|
||||
$notify.slideDown().delay(time).slideUp();
|
||||
};
|
||||
this.executeFunc = function(func,callbackFn){
|
||||
func.call(this);
|
||||
if(callbackFn){
|
||||
callbackFn.call(this,func);
|
||||
}
|
||||
};
|
||||
this.sortJSON = function(field, reverse, primer){
|
||||
var key = function (x) {return primer ? primer(x[field]) : x[field]};
|
||||
return function (a,b) {
|
||||
var A = key(a), B = key(b);
|
||||
return ((A < B) ? -1 : (A > B) ? +1 : 0) * [-1,1][+!!reverse];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,6 +3,7 @@ class DesktopController< ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
def index
|
||||
@desktop = current_user.desktop
|
||||
@section = @desktop.sections.first
|
||||
end
|
||||
|
||||
def desktop
|
||||
@@ -34,4 +35,37 @@ class DesktopController< ApplicationController
|
||||
def settings
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def getgroups
|
||||
@section = Section.find(params["sectionid"])
|
||||
@groups = @section.groups
|
||||
a = Array.new
|
||||
@groups.each do |group|
|
||||
a << group.tiles
|
||||
end
|
||||
render :json =>a.to_json
|
||||
end
|
||||
|
||||
def getsectionlist
|
||||
@desktop = Desktop.find(params["desktopid"])
|
||||
@sections = @desktop.sections
|
||||
render :json => @sections.to_json
|
||||
end
|
||||
|
||||
def temp_func
|
||||
@section = Section.find(params["sectionid"])
|
||||
@groups = @section.groups
|
||||
|
||||
@groups.each do |group|
|
||||
a = 1;
|
||||
@tiles = group.tiles
|
||||
@tiles.each do |tile|
|
||||
tile.update_attributes({:data_category => "widget",:data_content => "temp", :position => a})
|
||||
a = a+1;
|
||||
end
|
||||
end
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
end
|
||||
+6
-2
@@ -7,8 +7,12 @@ class Group
|
||||
before_create :initialize_tile
|
||||
|
||||
def initialize_tile
|
||||
self.tiles.build
|
||||
self.tiles.build
|
||||
self.tiles.build(data_category: "widget", data_content: "timetable", position: 1, shape: "w2 h2", title: "Tiime Table")
|
||||
self.tiles.build(data_category: "app", data_content: "quotes", position: 2, shape: "w1 h1", title: "Quotes")
|
||||
self.tiles.build(data_category: "widget", data_content: "weather", position: 3, shape: "w2 h2", title: "Weather")
|
||||
self.tiles.build(data_category: "widget", data_content: "clock", position: 4, shape: "w2 h1", title: "Clock")
|
||||
self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 5, shape: "w1 h1", title: "Daily English Word")
|
||||
self.tiles.build(data_category: "widget", data_content: "school_events", position: 6, shape: "w2 h1", title: "School Events")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,6 +2,12 @@ class Tile
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :data_category
|
||||
field :data_content
|
||||
field :position, type: Integer
|
||||
field :shape
|
||||
field :title
|
||||
|
||||
belongs_to :group
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<div id="content">
|
||||
<div id="header" class="hh3">
|
||||
<div class="dtitle w2 hh3 hp sdm">
|
||||
<span class="thmtxth">Campus</span>
|
||||
<span class="thmtxth" id="section_heading">Loading...</span>
|
||||
<div class="admbg sdm_o">
|
||||
<ul>
|
||||
<ul id="section_list">
|
||||
<!-- <li><a class="admtxt hp w2 hh2" href="">Campus</a></li>
|
||||
<li><a class="admtxt hp w2 hh2" href="">Research</a></li>
|
||||
<li><a class="admtxt hp w2 hh2" href="">Social</a></li>
|
||||
<li><a class="admtxt hp w2 hh2" href="">Private</a></li>
|
||||
<li><a class="admtxt hp w2 hh2" href="">Private</a></li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -15,7 +16,7 @@
|
||||
<div class="scrollbar op01"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
|
||||
<div class="viewport">
|
||||
<div id="group_wrapper" class="overview">
|
||||
<div class="group">
|
||||
<!-- <div class="group">
|
||||
<ul class="grp ui-sortable">
|
||||
<li class="element w2 h2 hp vp" data-category="abc">
|
||||
<span class="tile thmc1 op07"></span>
|
||||
@@ -87,9 +88,9 @@
|
||||
<h1 class="appname thmtxt">Aperture</h1>
|
||||
</li><li style="" class="element w1 h1 hp vp thmc1 op07" data-category="desktop">
|
||||
<h1 class="appname thmtxt">Aperture</h1>
|
||||
</li>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
orbitDesktop.prototype.themefolder = "desktop_themes";
|
||||
orbitDesktop.prototype.notifyImgPath = "/assets/";
|
||||
orbitDesktop.prototype.desktopId = "<%= @desktop.id %>";
|
||||
orbitDesktop.prototype.sectionId = "<%= @section.id %>";
|
||||
//uselessfunction();
|
||||
var od = new orbitDesktop("#ajax_container");
|
||||
o.notify("Notification Working!!","imp",5)
|
||||
o.notify("Notification Working!!","imp",3)
|
||||
</script>
|
||||
Reference in new issue
Block a user