some changes for gridster

This commit is contained in:
Harry Bomrah 2013-02-27 11:47:41 +08:00 committed by Rueshyna
parent b8ee748723
commit 0f12314213
1 changed files with 53 additions and 30 deletions

View File

@ -459,41 +459,55 @@ var orbitDesktop = function(dom){
.gridster({
widget_margins: [6, 6],
widget_base_dimensions: [120, 120],
avoid_overlapped_widgets: true,
// avoid_overlapped_widgets: true,
draggable : {
stop: function(event, ui){
// var widgetchanged_col = dragged.attr("data-col");
// var total = 0;
// // console.log(widgetchanged.col);
// // console.log(o.gridvar.serialize_changed());
// $(".grid ul li[data-col="+widgetchanged_col+"]").each(function(i,w){
// var size = parseInt($(this).attr("data-sizey"));
// if(!isNaN(size)){
// total += size;
// }
// })
// // other way to calculate the overflow is by top > height of div
// if(total>totaltiles_in_a_row){
// revertbacktiles();
// }else{
// console.log(widgetchanged_col-1);
// $(".grid ul li[data-col="+(widgetchanged_col-1)+"]").each(function(i,w){
// var sizey = parseInt($(this).attr("data-sizey"));
// var sizex = parseInt($(this).attr("data-sizex"));
// if(sizey==1){
// sizex = sizex - 1;
// }
// console.log(sizex);
var widgetchanged_col = dragged.attr("data-col");
var total = 0;
// console.log(widgetchanged.col);
// console.log(o.gridvar.serialize_changed());
$(".grid ul li[data-col="+widgetchanged_col+"]").each(function(i,w){
var size = parseInt($(this).attr("data-sizey"));
if(!isNaN(size)){
total += size;
}
})
// other way to calculate the overflow is by top > height of div
if(total>totaltiles_in_a_row){
revertbacktiles();
}else{
console.log(widgetchanged_col-1);
$(".grid ul li[data-col="+(widgetchanged_col-1)+"]").each(function(i,w){
var sizey = parseInt($(this).attr("data-sizey"));
var sizex = parseInt($(this).attr("data-sizex"));
if(sizey==1){
sizex = sizex - 1;
}
console.log(sizex);
// if(!isNaN(sizex)){
// total += sizex;
// }
// })
// if(total>totaltiles_in_a_row){
// revertbacktiles();
// }
// }
if(!isNaN(sizex)){
total += sizex;
for (var i = 1; i <= 30; i++) {
// var celement = $(".grid ul .widget[data-col="+i+"]:last");
$(".grid ul .widget[data-col="+i+"]").each(function(){
var pos = $(this).position();
if(pos){
console.log(pos.top + $(this).height() + 6);
if((pos.top + $(this).height() + 6) > 550){
revertbacktiles();
}
}
})
if(total>totaltiles_in_a_row){
revertbacktiles();
}
}
}
}
}
}).data('gridster');
@ -502,6 +516,15 @@ var orbitDesktop = function(dom){
$(".grid ul li").each(function(i){
$(this).attr({"data-col":lastpos[i].col,"data-row":lastpos[i].row});
})
}
var remove_empty_columns = function(){
for (var i = 1; i <= 30; i++) {
// var celement = $(".grid ul .widget[data-col="+i+"]:last");
$(".grid ul .widget[data-col="+i+"]").each(function(){
})
break;
}
}
bindHandlers();
o.initializeWidgets();