updated dist

This commit is contained in:
vieron
2012-07-20 14:03:32 +02:00
parent fbeb2ac05c
commit 0b310de6e7
2 changed files with 37 additions and 12 deletions
+36 -11
View File
@@ -484,9 +484,7 @@
} }
if (valid_pos.length) { if (valid_pos.length) {
var next_position = this.sort_by_row_desc(valid_pos); return this.sort_by_row_and_col_asc(valid_pos)[0];
next_position = this.sort_by_col_asc(next_position)[0];
return next_position;
} }
return false; return false;
}; };
@@ -499,7 +497,7 @@
* @param {HTMLElement} el The jQuery wrapped HTMLElement you want to remove. * @param {HTMLElement} el The jQuery wrapped HTMLElement you want to remove.
* @return {Class} Returns the instance of the Gridster Class. * @return {Class} Returns the instance of the Gridster Class.
*/ */
fn.remove_widget = function(el) { fn.remove_widget = function(el, callback) {
var $el = el instanceof jQuery ? el : $(el); var $el = el instanceof jQuery ? el : $(el);
var wgd = $el.coords().grid; var wgd = $el.coords().grid;
@@ -515,6 +513,10 @@
this.move_widget_up( $(widget), wgd.size_y ); this.move_widget_up( $(widget), wgd.size_y );
}, this)); }, this));
}, this)); }, this));
if (callback) {
callback.apply(el);
};
}; };
@@ -650,6 +652,7 @@
self.$player = $(this); self.$player = $(this);
self.$helper = self.options.draggable.helper === 'clone' ? self.$helper = self.options.draggable.helper === 'clone' ?
$(ui.helper) : self.$player; $(ui.helper) : self.$player;
self.helper = !self.$helper.is(self.$player);
self.on_start_drag.call(self, event, ui); self.on_start_drag.call(self, event, ui);
self.$el.trigger('gridster:dragstart'); self.$el.trigger('gridster:dragstart');
@@ -665,8 +668,7 @@
}); });
this.$widgets.draggable(draggable_options); this.$widgets.draggable(draggable_options);
return this;
return this;
}; };
@@ -740,6 +742,13 @@
this.on_stop_overlapping_row this.on_stop_overlapping_row
); );
if (this.helper && this.$player) {
this.$player.css({
'left': ui.position.left,
'top': ui.position.top
});
}
if (this.options.draggable.drag) { if (this.options.draggable.drag) {
this.options.draggable.drag.call(this, event, ui); this.options.draggable.drag.call(this, event, ui);
} }
@@ -754,6 +763,7 @@
* See http://jqueryui.com/demos/draggable/ for more info. * See http://jqueryui.com/demos/draggable/ for more info.
*/ */
fn.on_stop_drag = function(event, ui) { fn.on_stop_drag = function(event, ui) {
this.$wrapper.removeClass('dragging');
this.colliders_data = this.drag_api.get_closest_colliders(); this.colliders_data = this.drag_api.get_closest_colliders();
this.on_overlapped_column_change( this.on_overlapped_column_change(
@@ -981,6 +991,26 @@
}; };
/**
* Sorts an Array of grid coords objects (representing the grid coords of
* each widget) placing first the empty cells upper left.
*
* @method sort_by_row_asc
* @param {Array} widgets Array of grid coords objects
* @return {Array} Returns the array sorted.
*/
fn.sort_by_row_and_col_asc = function(widgets) {
widgets = widgets.sort(function(a, b){
if (a.row > b.row || a.row == b.row && a.col > b.col) {
return 1;
}
return -1;
});
return widgets;
};
/** /**
* Sorts an Array of grid coords objects by column (representing the grid * Sorts an Array of grid coords objects by column (representing the grid
* coords of each widget) in ascending way. * coords of each widget) in ascending way.
@@ -2301,14 +2331,9 @@
cols = Math.max(min_cols, cols, this.options.min_cols); cols = Math.max(min_cols, cols, this.options.min_cols);
rows = Math.max(min_rows, rows, this.options.min_rows); rows = Math.max(min_rows, rows, this.options.min_rows);
//this.support_grid_width = cols * this.min_widget_width;
// this.support_grid_width = this.wrapper_width;
// this.support_grid_height = rows * this.min_widget_height;
this.baseX = ($(window).width() - aw) / 2; this.baseX = ($(window).width() - aw) / 2;
this.baseY = this.$wrapper.offset().top; this.baseY = this.$wrapper.offset().top;
//this.baseX = 0;
if (this.options.autogenerate_stylesheet) { if (this.options.autogenerate_stylesheet) {
this.generate_stylesheet(rows, cols); this.generate_stylesheet(rows, cols);
} }
+1 -1
View File
File diff suppressed because one or more lines are too long