|
1 |
| -/*! gridster.js - v0.1.0 - 2012-08-08 |
| 1 | +/*! gridster.js - v0.1.0 - 2012-08-13 |
2 | 2 | * http://gridster.net/
|
3 | 3 | * Copyright (c) 2012 ducksboard; Licensed MIT */
|
4 | 4 |
|
|
561 | 561 |
|
562 | 562 | return false;
|
563 | 563 | });
|
| 564 | + |
| 565 | + return false; |
564 | 566 | };
|
565 | 567 |
|
566 | 568 |
|
|
643 | 645 | return false;
|
644 | 646 | };
|
645 | 647 |
|
| 648 | + fn.on_select_start = function(e) { |
| 649 | + return false; |
| 650 | + } |
| 651 | + |
646 | 652 |
|
647 | 653 | fn.enable = function(){
|
| 654 | + this.$container.on('selectstart', this.on_select_start); |
| 655 | + |
648 | 656 | this.$container.on(pointer_events.start, this.options.items, $.proxy(
|
649 | 657 | this.drag_handler, this));
|
650 | 658 |
|
|
661 | 669 | fn.disable = function(){
|
662 | 670 | this.$container.off(pointer_events.start);
|
663 | 671 | this.$body.off(pointer_events.end);
|
| 672 | + this.$container.off(this.on_select_start); |
664 | 673 | };
|
665 | 674 |
|
666 | 675 |
|
|
1526 | 1535 | return this;
|
1527 | 1536 | };
|
1528 | 1537 |
|
1529 |
| - |
1530 | 1538 | /**
|
1531 | 1539 | * Determines if there is a widget in the row and col given. Or if the
|
1532 | 1540 | * HTMLElement passed as first argument is the player.
|
|
1554 | 1562 | * @return {Boolean} Returns true or false.
|
1555 | 1563 | */
|
1556 | 1564 | fn.is_player_in = function(col, row) {
|
1557 |
| - var c = this.cells_occupied_by_player; |
| 1565 | + var c = this.cells_occupied_by_player || {}; |
1558 | 1566 | return $.inArray(col, c.cols) >= 0 && $.inArray(row, c.rows) >= 0;
|
1559 | 1567 | };
|
1560 | 1568 |
|
|
1802 | 1810 | var upper_rows = [];
|
1803 | 1811 | var min_row = 10000;
|
1804 | 1812 |
|
| 1813 | + if (widget_grid_data.col < this.player_grid_data.col && |
| 1814 | + (widget_grid_data.col + widget_grid_data.size_y - 1) > |
| 1815 | + (this.player_grid_data.col + this.player_grid_data.size_y - 1) |
| 1816 | + ) { |
| 1817 | + return false; |
| 1818 | + }; |
| 1819 | + |
1805 | 1820 | /* generate an array with columns as index and array with upper rows
|
1806 | 1821 | * empty as value */
|
1807 | 1822 | this.for_each_column_occupied(widget_grid_data, function(tcol) {
|
|
1811 | 1826 | var r = p_bottom_row + 1;
|
1812 | 1827 |
|
1813 | 1828 | while (--r > 0) {
|
1814 |
| - if (this.is_occupied(tcol, r) && !this.is_player(tcol, r)) { |
1815 |
| - break; |
| 1829 | + if (this.is_widget(tcol, r) && !this.is_player_in(tcol, r)) { |
| 1830 | + if (!grid_col[r].is(widget_grid_data.el)) { |
| 1831 | + break; |
| 1832 | + }; |
1816 | 1833 | }
|
1817 | 1834 |
|
1818 | 1835 | if (!this.is_player(tcol, r) &&
|
1819 |
| - !this.is_placeholder_in(tcol, r) |
1820 |
| - ) { |
| 1836 | + !this.is_placeholder_in(tcol, r) && |
| 1837 | + !this.is_player_in(tcol, r)) { |
1821 | 1838 | upper_rows[tcol].push(r);
|
1822 |
| - } |
| 1839 | + }; |
1823 | 1840 |
|
1824 |
| - if (r < min_row ) { |
| 1841 | + if (r < min_row) { |
1825 | 1842 | min_row = r;
|
1826 | 1843 | }
|
1827 | 1844 | }
|
|
1863 | 1880 | while (++r <= p_bottom_row ) {
|
1864 | 1881 | var common = true;
|
1865 | 1882 | $.each(upper_rows, function(col, rows) {
|
1866 |
| - if (rows && $.inArray(r, rows) === -1) { |
| 1883 | + if ($.isArray(rows) && $.inArray(r, rows) === -1) { |
1867 | 1884 | common = false;
|
1868 | 1885 | }
|
1869 | 1886 | });
|
|
1888 | 1905 | }
|
1889 | 1906 | }
|
1890 | 1907 |
|
1891 |
| - |
1892 | 1908 | return new_row;
|
1893 | 1909 | };
|
1894 | 1910 |
|
|
1983 | 1999 | * @return {HTMLElements} Returns a jQuery collection of HTMLElements.
|
1984 | 2000 | */
|
1985 | 2001 | fn.on_stop_overlapping_column = function(col) {
|
1986 |
| - this.set_player(); |
| 2002 | + this.set_player(col, false); |
1987 | 2003 |
|
1988 | 2004 | var self = this;
|
1989 | 2005 | this.for_each_widget_below(col, this.cells_occupied_by_player.rows[0],
|
|
2001 | 2017 | * @return {HTMLElements} Returns a jQuery collection of HTMLElements.
|
2002 | 2018 | */
|
2003 | 2019 | fn.on_stop_overlapping_row = function(row) {
|
2004 |
| - this.set_player(); |
| 2020 | + this.set_player(false, row); |
2005 | 2021 |
|
2006 | 2022 | var self = this;
|
2007 | 2023 | var cols = this.cells_occupied_by_player.cols;
|
|
2047 | 2063 | var $w = $(widget);
|
2048 | 2064 | var wgd = $w.coords().grid;
|
2049 | 2065 | var can_go_up = self.can_go_widget_up(wgd);
|
2050 |
| - |
2051 | 2066 | if (can_go_up && can_go_up !== wgd.row) {
|
2052 | 2067 | self.move_widget_to($w, can_go_up);
|
2053 | 2068 | }
|
|
2314 | 2329 | var $w = this.is_widget(col, prev_row);
|
2315 | 2330 | if (this.is_occupied(col, prev_row) ||
|
2316 | 2331 | this.is_player(col, prev_row) ||
|
2317 |
| - this.is_placeholder_in(col, prev_row) |
| 2332 | + this.is_placeholder_in(col, prev_row) || |
| 2333 | + this.is_player_in(col, prev_row) |
2318 | 2334 | ) {
|
2319 | 2335 | result = false;
|
2320 | 2336 | return true; //break
|
|
0 commit comments