section page fixed..

This commit is contained in:
Harry Bomrah 2013-03-14 14:00:04 +08:00 committed by Matt K. Fu
parent 27ad25ccca
commit 8dee211ab4
2 changed files with 101 additions and 56 deletions

View File

@ -12,7 +12,8 @@
//confirm-message ="Some message", this will prompt user with a confirm box and show the message before ajax call is made.
//"toggle-onclick" = "classes to get toggle" this will toggle classes on toggle when a tags are clicked.
//"delete-item" = "true" this will remove its respective item from the list.
//"pagination-link" = "url" this url will be used for pagination.. this will override last link url.
//"pagination-var" = "variable to send paramater with url for pagination" this will enable pagination with this attribute for that view.
//for layout tinyscrollbar
//content-layout="datalist|column|simple" datalist is for data list from database.. column is usually for forms and some other pages.. simple is without any columns, the page will be displayed as it is.. base width will be considered the default width for tinyscrollbar
@ -335,7 +336,7 @@ var orbitDesktop = function(dom){
var w = (!isNaN(base_width) ? base_width * total_columns : null);
return {"markup":temp_div.html(),"width":w,"total":entries.length};
}
$("div[container=true]").html(h).find("div.overview").wrap('<div class="tinycanvas vp"><div class="viewport"></div></div>');
$("div[container=true]").html(h).find("div.overview").wrap('<div class="tinycanvas"><div class="viewport"></div></div>');
$("div[container=true]").find("div.tinycanvas").prepend('<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>');
var f = o.layout_data.generate_layout_html(h)
$("div[container=true] div.overview").html(f.markup);
@ -920,59 +921,94 @@ var orbitDesktop = function(dom){
this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager
var elementParent,element,slabel;
var bindHandlers = function(){ // this is bind handler for section manager page
var groupWrapperWidth = 0;
$("div#sections .group").width(400);
$("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
var groupWrapperWidth = 0;
$("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
groupWrapperWidth+=200;
groupWrapperHeight = $(".group").height() + 20;
$("#group_wrapper").width(groupWrapperWidth);
$("div#sections #group_wrapper .grp").sortable({
start:function(){
slabel = $(this).siblings('.section_label');
slabel.find('li:hidden').stop(1,1).fadeIn(500);
},
stop:function(){
slabel.find('li:not(:nth-child(1))').stop(1,1).fadeOut(500);
}
});
$("div#sections .section_label li:not(:nth-child(1))").droppable({
drop:function(event, ui){
elementParent = ui.draggable.parents('.group');
var $item = $( this ),
$list = $( '#'+$item.data("category") );
groupWrapperHeight = $(".group").height() + 20;
$("#group_wrapper").width(groupWrapperWidth);
if($list.children('.element').length>=24){
o.notify("Section is full.","alert");
}
else{
ui.draggable.hide('fast',function(){
$(this).appendTo($list).fadeIn();
var sortingoptions = {
start:function(){
slabel = $(this).parent().siblings('.section_label');
slabel.find('li:hidden').stop(1,1).fadeIn(500);
},
stop:function(){
slabel.find('li:not(:nth-child(1))').stop(1,1).fadeOut(500);
}
}
$("div#sections #group_wrapper .appgroup").sortable(sortingoptions);
$("div#sections .section_label li:not(:nth-child(1))").droppable({
drop:function(event, ui){
elementParent = ui.draggable.parents('.group');
elementParentUl = ui.draggable.parents(".appgroup");
var $item = $( this ),
$list = $( '#'+$item.data("category") );
if($list.children('.element').length>=24){
o.notify("Section is full.","alert");
}else{
ui.draggable.hide('fast',function(){
var newul = false;
if($list.find("ul").length == 0){
$list.append(('<ul class="appgroup w1" ></ul>'));
newul = true;
}else if($list.find("ul:eq(0) li").length == 7){
$list.append(('<ul class="appgroup w1" ></ul>'));
newul = true;
}
$(this).appendTo($list.find("ul:last")).fadeIn();
var next_group = elementParent.find(".grp ul").eq(elementParentUl.index() + 1);
if(elementParentUl.index() == 0){
if(elementParentUl.find("li").length < 7){
var element_to_shift = next_group.find("li").eq(0);
if(element_to_shift.length != 0){
elementParentUl.append(element_to_shift);
}
}
}
if(next_group.find("li").length == 0){
next_group.remove();
}
if(elementParentUl.find("li").length == 0){
elementParentUl.remove();
}
if(elementParent.find(".grp ul").length == 0){
elementParent.find(".grp").addClass("no_app");
}else{
elementParent.find(".grp").removeClass("no_app");
}
if(newul){
$("div#sections #group_wrapper .appgroup").sortable(sortingoptions);
$list.removeClass("no_app");
}
});
$.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":ui.draggable.attr("id"),"newsectionid":$(this).data("content"),"desktopid":o.desktopId});
if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){
o.desktopData["home"]="";
}
}
$(this).find('span.tile').addClass('op06',400);
},
over:function(){
$(this).find('span.tile').removeClass('op06');
},
out:function(){
$(this).find('span.tile').addClass('op06');
},
accept: '.to_drop'
});
$.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":ui.draggable.attr("id"),"newsectionid":$(this).data("content"),"desktopid":o.desktopId});
if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){
o.desktopData["home"]="";
}
}
$(this).find('span.tile').addClass('op06',400);
},
over:function(){
$(this).find('span.tile').removeClass('op06');
},
out:function(){
$(this).find('span.tile').addClass('op06');
},
accept: '.to_drop'
});
};
var loadApps = function(){ // this loads apps from db to in each sections
$.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>');
$group = $('<div class="group" id="'+o.sectionList[section]._id+'"><div class="section_label"><ul class="section_grp"></ul></div><div id="section'+(z+1)+'" class="grp no_app" style="min-width:120px;"></div></div>');
for(x=0;x<4;x++){
if(x==0){
$li = $('<li class="element w1 h1 hp vp thmtxt" data-content="'+o.sectionList[z]._id+'"><span class="tile thmc1"></span><span class="thmtxt">'+o.sectionList[z].name+'</span></li>');
@ -987,19 +1023,27 @@ var orbitDesktop = function(dom){
$("div#group_wrapper").append($group);
}
var yy=1,y=0;
$.each(appss,function(i,apps){
$.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>');
$("ul#section"+yy).append($li);
var x = 0;
$.each(appss,function(i,apps){
x = 0;
$.each(apps,function(y,app){
x++;
if(x == 1){
$ul = $('<ul class="appgroup w1" ></ul>');
}
$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>');
$ul.append($li);
if(x == 7){
$("div#group_wrapper div#section"+(i+1)).append($ul);
$("div#group_wrapper div#section"+(i+1)).removeClass("no_app")
x = 0;
}
})
if(y==1){
y=-1;
yy++;
if(x != 0){
$("div#group_wrapper div#section"+(i+1)).append($ul);
$("div#group_wrapper div#section"+(i+1)).removeClass("no_app")
}
y++;
})
bindHandlers();
})

View File

@ -40,6 +40,7 @@ class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController
if @conference_co_author_relation.update_attributes(params[:conference_co_author_relation])
@conference_co_author_relations = ConferenceCoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @conference_co_author_relations
newv = '<div class="overview" content-layout="datalist" per-column="4" base-width="300">' + newv + '</div>'
render json: {success: true, msg: t('update_success'), newvalue: newv}.to_json
else
error_msg = @conference_co_author.errors.full_messages.join("<br />")