updated dist

This commit is contained in:
vieron
2012-10-07 21:12:38 +02:00
parent 42ce094e1c
commit 6ebd10139f
6 changed files with 3460 additions and 57 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/*! gridster.js - v0.1.0 - 2012-09-12
/*! gridster.js - v0.1.0 - 2012-10-03
* http://gridster.net/
* Copyright (c) 2012 ducksboard; Licensed MIT */
+95 -53
View File
@@ -1,4 +1,4 @@
/*! gridster.js - v0.1.0 - 2012-09-12
/*! gridster.js - v0.1.0 - 2012-10-03
* http://gridster.net/
* Copyright (c) 2012 ducksboard; Licensed MIT */
@@ -420,12 +420,28 @@
fn.init = function() {
this.calculate_positions();
this.$container.css('position', 'relative');
this.enable();
this.disabled = false;
this.events();
$(window).bind('resize',
throttle($.proxy(this.calculate_positions, this), 200));
};
fn.events = function() {
this.$container.on('selectstart', this.on_select_start);
this.$container.on(pointer_events.start, this.options.items, $.proxy(
this.drag_handler, this));
this.$body.on(pointer_events.end, $.proxy(function(e) {
this.is_dragging = false;
if (this.disabled) { return; }
this.$body.off(pointer_events.move);
if (this.drag_start) {
this.on_dragstop(e);
}
}, this));
};
fn.get_actual_pos = function($el) {
var pos = $el.position();
@@ -437,7 +453,7 @@
if (isTouch) {
var oe = e.originalEvent;
e = oe.touches.length ? oe.touches[0] : oe.changedTouches[0];
};
}
return {
left: e.clientX,
@@ -496,7 +512,7 @@
$window.scrollTop(nextScrollTop);
this.scrollOffset = this.scrollOffset + 30;
}
};
}
if (abs_mouse_top <= mouse_up_zone) {
nextScrollTop = scrollTop - 30;
@@ -504,26 +520,25 @@
$window.scrollTop(nextScrollTop);
this.scrollOffset = this.scrollOffset - 30;
}
};
}
}
};
fn.calculate_positions = function(e) {
this.window_height = $window.height();
}
};
fn.drag_handler = function(e) {
var node = e.target.nodeName;
if (e.which !== 1 && !isTouch) {
if (this.disabled || e.which !== 1 && !isTouch) {
return;
}
if (node === 'INPUT' || node === 'TEXTAREA' || node === 'SELECT' ||
node === 'BUTTON') {
return;
};
}
var self = this;
var first = true;
@@ -551,7 +566,7 @@
return false;
}
if (self.is_dragging == true) {
if (self.is_dragging === true) {
self.on_dragmove.call(self, mme);
}
@@ -642,30 +657,16 @@
};
fn.on_select_start = function(e) {
if (this.disabled) { return; }
return false;
}
fn.enable = function(){
this.$container.on('selectstart', this.on_select_start);
this.$container.on(pointer_events.start, this.options.items, $.proxy(
this.drag_handler, this));
this.$body.on(pointer_events.end, $.proxy(function(e) {
this.is_dragging = false;
this.$body.off(pointer_events.move);
if (this.drag_start) {
this.on_dragstop(e);
}
}, this));
};
fn.enable = function() {
this.disabled = false;
};
fn.disable = function(){
this.$container.off(pointer_events.start);
this.$body.off(pointer_events.end);
this.$container.off('selectstart', this.on_select_start);
fn.disable = function() {
this.disabled = true;
};
@@ -674,7 +675,6 @@
$.removeData(this.$container, 'drag');
};
//jQuery adapter
$.fn.drag = function ( options ) {
return this.each(function () {
@@ -859,6 +859,7 @@
this.register_widget($w);
this.add_faux_rows(pos.size_y);
this.add_faux_cols(pos.size_x);
this.set_dom_grid_height();
@@ -884,7 +885,7 @@
if (size_x > this.cols) {
size_x = this.cols;
};
}
var old_cells_occupied = this.get_cells_occupied(wgd);
var old_size_x = wgd.size_x;
@@ -898,7 +899,7 @@
var diff = old_col + (size_x - 1) - this.cols;
var c = old_col - diff;
new_col = Math.max(1, c);
};
}
var new_grid_data = {
col: new_col,
@@ -913,7 +914,7 @@
$.each(old_cells_occupied.cols, function(i, col) {
if ($.inArray(col, new_cells_occupied.cols) === -1) {
empty_cols.push(col);
};
}
});
var occupied_cols = [];
@@ -927,14 +928,14 @@
$.each(old_cells_occupied.rows, function(i, row) {
if ($.inArray(row, new_cells_occupied.rows) === -1) {
empty_rows.push(row);
};
}
});
var occupied_rows = [];
$.each(new_cells_occupied.rows, function(i, row) {
if ($.inArray(row, old_cells_occupied.rows) === -1) {
occupied_rows.push(row);
};
}
});
this.remove_from_gridmap(wgd);
@@ -944,12 +945,12 @@
new_col, wgd.row, size_x, Math.min(old_size_y, size_y), $widget
];
this.empty_cells.apply(this, cols_to_empty);
};
}
if (occupied_rows.length) {
var rows_to_empty = [new_col, wgd.row, size_x, size_y, $widget];
this.empty_cells.apply(this, rows_to_empty);
};
}
wgd.col = new_col;
wgd.size_x = size_x;
@@ -966,7 +967,11 @@
if (size_y > old_size_y) {
this.add_faux_rows(size_y - old_size_y);
};
}
if (size_x > old_size_x) {
this.add_faux_cols(size_x - old_size_x);
}
$widget.attr({
'data-col': new_col,
@@ -1019,7 +1024,7 @@
$nexts.not($exclude).each($.proxy(function(i, w) {
var wgd = $(w).coords().grid;
if (!(wgd.row <= (row + size_y - 1))) { return; };
if (!(wgd.row <= (row + size_y - 1))) { return; }
var diff = (row + size_y) - wgd.row;
this.move_widget_down($(w), diff);
}, this));
@@ -1059,7 +1064,7 @@
this.set_dom_grid_height();
return this;
}
};
/**
@@ -1077,9 +1082,10 @@
var ga = this.gridmap;
var cols_l = ga.length;
var valid_pos = [];
var rows_l;
for (var c = 1; c < cols_l; c++) {
var rows_l = ga[c].length;
rows_l = ga[c].length;
for (var r = 1; r <= rows_l; r++) {
var can_move_to = this.can_move_to({
size_x: size_x,
@@ -1211,7 +1217,7 @@
$el.data('coords').grid = wgd;
this.add_to_gridmap(wgd, $el);
this.widgets.push($el);
return this;
};
@@ -1372,7 +1378,7 @@
//break if dragstop has been fired
if (this.$player === null) {
return false;
};
}
var abs_offset = {
left: ui.position.left + this.baseX,
@@ -1555,7 +1561,7 @@
var self = this;
if (!no_player) {
this.empty_cells_player_occupies();
};
}
var cell = !no_player ? self.colliders_data[0].el.data : {col: col};
var to_col = cell.col;
var to_row = row || cell.row;
@@ -1644,7 +1650,7 @@
if (!a.row) {
a = $(a).coords().grid;
b = $(b).coords().grid;
};
}
if (a.row > b.row) {
return 1;
@@ -1666,7 +1672,7 @@
*/
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) {
if (a.row > b.row || a.row === b.row && a.col > b.col) {
return 1;
}
return -1;
@@ -2579,9 +2585,10 @@
* the widget.
* @param {Object} col The col to check.
* @param {Object} row The row to check.
* @param {Number} [max_row] The max row allowed.
* @return {Boolean} Returns true if all cells are empty, else return false.
*/
fn.can_move_to = function(widget_grid_data, col, row) {
fn.can_move_to = function(widget_grid_data, col, row, max_row) {
var ga = this.gridmap;
var $w = widget_grid_data.el;
var future_wd = {
@@ -2596,7 +2603,11 @@
var right_col = col + widget_grid_data.size_x - 1;
if (right_col > this.cols) {
return false;
};
}
if (max_row && max_row < row + widget_grid_data.size_y - 1) {
return false;
}
this.for_each_cell_occupied(future_wd, function(tcol, trow) {
var $tw = this.is_widget(tcol, trow);
@@ -2904,7 +2915,7 @@
opts || (opts = {});
opts.cols || (opts.cols = this.cols);
opts.rows || (opts.rows = this.rows);
opts.namespace || (opts.namespace = '');
opts.namespace || (opts.namespace = this.options.namespace);
opts.widget_base_dimensions ||
(opts.widget_base_dimensions = this.options.widget_base_dimensions);
opts.widget_margins ||
@@ -3021,6 +3032,10 @@
original_row: row
}).coords();
if (!$.isArray(this.gridmap[col])) {
this.gridmap[col] = [];
}
this.gridmap[col][row] = false;
this.faux_grid.push(coords);
@@ -3048,7 +3063,33 @@
this.rows = max_rows;
if (this.options.autogenerate_stylesheet) {
this.generate_stylesheet({namespace: this.options.namespace});
this.generate_stylesheet();
}
return this;
};
/**
* Add cols to the faux grid.
*
* @method add_faux_cols
* @param {Number} cols The number of cols you want to add to the faux grid.
* @return {Object} Returns the instance of the Gridster class.
*/
fn.add_faux_cols = function(cols) {
var actual_cols = this.cols;
var max_cols = actual_cols + (cols || 1);
for (var c = actual_cols; c < max_cols; c++) {
for (var r = this.rows; r >= 1; r--) {
this.add_faux_cell(r, c);
};
};
this.cols = max_cols;
if (this.options.autogenerate_stylesheet) {
this.generate_stylesheet();
}
return this;
@@ -3118,7 +3159,7 @@
// get all rows that could be occupied by the current widgets
var max_rows = this.options.extra_rows;
this.$widgets.each(function(i, w){
this.$widgets.each(function(i, w) {
max_rows += (+$(w).attr('data-sizey'));
});
@@ -3145,5 +3186,6 @@
});
};
$.Gridster = fn;
}(jQuery, window, document));
+1 -1
View File
@@ -1,3 +1,3 @@
/*! gridster.js - v0.1.0 - 2012-09-12
/*! gridster.js - v0.1.0 - 2012-10-03
* 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}
+2 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long