some changes for gridster

This commit is contained in:
Harry Bomrah 2013-02-27 11:47:41 +08:00
parent e9c0f443b7
commit 912080482b
1 changed files with 53 additions and 30 deletions

View File

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