mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fixed add_widget method
This commit is contained in:
@@ -206,9 +206,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;
|
||||||
};
|
};
|
||||||
@@ -376,6 +374,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');
|
||||||
@@ -391,8 +390,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.$widgets.draggable(draggable_options);
|
this.$widgets.draggable(draggable_options);
|
||||||
|
return this;
|
||||||
return this;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -466,6 +464,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);
|
||||||
}
|
}
|
||||||
@@ -480,6 +485,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(
|
||||||
@@ -707,6 +713,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.
|
||||||
@@ -2027,14 +2053,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);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user