From 912080482b313a1171d429ed3a6cebe3d7fc8292 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 27 Feb 2013 11:47:41 +0800 Subject: [PATCH] some changes for gridster --- app/assets/javascripts/orbitdesktop.js | 83 ++++++++++++++++---------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index e1fded1f..08fd3337 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -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(!isNaN(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'); @@ -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();