Working on Static widgets

This commit is contained in:
Dustin Moore
2013-02-28 13:52:34 -08:00
parent 8f431a4233
commit ac8894d4bb
7 changed files with 158 additions and 53 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
/*! gridster.js - v0.1.0 - 2012-12-11
/*! gridster.js - v0.1.0 - 2013-02-28
* http://gridster.net/
* Copyright (c) 2012 ducksboard; Licensed MIT */
* Copyright (c) 2013 ducksboard; Licensed MIT */
.gridster {
position:relative;
+50 -15
View File
@@ -1,6 +1,6 @@
/*! gridster.js - v0.1.0 - 2012-12-11
/*! gridster.js - v0.1.0 - 2013-02-28
* http://gridster.net/
* Copyright (c) 2012 ducksboard; Licensed MIT */
* Copyright (c) 2013 ducksboard; Licensed MIT */
;(function($, window, document, undefined){
/**
@@ -703,6 +703,7 @@
;(function($, window, document, undefined) {
//ToDo Max_cols and Max_size_x conflict.. need to unify
var defaults = {
namespace: '',
widget_selector: 'li',
@@ -712,7 +713,7 @@
extra_rows: 0,
extra_cols: 0,
min_cols: 1,
max_cols: 50,
max_cols: 60,
min_rows: 15,
max_rows: 15,
max_size_x: 6,
@@ -1719,10 +1720,15 @@
///If set to false smaller widgets will not displace larger widgets.
if(this.options.shift_larger_widgets_down && !swap){
var constraints = this.widgets_constraints($overlapped_widgets);
$overlapped_widgets.each($.proxy(function(i, w){
var $w = $(w);
var wgd = $w.coords().grid;
if($gr.can_go_down($w)){
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
}
}));
this.manage_movements(constraints.can_go_up, to_col, to_row);
this.manage_movements(constraints.can_not_go_up, to_col, to_row);
}
@@ -2015,6 +2021,8 @@
/**
* Sorts an Array of grid coords objects (representing the grid coords of
* each widget) in descending way.
* Depreciated.
*
* @method manage_movements
* @param {HTMLElements} $widgets A jQuery collection of HTMLElements
@@ -2047,9 +2055,11 @@
// so we need to move widget down to a position that dont
// overlaps player
var y = (to_row + this.player_grid_data.size_y) - wgd.row;
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
if (this.can_go_down($w)){
console.log("In Move Down!")
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
}
}
}
}, this));
@@ -2286,11 +2296,18 @@
});
if (moved_down || changed_column) {
/* $nexts.each($.proxy(function(i, widget) {
console.log("set_placeholder");
this.move_widget_up(
$(widget), this.placeholder_grid_data.col - col + phgd.size_y);
}, this)); */
$nexts.each($.proxy(function(i, widget) {
//Make sure widget is at it's topmost position
$w = $(widget);
wgd = $w.coords().grid;
var can_go_widget_up = this.can_go_widget_up(wgd);
if (can_go_widget_up) {
this.move_widget_to($w, can_go_widget_up);
}
}, this));
}
@@ -2883,6 +2900,23 @@
return this;
};
fn.can_go_down = function($el) {
var can_go_down = true;
var $gr = this;
if ($el.hasClass(this.options.static_class)){
can_go_down = false;
}
this.widgets_below($el).each(function(){
if ($(this).hasClass($gr.options.static_class)){
can_go_down = false;
}
})
return can_go_down;
}
fn.can_go_up = function($el) {
var el_grid_data = $el.coords().grid;
@@ -3116,7 +3150,8 @@
) {
cr = callback.call(ga[col][trow], col, trow);
matched.push(ga[col][trow]);
if (cr) { break; }
//break was causing problems, leaving for testing.
//if (cr) { break; }
}
}
}
+2 -2
View File
@@ -1,3 +1,3 @@
/*! gridster.js - v0.1.0 - 2012-12-11
/*! gridster.js - v0.1.0 - 2013-02-28
* http://gridster.net/
* Copyright (c) 2012 ducksboard; Licensed MIT */.gridster{position:relative}.gridster>*{margin:0 auto;-webkit-transition:height .4s;-moz-transition:height .4s;-o-transition:height .4s;-ms-transition:height .4s;transition:height .4s}.gridster .gs_w{z-index:2;position:absolute}.ready .gs_w:not(.preview-holder){-webkit-transition:opacity .3s,left .3s,top .3s;-moz-transition:opacity .3s,left .3s,top .3s;-o-transition:opacity .3s,left .3s,top .3s;transition:opacity .3s,left .3s,top .3s}.ready .gs_w:not(.preview-holder){-webkit-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-moz-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-o-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;transition:opacity .3s,left .3s,top .3s,width .3s,height .3s}.gridster .preview-holder{z-index:1;position:absolute;background-color:#fff;border-color:#fff;opacity:.3}.gridster .player-revert{z-index:10!important;-webkit-transition:left .3s,top .3s!important;-moz-transition:left .3s,top .3s!important;-o-transition:left .3s,top .3s!important;transition:left .3s,top .3s!important}.gridster .dragging{z-index:10!important;-webkit-transition:all 0s!important;-moz-transition:all 0s!important;-o-transition:all 0s!important;transition:all 0s!important}
* Copyright (c) 2013 ducksboard; Licensed MIT */.gridster{position:relative}.gridster>*{margin:0 auto;-webkit-transition:height .4s;-moz-transition:height .4s;-o-transition:height .4s;-ms-transition:height .4s;transition:height .4s}.gridster .gs_w{z-index:2;position:absolute}.ready .gs_w:not(.preview-holder){-webkit-transition:opacity .3s,left .3s,top .3s;-moz-transition:opacity .3s,left .3s,top .3s;-o-transition:opacity .3s,left .3s,top .3s;transition:opacity .3s,left .3s,top .3s}.ready .gs_w:not(.preview-holder){-webkit-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-moz-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-o-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;transition:opacity .3s,left .3s,top .3s,width .3s,height .3s}.gridster .preview-holder{z-index:1;position:absolute;background-color:#fff;border-color:#fff;opacity:.3}.gridster .player-revert{z-index:10!important;-webkit-transition:left .3s,top .3s!important;-moz-transition:left .3s,top .3s!important;-o-transition:left .3s,top .3s!important;transition:left .3s,top .3s!important}.gridster .dragging{z-index:10!important;-webkit-transition:all 0s!important;-moz-transition:all 0s!important;-o-transition:all 0s!important;transition:all 0s!important}
+3 -3
View File
File diff suppressed because one or more lines are too long
+50 -15
View File
@@ -1,6 +1,6 @@
/*! gridster.js - v0.1.0 - 2012-12-11
/*! gridster.js - v0.1.0 - 2013-02-28
* http://gridster.net/
* Copyright (c) 2012 ducksboard; Licensed MIT */
* Copyright (c) 2013 ducksboard; Licensed MIT */
;(function($, window, document, undefined){
/**
@@ -703,6 +703,7 @@
;(function($, window, document, undefined) {
//ToDo Max_cols and Max_size_x conflict.. need to unify
var defaults = {
namespace: '',
widget_selector: 'li',
@@ -712,7 +713,7 @@
extra_rows: 0,
extra_cols: 0,
min_cols: 1,
max_cols: 50,
max_cols: 60,
min_rows: 15,
max_rows: 15,
max_size_x: 6,
@@ -1719,10 +1720,15 @@
///If set to false smaller widgets will not displace larger widgets.
if(this.options.shift_larger_widgets_down && !swap){
var constraints = this.widgets_constraints($overlapped_widgets);
$overlapped_widgets.each($.proxy(function(i, w){
var $w = $(w);
var wgd = $w.coords().grid;
if($gr.can_go_down($w)){
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
}
}));
this.manage_movements(constraints.can_go_up, to_col, to_row);
this.manage_movements(constraints.can_not_go_up, to_col, to_row);
}
@@ -2015,6 +2021,8 @@
/**
* Sorts an Array of grid coords objects (representing the grid coords of
* each widget) in descending way.
* Depreciated.
*
* @method manage_movements
* @param {HTMLElements} $widgets A jQuery collection of HTMLElements
@@ -2047,9 +2055,11 @@
// so we need to move widget down to a position that dont
// overlaps player
var y = (to_row + this.player_grid_data.size_y) - wgd.row;
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
if (this.can_go_down($w)){
console.log("In Move Down!")
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
}
}
}
}, this));
@@ -2286,11 +2296,18 @@
});
if (moved_down || changed_column) {
/* $nexts.each($.proxy(function(i, widget) {
console.log("set_placeholder");
this.move_widget_up(
$(widget), this.placeholder_grid_data.col - col + phgd.size_y);
}, this)); */
$nexts.each($.proxy(function(i, widget) {
//Make sure widget is at it's topmost position
$w = $(widget);
wgd = $w.coords().grid;
var can_go_widget_up = this.can_go_widget_up(wgd);
if (can_go_widget_up) {
this.move_widget_to($w, can_go_widget_up);
}
}, this));
}
@@ -2883,6 +2900,23 @@
return this;
};
fn.can_go_down = function($el) {
var can_go_down = true;
var $gr = this;
if ($el.hasClass(this.options.static_class)){
can_go_down = false;
}
this.widgets_below($el).each(function(){
if ($(this).hasClass($gr.options.static_class)){
can_go_down = false;
}
})
return can_go_down;
}
fn.can_go_up = function($el) {
var el_grid_data = $el.coords().grid;
@@ -3116,7 +3150,8 @@
) {
cr = callback.call(ga[col][trow], col, trow);
matched.push(ga[col][trow]);
if (cr) { break; }
//break was causing problems, leaving for testing.
//if (cr) { break; }
}
}
}
File diff suppressed because one or more lines are too long
+48 -13
View File
@@ -7,6 +7,7 @@
*/
;(function($, window, document, undefined) {
//ToDo Max_cols and Max_size_x conflict.. need to unify
var defaults = {
namespace: '',
widget_selector: 'li',
@@ -16,7 +17,7 @@
extra_rows: 0,
extra_cols: 0,
min_cols: 1,
max_cols: 50,
max_cols: 60,
min_rows: 15,
max_rows: 15,
max_size_x: 6,
@@ -1023,10 +1024,15 @@
///If set to false smaller widgets will not displace larger widgets.
if(this.options.shift_larger_widgets_down && !swap){
var constraints = this.widgets_constraints($overlapped_widgets);
$overlapped_widgets.each($.proxy(function(i, w){
var $w = $(w);
var wgd = $w.coords().grid;
if($gr.can_go_down($w)){
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
}
}));
this.manage_movements(constraints.can_go_up, to_col, to_row);
this.manage_movements(constraints.can_not_go_up, to_col, to_row);
}
@@ -1319,6 +1325,8 @@
/**
* Sorts an Array of grid coords objects (representing the grid coords of
* each widget) in descending way.
* Depreciated.
*
* @method manage_movements
* @param {HTMLElements} $widgets A jQuery collection of HTMLElements
@@ -1351,9 +1359,11 @@
// so we need to move widget down to a position that dont
// overlaps player
var y = (to_row + this.player_grid_data.size_y) - wgd.row;
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
if (this.can_go_down($w)){
console.log("In Move Down!")
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
}
}
}
}, this));
@@ -1590,11 +1600,18 @@
});
if (moved_down || changed_column) {
/* $nexts.each($.proxy(function(i, widget) {
console.log("set_placeholder");
this.move_widget_up(
$(widget), this.placeholder_grid_data.col - col + phgd.size_y);
}, this)); */
$nexts.each($.proxy(function(i, widget) {
//Make sure widget is at it's topmost position
$w = $(widget);
wgd = $w.coords().grid;
var can_go_widget_up = this.can_go_widget_up(wgd);
if (can_go_widget_up) {
this.move_widget_to($w, can_go_widget_up);
}
}, this));
}
@@ -2187,6 +2204,23 @@
return this;
};
fn.can_go_down = function($el) {
var can_go_down = true;
var $gr = this;
if ($el.hasClass(this.options.static_class)){
can_go_down = false;
}
this.widgets_below($el).each(function(){
if ($(this).hasClass($gr.options.static_class)){
can_go_down = false;
}
})
return can_go_down;
}
fn.can_go_up = function($el) {
var el_grid_data = $el.coords().grid;
@@ -2420,7 +2454,8 @@
) {
cr = callback.call(ga[col][trow], col, trow);
matched.push(ga[col][trow]);
if (cr) { break; }
//break was causing problems, leaving for testing.
//if (cr) { break; }
}
}
}